Merge 65b9c5a8e5ca4b888d99b93d3ce6f21a963c960d into 9969dc60c5278340b6b9a4d7facdde620e99d1f5

This commit is contained in:
Zkitefly 2025-08-02 23:00:10 +08:00 committed by GitHub
commit b98bedd5ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 56 additions and 1 deletions

View File

@ -428,6 +428,20 @@ public final class VersionSetting implements Cloneable, Observable {
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() {
@ -760,6 +774,7 @@ public final class VersionSetting implements Cloneable, Observable {
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());
@ -838,6 +853,7 @@ public final class VersionSetting implements Cloneable, Observable {
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));

View File

@ -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 final class AdvancedVersionSettingPage extends StackPane implements Decor
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 final class AdvancedVersionSettingPage extends StackPane implements Decor
workaroundPane.getContent().setAll(
nativesDirSublist, rendererPane, noJVMArgsPane, noGameCheckPane,
noJVMCheckPane, noNativesPatchPane
noJVMCheckPane, noNativesPatchPane, noUseRetroTweakerPane
);
if (OperatingSystem.CURRENT_OS.isLinuxOrBSD()) {
@ -235,6 +239,7 @@ public final class AdvancedVersionSettingPage extends StackPane implements Decor
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 @@ public final class AdvancedVersionSettingPage extends StackPane implements Decor
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());

View File

@ -27,6 +27,8 @@ import org.jackhuang.hmcl.java.JavaRuntime;
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 final class NativePatcher {
JavaRuntime javaVersion,
VersionSetting settings,
List<String> 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<Library> 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;

View File

@ -1237,6 +1237,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 JVM 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/<instance name>/", except for assets and libraries)

View File

@ -1039,6 +1039,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 外)

View File

@ -1049,6 +1049,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 外)