Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

使用 retrowrapper 为旧版本做兼容 #3796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zkitefly wants to merge 11 commits into HMCL-dev:main
base: main
Choose a base branch
Loading
from zkitefly:microsoft-account-skin-uplode
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/setting/VersionSetting.java
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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));
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));

Expand All @@ -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()) {
Expand Down Expand Up @@ -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());

Expand All @@ -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());

Expand Down
30 changes: 30 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/util/NativePatcher.java
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,6 +69,34 @@ public static Version patchNative(DefaultGameRepository repository,
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;
Expand Down
1 change: 1 addition & 0 deletions HMCL/src/main/resources/assets/lang/I18N.properties
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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/<instance name>/", except for assets and libraries)
Expand Down
1 change: 1 addition & 0 deletions HMCL/src/main/resources/assets/lang/I18N_zh.properties
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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 及以下版本使用)
Copy link
Contributor

@3gf8jv4dv 3gf8jv4dv Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
settings.advanced.dont_use_retrowrapper=不使用 RetroWrapper 修補程式(該修補程式默認僅會在 Minecraft 1.5 及以下版本使用)
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 外)
Expand Down
1 change: 1 addition & 0 deletions HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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 外)
Expand Down

AltStyle によって変換されたページ (->オリジナル) /