Skip to content
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
39 changes: 36 additions & 3 deletions HMCL/src/main/java/org/jackhuang/hmcl/util/NativePatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ public static Version patchNative(DefaultGameRepository repository,

if (arch == Architecture.ARM64 && (os == OperatingSystem.MACOS || os == OperatingSystem.WINDOWS)
&& gameVersionNumber != null
&& gameVersionNumber.compareTo("1.19") >= 0)
&& gameVersionNumber.compareTo("1.19") >= 0
&& !hasLegacyLwjglNatives(version))
return version;

Map<String, Library> replacements = getNatives(javaVersion.getPlatform());
Expand All @@ -148,12 +149,23 @@ public static Version patchNative(DefaultGameRepository repository,
continue;

if (library.isNative()) {
Library replacement = replacements.getOrDefault(library.getName() + ":natives", NONEXISTENT_LIBRARY);
String nativeKey = library.getName() + ":natives";
String matchedKey = nativeKey;
Library replacement = replacements.getOrDefault(nativeKey, NONEXISTENT_LIBRARY);
if (replacement == NONEXISTENT_LIBRARY) {
String classifier = library.getClassifier();
if (classifier != null) {
String classifierKey = library.getName() + ":" + classifier;
replacement = replacements.getOrDefault(classifierKey, NONEXISTENT_LIBRARY);
matchedKey = classifierKey;
}
}
Comment thread
yaalyy marked this conversation as resolved.

if (replacement == NONEXISTENT_LIBRARY) {
LOG.warning("No alternative native library " + library.getName() + ":natives provided for platform " + javaVersion.getPlatform());
newLibraries.add(library);
} else if (replacement != null) {
LOG.info("Replace " + library.getName() + ":natives with " + replacement.getName());
LOG.info("Replace " + matchedKey + " with " + replacement.getName());
newLibraries.add(replacement);
}
} else {
Expand Down Expand Up @@ -280,6 +292,27 @@ public static SupportStatus checkSupportedStatus(GameVersionNumber gameVersion,
return SupportStatus.UNTESTED;
}

private static boolean hasLegacyLwjglNatives(Version version) {
for (Library lib : version.getLibraries()) {
if (!lib.appliesToCurrentEnvironment()) continue;
if (!"org.lwjgl".equals(lib.getGroupId())) continue;
if (!lib.isNative()) continue;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Treat classifier-only LWJGL entries as legacy natives

hasLegacyLwjglNatives filters with lib.isNative(), but Library.isNative() only returns true when natives or downloads.classifiers is present; a MultiMC/Forge-style library declared as "name": "org.lwjgl:...:natives-macos" (classifier in coordinate only) is treated as non-native and skipped here. In that case this method returns false, the early return at patchNative stays active for macOS/Windows ARM64 1.19+, and the legacy natives-macos mapping you added is never applied.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

通过multiMC程序打包的整合包, 在经过HMCL导入后,目前可见的legacy classifier仅遇到过downloads.classifiers的形式,未遇见过"name": "org.lwjgl:...:natives-macos"的形式,因此该特例认为可以暂时忽略

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

示例json:
{ "name": "org.lwjgl:lwjgl-glfw:3.3.1", "downloads": { "artifact": { "url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1.jar", "sha1": "cbac1b8d30cb4795149c1ef540f912671a8616d0", "size": 128801 }, "classifiers": { "natives-linux": { "url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1-natives-linux.jar", "sha1": "81716978214ecbda15050ca394b06ef61501a49e", "size": 119817 }, "natives-macos": { "url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1-natives-macos.jar", "sha1": "9ec4ce1fc8c85fdef03ef4ff2aace6f5775fb280", "size": 131655 }, "natives-windows": { "url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1-natives-windows.jar", "sha1": "ed892f945cf7e79c8756796f32d00fa4ceaf573b", "size": 145512 } } }, "natives": { "linux": "natives-linux", "osx": "natives-macos", "windows": "natives-windows" } },


String classifier = lib.getClassifier();
if (classifier == null) {
return true;
}

String c = classifier.toLowerCase(Locale.ROOT);
boolean arm64Like = c.contains("arm64") || c.contains("aarch64");
if (!arm64Like) {
// e.g. natives-macos / natives-windows
return true;
}
}
return false;
}

public enum SupportStatus {
OFFICIAL_SUPPORTED,
LAUNCHER_SUPPORTED,
Expand Down
77 changes: 77 additions & 0 deletions HMCL/src/main/resources/assets/natives.json
Original file line number Diff line number Diff line change
Expand Up @@ -5199,6 +5199,83 @@
}
}
},
"org.lwjgl:lwjgl:3.3.1:natives-macos": {
"name": "org.lwjgl:lwjgl:3.3.1:natives-macos-arm64",
"downloads": {
"artifact": {
"path": "org/lwjgl/lwjgl/3.3.1/lwjgl-3.3.1-natives-macos-arm64.jar",
"url": "https://libraries.minecraft.net/org/lwjgl/lwjgl/3.3.1/lwjgl-3.3.1-natives-macos-arm64.jar",
"sha1": "71d0d5e469c9c95351eb949064497e3391616ac9",
"size": 42693
}
}
},
"org.lwjgl:lwjgl-jemalloc:3.3.1:natives-macos": {
"name": "org.lwjgl:lwjgl-jemalloc:3.3.1:natives-macos-arm64",
"downloads": {
"artifact": {
"path": "org/lwjgl/lwjgl-jemalloc/3.3.1/lwjgl-jemalloc-3.3.1-natives-macos-arm64.jar",
"url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-jemalloc/3.3.1/lwjgl-jemalloc-3.3.1-natives-macos-arm64.jar",
"sha1": "e577b87d8ad2ade361aaea2fcf226c660b15dee8",
"size": 103475
}
}
},
"org.lwjgl:lwjgl-openal:3.3.1:natives-macos": {
"name": "org.lwjgl:lwjgl-openal:3.3.1:natives-macos-arm64",
"downloads": {
"artifact": {
"path": "org/lwjgl/lwjgl-openal/3.3.1/lwjgl-openal-3.3.1-natives-macos-arm64.jar",
"url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-openal/3.3.1/lwjgl-openal-3.3.1-natives-macos-arm64.jar",
"sha1": "23d55e7490b57495320f6c9e1936d78fd72c4ef8",
"size": 346125
}
}
},
"org.lwjgl:lwjgl-opengl:3.3.1:natives-macos": {
"name": "org.lwjgl:lwjgl-opengl:3.3.1:natives-macos-arm64",
"downloads": {
"artifact": {
"path": "org/lwjgl/lwjgl-opengl/3.3.1/lwjgl-opengl-3.3.1-natives-macos-arm64.jar",
"url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-opengl/3.3.1/lwjgl-opengl-3.3.1-natives-macos-arm64.jar",
"sha1": "eafe34b871d966292e8db0f1f3d6b8b110d4e91d",
"size": 41665
}
}
},
"org.lwjgl:lwjgl-glfw:3.3.1:natives-macos": {
"name": "org.lwjgl:lwjgl-glfw:3.3.1:natives-macos-arm64",
"downloads": {
"artifact": {
"path": "org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1-natives-macos-arm64.jar",
"url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1-natives-macos-arm64.jar",
"sha1": "cac0d3f712a3da7641fa174735a5f315de7ffe0a",
"size": 129077
}
}
},
"org.lwjgl:lwjgl-stb:3.3.1:natives-macos": {
"name": "org.lwjgl:lwjgl-stb:3.3.1:natives-macos-arm64",
"downloads": {
"artifact": {
"path": "org/lwjgl/lwjgl-stb/3.3.1/lwjgl-stb-3.3.1-natives-macos-arm64.jar",
"url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-stb/3.3.1/lwjgl-stb-3.3.1-natives-macos-arm64.jar",
"sha1": "fcf073ed911752abdca5f0b00a53cfdf17ff8e8b",
"size": 178408
}
}
},
"org.lwjgl:lwjgl-tinyfd:3.3.1:natives-macos": {
"name": "org.lwjgl:lwjgl-tinyfd:3.3.1:natives-macos-arm64",
"downloads": {
"artifact": {
"path": "org/lwjgl/lwjgl-tinyfd/3.3.1/lwjgl-tinyfd-3.3.1-natives-macos-arm64.jar",
"url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-tinyfd/3.3.1/lwjgl-tinyfd-3.3.1-natives-macos-arm64.jar",
"sha1": "972ecc17bad3571e81162153077b4d47b7b9eaa9",
"size": 41380
}
}
},
"ca.weblite:java-objc-bridge:1.0.0": {
"name": "org.glavo.hmcl.mmachina:java-objc-bridge:1.1.0-mmachina.1",
"downloads": {
Expand Down