diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/setting/VersionSetting.java b/HMCL/src/main/java/org/jackhuang/hmcl/setting/VersionSetting.java index 39fb1afd48..9624b417fb 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/setting/VersionSetting.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/setting/VersionSetting.java @@ -418,6 +418,20 @@ public void setNotPatchNatives(boolean notPatchNatives) { notPatchNativesProperty.set(notPatchNatives); } + private final BooleanProperty notUseRetroTweakerProperty = new SimpleBooleanProperty(this, "notUseRetroTweaker", false); + + public BooleanProperty notUseRetroTweakerProperty() { + return notUseRetroTweakerProperty; + } + + public boolean isNotUseRetroTweaker() { + return notUseRetroTweakerProperty.get(); + } + + public void setNotUseRetroTweaker(boolean notUseRetroTweaker) { + notUseRetroTweakerProperty.set(notUseRetroTweaker); + } + private final BooleanProperty showLogsProperty = new SimpleBooleanProperty(this, "showLogs", false); public BooleanProperty showLogsProperty() { @@ -750,6 +764,7 @@ public JsonElement serialize(VersionSetting src, Type typeOfSrc, JsonSerializati obj.addProperty("notCheckGame", src.isNotCheckGame()); obj.addProperty("notCheckJVM", src.isNotCheckJVM()); obj.addProperty("notPatchNatives", src.isNotPatchNatives()); + obj.addProperty("notUseRetroTweaker", src.isNotUseRetroTweaker()); obj.addProperty("showLogs", src.isShowLogs()); obj.addProperty("gameDir", src.getGameDir()); obj.addProperty("launcherVisibility", src.getLauncherVisibility().ordinal()); @@ -828,6 +843,7 @@ public VersionSetting deserialize(JsonElement json, Type typeOfT, JsonDeserializ vs.setNotCheckGame(Optional.ofNullable(obj.get("notCheckGame")).map(JsonElement::getAsBoolean).orElse(false)); vs.setNotCheckJVM(Optional.ofNullable(obj.get("notCheckJVM")).map(JsonElement::getAsBoolean).orElse(false)); vs.setNotPatchNatives(Optional.ofNullable(obj.get("notPatchNatives")).map(JsonElement::getAsBoolean).orElse(false)); + vs.setNotUseRetroTweaker(Optional.ofNullable(obj.get("notUseRetroTweaker")).map(JsonElement::getAsBoolean).orElse(false)); vs.setShowLogs(Optional.ofNullable(obj.get("showLogs")).map(JsonElement::getAsBoolean).orElse(false)); vs.setLauncherVisibility(getOrDefault(LauncherVisibility.values(), obj.get("launcherVisibility"), LauncherVisibility.HIDE)); vs.setProcessPriority(getOrDefault(ProcessPriority.values(), obj.get("processPriority"), ProcessPriority.NORMAL)); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/AdvancedVersionSettingPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/AdvancedVersionSettingPage.java index 1acaf3c9b9..231449e83f 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/AdvancedVersionSettingPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/AdvancedVersionSettingPage.java @@ -45,6 +45,7 @@ public final class AdvancedVersionSettingPage extends StackPane implements Decor private final OptionToggleButton noGameCheckPane; private final OptionToggleButton noJVMCheckPane; private final OptionToggleButton noNativesPatchPane; + private final OptionToggleButton noUseRetroTweakerPane; private final OptionToggleButton useNativeGLFWPane; private final OptionToggleButton useNativeOpenALPane; private final ComponentSublist nativesDirSublist; @@ -191,6 +192,9 @@ public AdvancedVersionSettingPage(Profile profile, String versionId, VersionSett noNativesPatchPane = new OptionToggleButton(); noNativesPatchPane.setTitle(i18n("settings.advanced.dont_patch_natives")); + noUseRetroTweakerPane = new OptionToggleButton(); + noUseRetroTweakerPane.setTitle(i18n("settings.advanced.dont_use_retrowrapper")); + useNativeGLFWPane = new OptionToggleButton(); useNativeGLFWPane.setTitle(i18n("settings.advanced.use_native_glfw")); @@ -199,7 +203,7 @@ public AdvancedVersionSettingPage(Profile profile, String versionId, VersionSett workaroundPane.getContent().setAll( nativesDirSublist, rendererPane, noJVMArgsPane, noGameCheckPane, - noJVMCheckPane, noNativesPatchPane + noJVMCheckPane, noNativesPatchPane, noUseRetroTweakerPane ); if (OperatingSystem.CURRENT_OS.isLinuxOrBSD()) { @@ -235,6 +239,7 @@ void bindProperties() { noJVMCheckPane.selectedProperty().bindBidirectional(versionSetting.notCheckJVMProperty()); noJVMArgsPane.selectedProperty().bindBidirectional(versionSetting.noJVMArgsProperty()); noNativesPatchPane.selectedProperty().bindBidirectional(versionSetting.notPatchNativesProperty()); + noUseRetroTweakerPane.selectedProperty().bindBidirectional(versionSetting.notUseRetroTweakerProperty()); useNativeGLFWPane.selectedProperty().bindBidirectional(versionSetting.useNativeGLFWProperty()); useNativeOpenALPane.selectedProperty().bindBidirectional(versionSetting.useNativeOpenALProperty()); @@ -257,6 +262,7 @@ void unbindProperties() { noJVMCheckPane.selectedProperty().unbindBidirectional(versionSetting.notCheckJVMProperty()); noJVMArgsPane.selectedProperty().unbindBidirectional(versionSetting.noJVMArgsProperty()); noNativesPatchPane.selectedProperty().unbindBidirectional(versionSetting.notPatchNativesProperty()); + noUseRetroTweakerPane.selectedProperty().unbindBidirectional(versionSetting.notUseRetroTweakerProperty()); useNativeGLFWPane.selectedProperty().unbindBidirectional(versionSetting.useNativeGLFWProperty()); useNativeOpenALPane.selectedProperty().unbindBidirectional(versionSetting.useNativeOpenALProperty()); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/util/NativePatcher.java b/HMCL/src/main/java/org/jackhuang/hmcl/util/NativePatcher.java index 211b7e274e..6fb61a1261 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/util/NativePatcher.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/util/NativePatcher.java @@ -27,6 +27,8 @@ import org.jackhuang.hmcl.util.platform.OperatingSystem; import org.jackhuang.hmcl.util.platform.Platform; import org.jackhuang.hmcl.util.versioning.GameVersionNumber; +import org.jackhuang.hmcl.game.Library; +import org.jackhuang.hmcl.game.LibraryDownloadInfo; import java.io.IOException; import java.io.InputStreamReader; @@ -67,6 +69,34 @@ public static Version patchNative(DefaultGameRepository repository, JavaRuntime javaVersion, VersionSetting settings, List javaArguments) { + + // Add RetroWrapper for versions below 1.6 + if (!settings.isNotUseRetroTweaker()) { + if (gameVersion != null && GameVersionNumber.compare(gameVersion, "1.6") < 0) { + String minecraftArguments = version.getMinecraftArguments().orElse(null); + if (minecraftArguments != null && !minecraftArguments.contains("--tweakClass")) { + ArrayList libraries = new ArrayList<>(version.getLibraries()); + Library retroWrapper = new Library( + new Artifact("com.zero", "retrowrapper", "1.7.8"), + null, + new LibrariesDownloadInfo( + new LibraryDownloadInfo( + "com/zero/retrowrapper/1.7.8/retrowrapper-1.7.8.jar", + "https://zkitefly.github.io/unlisted-versions-of-minecraft/libraries/retrowrapper-1.7.8.jar", + "ea9175b4aebe091ae8859f7352fe59077a62bdf4", + 181263 + ) + ) + ); + libraries.add(retroWrapper); + version = version.setLibraries(libraries); + + javaArguments.add("-Dretrowrapper.doUpdateCheck=false"); + version = version.setMinecraftArguments(minecraftArguments + " --tweakClass com.zero.retrowrapper.RetroTweaker"); + } + } + } + if (settings.getNativesDirType() == NativesDirectoryType.CUSTOM) { if (gameVersion != null && GameVersionNumber.compare(gameVersion, "1.19") < 0) return version; diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index 1c1d453a01..5f7f259ec7 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -1168,6 +1168,7 @@ settings.advanced.custom_commands.hint=The following environment variables are p settings.advanced.dont_check_game_completeness=Do not check game integrity settings.advanced.dont_check_jvm_validity=Do not check Java VM compatibility settings.advanced.dont_patch_natives=Do not attempt to automatically replace native libraries +settings.advanced.dont_use_retrowrapper=Do not use RetroWrapper for Minecraft 1.5 and earlier (Minecraft 1.6 and later will not use it anyway) settings.advanced.environment_variables=Environment Variables settings.advanced.game_dir.default=Default (".minecraft/") settings.advanced.game_dir.independent=Isolated (".minecraft/versions//", except for assets and libraries) diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index ba2fe55fb8..8c62d1532b 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -969,6 +969,7 @@ settings.advanced.custom_commands.hint=自訂指令被呼叫時將包含如下 settings.advanced.dont_check_game_completeness=不檢查遊戲完整性 settings.advanced.dont_check_jvm_validity=不檢查 JVM 與遊戲的相容性 settings.advanced.dont_patch_natives=不嘗試自動取代本機庫 +settings.advanced.dont_use_retrowrapper=不使用 RetroWrapper 修補程式(該修補程式默認僅會在 Minecraft 1.5 及以下版本使用) settings.advanced.environment_variables=環境變數 settings.advanced.game_dir.default=預設 (".minecraft/") settings.advanced.game_dir.independent=各實例獨立 (".minecraft/versions/<實例名>/",除 assets、libraries 外) diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties index 6b5950291a..f2e1433f42 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -980,6 +980,7 @@ settings.advanced.custom_commands.hint=自定义命令被调用时将包含如 settings.advanced.dont_check_game_completeness=不检查游戏完整性 settings.advanced.dont_check_jvm_validity=不检查 JVM 与游戏的兼容性 settings.advanced.dont_patch_natives=不尝试自动替换本地库 +settings.advanced.dont_use_retrowrapper=不使用 RetroWrapper 补丁(该补丁默认仅会在 Minecraft 1.5 及以下版本使用) settings.advanced.environment_variables=环境变量 settings.advanced.game_dir.default=默认 (".minecraft/") settings.advanced.game_dir.independent=各版本独立 (存放在 ".minecraft/versions/<版本名>/",除 assets、libraries 外)