若你不使用搭载苹果芯片(macOS,ARM架构)的设备开发Forge模组,则不需要阅读本文。 背景:当你使用基于ARM Native的JDK运行MC时,会出现以下报错: - [LWJGL] Platform/architecture mismatch detected for module: org.lwjgl
- JVM platform:
- macOS aarch64 17.0.1
- OpenJDK 64-Bit Server VM v17.0.1+12-39 by Oracle Corporation
- Platform available on classpath:
- macos/x64
- ---
- Exception in thread "Render thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
- ---
- Caused by: java.lang.reflect.InvocationTargetException
- ---
- Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.mojang.blaze3d.systems.RenderSystem
复制代码 修复方法:①在下列两条代码中任选其一复制到工作区build.gradle的最后一行: - apply from: "https://moddingtutorials.org/applesilicon.gradle"
复制代码- apply from: "https://gitee.com/nova-committee/AppleSiliconGradleFix/blob/main/applesilicon.gradle"
复制代码②确保build.gradle同目录下有gradle.properties文件,且定义mc_version=你正在开发的mc版本;
以开发Forge1.18.2为例: ③重新运行runClient。第一次运行会出现同样的报错,这很正常,运行第二次时应该就能顺利启动了。 如果你在开发1.16.5/1.17.1,还需要额外执行以下步骤: Forge1.16.5:使用不低于36.2.30版本的MDK Forge1.17.1:你需要额外添加一个客户端侧mixin - @Mixin(Window.class)
- public class M1Fix {
- @Inject(at = @At("HEAD"), method = "setIcon", cancellable = true)
- private void glfwSetWindowIcon(InputStream intbuffer1, InputStream intbuffer2, CallbackInfo ci) {
- if (isAppleSlilicon()) ci.cancel();
- }
- @Inject(at = @At("HEAD"), method = "checkGlfwError", cancellable = true)
- private static void checkGlfwError(BiConsumer<Integer, String> j, CallbackInfo ci) {
- if (isAppleSlilicon()) ci.cancel();
- }
- private static boolean isAppleSlilicon() {
- return System.getProperty("os.arch").equals("aarch64") && System.getProperty("os.name").equals("Mac OS X");
- }
- }
复制代码
|