mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE] Support autobuild lwjgl3ify
This commit is contained in:
parent
5c7f7eedec
commit
bc6da641d6
2 changed files with 66 additions and 27 deletions
|
@ -27,6 +27,7 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti
|
||||||
builder.setMainClass(getMainClassByVersion(version, options));
|
builder.setMainClass(getMainClassByVersion(version, options));
|
||||||
builder.setServers(List.of(new ClientProfile.ServerProfile(title, "localhost", 25565)));
|
builder.setServers(List.of(new ClientProfile.ServerProfile(title, "localhost", 25565)));
|
||||||
// ------------
|
// ------------
|
||||||
|
var lwjgl3ify = findOption(options, Lwjgl3ifyOption.class);
|
||||||
builder.setUpdateVerify(List.of("libraries", "natives", "mods", "minecraft.jar", "forge.jar", "liteloader.jar"));
|
builder.setUpdateVerify(List.of("libraries", "natives", "mods", "minecraft.jar", "forge.jar", "liteloader.jar"));
|
||||||
{
|
{
|
||||||
List<String> classPath = new ArrayList<>(5);
|
List<String> classPath = new ArrayList<>(5);
|
||||||
|
@ -44,8 +45,40 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti
|
||||||
jvmArgs.add("-XX:+DisableAttachMechanism");
|
jvmArgs.add("-XX:+DisableAttachMechanism");
|
||||||
// Official Mojang launcher java arguments
|
// Official Mojang launcher java arguments
|
||||||
if (version.compareTo(ClientProfileVersions.MINECRAFT_1_12_2) <= 0) {
|
if (version.compareTo(ClientProfileVersions.MINECRAFT_1_12_2) <= 0) {
|
||||||
jvmArgs.add("-XX:+UseConcMarkSweepGC");
|
// lwjgl3ify arguments https://github.com/GTNewHorizons/lwjgl3ify
|
||||||
jvmArgs.add("-XX:+CMSIncrementalMode");
|
jvmArgs.add("-Djava.security.manager=allow");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.base/jdk.internal.loader=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.base/java.net=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.base/java.nio=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.base/java.io=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.base/java.lang=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.base/java.lang.reflect=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.base/java.text=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.base/java.util=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.base/jdk.internal.reflect=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.base/sun.nio.ch=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("jdk.naming.dns/com.sun.jndi.dns=ALL-UNNAMED,java.naming");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.desktop/sun.awt=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.desktop/sun.awt.image=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.desktop/com.sun.imageio.plugins.png=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("jdk.dynalink/jdk.dynalink.beans=ALL-UNNAMED");
|
||||||
|
jvmArgs.add("--add-opens");
|
||||||
|
jvmArgs.add("java.sql.rowset/javax.sql.rowset.serial=ALL-UNNAMED");
|
||||||
} else if (version.compareTo(ClientProfileVersions.MINECRAFT_1_18) <= 0) { // 1.13 - 1.16.5
|
} else if (version.compareTo(ClientProfileVersions.MINECRAFT_1_18) <= 0) { // 1.13 - 1.16.5
|
||||||
jvmArgs.add("-XX:+UseG1GC");
|
jvmArgs.add("-XX:+UseG1GC");
|
||||||
jvmArgs.add("-XX:+UnlockExperimentalVMOptions");
|
jvmArgs.add("-XX:+UnlockExperimentalVMOptions");
|
||||||
|
@ -116,14 +149,8 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (version.compareTo(ClientProfileVersions.MINECRAFT_1_17) >= 0 && version.compareTo(ClientProfileVersions.MINECRAFT_1_18) < 0) {
|
|
||||||
builder.setMinJavaVersion(16);
|
|
||||||
builder.setRecommendJavaVersion(16);
|
|
||||||
}
|
|
||||||
if (version.compareTo(ClientProfileVersions.MINECRAFT_1_18) >= 0) {
|
|
||||||
builder.setMinJavaVersion(17);
|
builder.setMinJavaVersion(17);
|
||||||
builder.setRecommendJavaVersion(17);
|
builder.setRecommendJavaVersion(17);
|
||||||
}
|
|
||||||
if(version.compareTo(ClientProfileVersions.MINECRAFT_1_20_3) >= 0) {
|
if(version.compareTo(ClientProfileVersions.MINECRAFT_1_20_3) >= 0) {
|
||||||
builder.setMinJavaVersion(21);
|
builder.setMinJavaVersion(21);
|
||||||
builder.setRecommendJavaVersion(21);
|
builder.setRecommendJavaVersion(21);
|
||||||
|
@ -133,7 +160,10 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti
|
||||||
builder.setJvmArgs(jvmArgs);
|
builder.setJvmArgs(jvmArgs);
|
||||||
builder.setUpdateOptional(optionals);
|
builder.setUpdateOptional(optionals);
|
||||||
List<String> clientArgs = new ArrayList<>();
|
List<String> clientArgs = new ArrayList<>();
|
||||||
if (findOption(options, MakeProfileOptionLaunchWrapper.class).isPresent()) {
|
if(version.compareTo(ClientProfileVersions.MINECRAFT_1_7_10) == 0) {
|
||||||
|
jvmArgs.add("-Drfb.skipClassLoaderCheck=true");
|
||||||
|
}
|
||||||
|
if (findOption(options, MakeProfileOptionLaunchWrapper.class).isPresent() || findOption(options, MakeProfileRfbOption.class).isPresent()) {
|
||||||
if (findOption(options, MakeProfileOptionLiteLoader.class).isPresent()) {
|
if (findOption(options, MakeProfileOptionLiteLoader.class).isPresent()) {
|
||||||
clientArgs.add("--tweakClass");
|
clientArgs.add("--tweakClass");
|
||||||
clientArgs.add("com.mumfrey.liteloader.launch.LiteLoaderTweaker");
|
clientArgs.add("com.mumfrey.liteloader.launch.LiteLoaderTweaker");
|
||||||
|
@ -145,20 +175,9 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti
|
||||||
} else {
|
} else {
|
||||||
clientArgs.add("cpw.mods.fml.common.launcher.FMLTweaker");
|
clientArgs.add("cpw.mods.fml.common.launcher.FMLTweaker");
|
||||||
}
|
}
|
||||||
if (version.compareTo(ClientProfileVersions.MINECRAFT_1_12_2) <= 0) {
|
|
||||||
builder.setMinJavaVersion(8);
|
|
||||||
builder.setRecommendJavaVersion(8);
|
|
||||||
builder.setMaxJavaVersion(8);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (version.compareTo(ClientProfileVersions.MINECRAFT_1_12_2) > 0) {
|
} else if (version.compareTo(ClientProfileVersions.MINECRAFT_1_12_2) > 0) {
|
||||||
if (forge.isPresent()) {
|
forge.ifPresent(makeProfileOptionForge -> clientArgs.addAll(makeProfileOptionForge.makeClientArgs()));
|
||||||
clientArgs.addAll(forge.get().makeClientArgs());
|
|
||||||
builder.setClassLoaderConfig(ClientProfile.ClassLoaderConfig.SYSTEM_ARGS);
|
|
||||||
if (version.compareTo(ClientProfileVersions.MINECRAFT_1_16_5) <= 0) {
|
|
||||||
builder.setMaxJavaVersion(15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
builder.setClientArgs(clientArgs);
|
builder.setClientArgs(clientArgs);
|
||||||
|
|
||||||
|
@ -171,6 +190,9 @@ private static <T> Optional<T> findOption(MakeProfileOption[] options, Class<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getMainClassByVersion(ClientProfile.Version version, MakeProfileOption... options) {
|
public static String getMainClassByVersion(ClientProfile.Version version, MakeProfileOption... options) {
|
||||||
|
if(version.compareTo(ClientProfileVersions.MINECRAFT_1_7_10) == 0) {
|
||||||
|
return "com.gtnewhorizons.retrofuturabootstrap.Main";
|
||||||
|
}
|
||||||
if (findOption(options, MakeProfileOptionLaunchWrapper.class).isPresent()) {
|
if (findOption(options, MakeProfileOptionLaunchWrapper.class).isPresent()) {
|
||||||
return "net.minecraft.launchwrapper.Launch";
|
return "net.minecraft.launchwrapper.Launch";
|
||||||
}
|
}
|
||||||
|
@ -320,6 +342,13 @@ public static class MakeProfileOptionLaunchWrapper implements MakeProfileOption
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class MakeProfileRfbOption implements MakeProfileOption {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public record Lwjgl3ifyOption(String lwjgl3ifyForgePatches) implements MakeProfileOption {
|
||||||
|
}
|
||||||
|
|
||||||
public static class MakeProfileOptionFabric implements MakeProfileOption {
|
public static class MakeProfileOptionFabric implements MakeProfileOption {
|
||||||
public String jimfsPath;
|
public String jimfsPath;
|
||||||
public String guavaPath;
|
public String guavaPath;
|
||||||
|
|
|
@ -121,6 +121,11 @@ private static void realMain(String[] args) throws Throwable {
|
||||||
List<Path> classpath = resolveClassPath(clientDir, params.actions, params.profile)
|
List<Path> classpath = resolveClassPath(clientDir, params.actions, params.profile)
|
||||||
.filter(x -> !profile.getModulePath().contains(clientDir.relativize(x).toString()))
|
.filter(x -> !profile.getModulePath().contains(clientDir.relativize(x).toString()))
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
if(LogHelper.isDevEnabled()) {
|
||||||
|
for(var e : classpath) {
|
||||||
|
LogHelper.dev("Classpath entry %s", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
List<URL> classpathURLs = classpath.stream().map(IOHelper::toURL).collect(Collectors.toList());
|
List<URL> classpathURLs = classpath.stream().map(IOHelper::toURL).collect(Collectors.toList());
|
||||||
// Start client with WatchService monitoring
|
// Start client with WatchService monitoring
|
||||||
RequestService service;
|
RequestService service;
|
||||||
|
@ -256,7 +261,12 @@ private static Stream<Path> resolveClassPathStream(Path clientDir, String... cla
|
||||||
for (String classPathEntry : classPath) {
|
for (String classPathEntry : classPath) {
|
||||||
Path path = clientDir.resolve(IOHelper.toPath(classPathEntry.replace(IOHelper.CROSS_SEPARATOR, IOHelper.PLATFORM_SEPARATOR)));
|
Path path = clientDir.resolve(IOHelper.toPath(classPathEntry.replace(IOHelper.CROSS_SEPARATOR, IOHelper.PLATFORM_SEPARATOR)));
|
||||||
if (IOHelper.isDir(path)) { // Recursive walking and adding
|
if (IOHelper.isDir(path)) { // Recursive walking and adding
|
||||||
IOHelper.walk(path, new ClassPathFileVisitor(builder), false);
|
List<Path> jars = new ArrayList<>(32);
|
||||||
|
IOHelper.walk(path, new ClassPathFileVisitor(jars), false);
|
||||||
|
Collections.sort(jars);
|
||||||
|
for(var e : jars) {
|
||||||
|
builder.accept(e);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
builder.accept(path);
|
builder.accept(path);
|
||||||
|
@ -322,16 +332,16 @@ private static void launch(ClientProfile profile, ClientParams params) throws Th
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class ClassPathFileVisitor extends SimpleFileVisitor<Path> {
|
private static final class ClassPathFileVisitor extends SimpleFileVisitor<Path> {
|
||||||
private final Stream.Builder<Path> result;
|
private final List<Path> result;
|
||||||
|
|
||||||
private ClassPathFileVisitor(Stream.Builder<Path> result) {
|
private ClassPathFileVisitor(List<Path> result) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||||
if (IOHelper.hasExtension(file, "jar") || IOHelper.hasExtension(file, "zip"))
|
if (IOHelper.hasExtension(file, "jar") || IOHelper.hasExtension(file, "zip"))
|
||||||
result.accept(file);
|
result.add(file);
|
||||||
return super.visitFile(file, attrs);
|
return super.visitFile(file, attrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue