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.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"));
|
||||
{
|
||||
List<String> classPath = new ArrayList<>(5);
|
||||
|
@ -44,8 +45,40 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti
|
|||
jvmArgs.add("-XX:+DisableAttachMechanism");
|
||||
// Official Mojang launcher java arguments
|
||||
if (version.compareTo(ClientProfileVersions.MINECRAFT_1_12_2) <= 0) {
|
||||
jvmArgs.add("-XX:+UseConcMarkSweepGC");
|
||||
jvmArgs.add("-XX:+CMSIncrementalMode");
|
||||
// lwjgl3ify arguments https://github.com/GTNewHorizons/lwjgl3ify
|
||||
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
|
||||
jvmArgs.add("-XX:+UseG1GC");
|
||||
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.setRecommendJavaVersion(17);
|
||||
}
|
||||
if(version.compareTo(ClientProfileVersions.MINECRAFT_1_20_3) >= 0) {
|
||||
builder.setMinJavaVersion(21);
|
||||
builder.setRecommendJavaVersion(21);
|
||||
|
@ -133,7 +160,10 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti
|
|||
builder.setJvmArgs(jvmArgs);
|
||||
builder.setUpdateOptional(optionals);
|
||||
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()) {
|
||||
clientArgs.add("--tweakClass");
|
||||
clientArgs.add("com.mumfrey.liteloader.launch.LiteLoaderTweaker");
|
||||
|
@ -145,20 +175,9 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti
|
|||
} else {
|
||||
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) {
|
||||
if (forge.isPresent()) {
|
||||
clientArgs.addAll(forge.get().makeClientArgs());
|
||||
builder.setClassLoaderConfig(ClientProfile.ClassLoaderConfig.SYSTEM_ARGS);
|
||||
if (version.compareTo(ClientProfileVersions.MINECRAFT_1_16_5) <= 0) {
|
||||
builder.setMaxJavaVersion(15);
|
||||
}
|
||||
}
|
||||
forge.ifPresent(makeProfileOptionForge -> clientArgs.addAll(makeProfileOptionForge.makeClientArgs()));
|
||||
}
|
||||
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) {
|
||||
if(version.compareTo(ClientProfileVersions.MINECRAFT_1_7_10) == 0) {
|
||||
return "com.gtnewhorizons.retrofuturabootstrap.Main";
|
||||
}
|
||||
if (findOption(options, MakeProfileOptionLaunchWrapper.class).isPresent()) {
|
||||
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 String jimfsPath;
|
||||
public String guavaPath;
|
||||
|
|
|
@ -121,6 +121,11 @@ private static void realMain(String[] args) throws Throwable {
|
|||
List<Path> classpath = resolveClassPath(clientDir, params.actions, params.profile)
|
||||
.filter(x -> !profile.getModulePath().contains(clientDir.relativize(x).toString()))
|
||||
.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());
|
||||
// Start client with WatchService monitoring
|
||||
RequestService service;
|
||||
|
@ -256,7 +261,12 @@ private static Stream<Path> resolveClassPathStream(Path clientDir, String... cla
|
|||
for (String classPathEntry : classPath) {
|
||||
Path path = clientDir.resolve(IOHelper.toPath(classPathEntry.replace(IOHelper.CROSS_SEPARATOR, IOHelper.PLATFORM_SEPARATOR)));
|
||||
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;
|
||||
}
|
||||
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 final Stream.Builder<Path> result;
|
||||
private final List<Path> result;
|
||||
|
||||
private ClassPathFileVisitor(Stream.Builder<Path> result) {
|
||||
private ClassPathFileVisitor(List<Path> result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
if (IOHelper.hasExtension(file, "jar") || IOHelper.hasExtension(file, "zip"))
|
||||
result.accept(file);
|
||||
result.add(file);
|
||||
return super.visitFile(file, attrs);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue