From 3431fae1092ce149fc78c2ee2da7aefb61558de4 Mon Sep 17 00:00:00 2001 From: Gravita Date: Fri, 11 Jun 2021 10:14:22 +0700 Subject: [PATCH] [FEATURE] 1.17 support --- .../command/hash/SaveProfilesCommand.java | 45 ++++++++++++++++++- .../launcher/profiles/ClientProfile.java | 3 +- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/SaveProfilesCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/SaveProfilesCommand.java index c10f4ef4..40f75987 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/SaveProfilesCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/SaveProfilesCommand.java @@ -58,11 +58,46 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti } OptionalFile optionalMacOs = new OptionalFile(); optionalMacOs.name = "MacOSArgs"; + optionalMacOs.visible = false; optionalMacOs.actions = new ArrayList<>(1); optionalMacOs.actions.add(new OptionalActionJvmArgs(List.of("-XstartOnFirstThread"))); optionalMacOs.triggers = new OptionalTrigger[]{new OptionalTrigger(OptionalTrigger.TriggerType.OS_TYPE, 2)}; optionals.add(optionalMacOs); } + if (optionContains(options, MakeProfileOption.LWJGLMAC)) { + OptionalFile optionalMac = new OptionalFile(); + optionalMac.name = "MacLwjgl"; + optionalMac.visible = false; + optionalMac.actions.add(new OptionalActionFile(Map.of( + "libraries/libraries/org/lwjgl/lwjgl/3.2.1", "", + "libraries/libraries/org/lwjgl/lwjgl-glfw/3.2.1", "", + "libraries/libraries/org/lwjgl/lwjgl-openal/3.2.1", "", + "libraries/libraries/org/lwjgl/lwjgl-stb/3.2.1", "", + "libraries/libraries/org/lwjgl/lwjgl-tinyfd/3.2.1", "", + "libraries/libraries/org/lwjgl/lwjgl-opengl/3.2.1", "", + "libraries/libraries/org/lwjgl/lwjgl-jemalloc/3.2.1", "" + ))); + optionalMac.triggers = new OptionalTrigger[]{new OptionalTrigger(OptionalTrigger.TriggerType.OS_TYPE, true, 2, 0)}; + optionals.add(optionalMac); + OptionalFile optionalOther = new OptionalFile(); + optionalOther.name = "NonMacLwjgl"; + optionalOther.visible = false; + optionalOther.actions.add(new OptionalActionFile(Map.of( + "libraries/libraries/org/lwjgl/lwjgl/3.2.2", "", + "libraries/libraries/org/lwjgl/lwjgl-glfw/3.2.2", "", + "libraries/libraries/org/lwjgl/lwjgl-openal/3.2.2", "", + "libraries/libraries/org/lwjgl/lwjgl-stb/3.2.2", "", + "libraries/libraries/org/lwjgl/lwjgl-tinyfd/3.2.2", "", + "libraries/libraries/org/lwjgl/lwjgl-opengl/3.2.2", "", + "libraries/libraries/org/lwjgl/lwjgl-jemalloc/3.2.2", "" + ))); + optionalOther.triggers = new OptionalTrigger[]{new OptionalTrigger(OptionalTrigger.TriggerType.OS_TYPE, true, 2, 0)}; + optionals.add(optionalOther); + } + if (version.compareTo(ClientProfile.Version.MC117) >= 0) { + builder.setMinJavaVersion(16); + builder.setRecommendJavaVersion(16); + } jvmArgs.add("-Dfml.ignorePatchDiscrepancies=true"); jvmArgs.add("-Dfml.ignoreInvalidMinecraftCertificates=true"); builder.setJvmArgs(jvmArgs); @@ -80,6 +115,11 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti } else { clientArgs.add("cpw.mods.fml.common.launcher.FMLTweaker"); } + if (version.compareTo(ClientProfile.Version.MC1122) <= 0) { + builder.setMinJavaVersion(8); + builder.setRecommendJavaVersion(8); + builder.setMaxJavaVersion(8); + } } } builder.setClientArgs(clientArgs); @@ -106,6 +146,9 @@ public static MakeProfileOption[] getMakeProfileOptionsFromDir(Path dir, ClientP if (Files.exists(dir.resolve("liteloader.jar"))) { options.add(MakeProfileOption.LITELOADER); } + if (Files.exists(dir.resolve("libraries/libraries/org/lwjgl/lwjgl/3.2.2")) && Files.exists(dir.resolve("libraries/libraries/org/lwjgl/lwjgl/3.2.1"))) { + options.add(MakeProfileOption.LWJGLMAC); + } if (version.compareTo(ClientProfile.Version.MC1122) <= 0) { options.add(MakeProfileOption.LAUNCHWRAPPER); } @@ -187,6 +230,6 @@ public void invoke(String... args) throws Exception { } public enum MakeProfileOption { - LAUNCHWRAPPER, VANILLA, FORGE, FABRIC, LITELOADER + LAUNCHWRAPPER, VANILLA, FORGE, FABRIC, LITELOADER, LWJGLMAC } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java index 04c9a7b0..8f107c9a 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -488,7 +488,8 @@ public enum Version { MC1162("1.16.2", 751), MC1163("1.16.3", 753), MC1164("1.16.4", 754), - MC1165("1.16.5", 754); + MC1165("1.16.5", 754), + MC117("1.17", 755); private static final Map VERSIONS; static {