From b727ae677dd85ea650f90c61b3851106678ee473 Mon Sep 17 00:00:00 2001 From: Puqns67 Date: Sun, 27 Oct 2024 18:45:47 +0800 Subject: [PATCH] fix: crash when joining world Upstream renamed the method "com.mojang.blaze3d.platform.NativeImage$getPixelRGBA" to "getPixelABGR" and made it private. So add the AccessTransformer to make it public and follow upstream rename. --- build.gradle.kts | 4 ++++ src/main/java/icu/puqns67/skintypefix/util/Utils.java | 5 ++--- src/main/resources/fabric.mod.json | 1 + src/main/resources/skintypefix.accesswidener | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/skintypefix.accesswidener diff --git a/build.gradle.kts b/build.gradle.kts index 0c52bd0..850c8a1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,6 +39,10 @@ java { targetCompatibility = JavaVersion.valueOf("VERSION_${javaVersion}") } +loom { + accessWidenerPath = file("src/main/resources/${modId}.accesswidener") +} + modrinth { token = System.getenv("MODRINTH_TOKEN") ?: properties["modrinth_token"]?.toString() projectId = modId diff --git a/src/main/java/icu/puqns67/skintypefix/util/Utils.java b/src/main/java/icu/puqns67/skintypefix/util/Utils.java index e7796c5..91d3167 100644 --- a/src/main/java/icu/puqns67/skintypefix/util/Utils.java +++ b/src/main/java/icu/puqns67/skintypefix/util/Utils.java @@ -28,9 +28,8 @@ public class Utils { var timesForSlim = new HashMap(); PlayerSkin.Model result = null; - // The result of NativeImage.getPixelRGBA() is ARGB, not RGBA, like 0xAARRGGBB - PLAYER_SKIN_DIFF_SLIM_TO_WILD.forEach(p -> timesForDiff.merge(image.getPixelRGBA(p.x(), p.y()), 1, Integer::sum)); - PLAYER_SKIN_SLIM.forEach(p -> timesForSlim.merge(image.getPixelRGBA(p.x(), p.y()), 1, Integer::sum)); + PLAYER_SKIN_DIFF_SLIM_TO_WILD.forEach(p -> timesForDiff.merge(image.getPixelABGR(p.x(), p.y()), 1, Integer::sum)); + PLAYER_SKIN_SLIM.forEach(p -> timesForSlim.merge(image.getPixelABGR(p.x(), p.y()), 1, Integer::sum)); var blackTimesForDiff = timesForDiff.getOrDefault(0xff000000, 0); var blackTimesForSlim = timesForSlim.getOrDefault(0xff000000, 0); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2f26524..6c652fb 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -33,4 +33,5 @@ "suggests": { "another-mod": "*" } + "accessWidener": "${mod_id}.accesswidener", } \ No newline at end of file diff --git a/src/main/resources/skintypefix.accesswidener b/src/main/resources/skintypefix.accesswidener new file mode 100644 index 0000000..0084980 --- /dev/null +++ b/src/main/resources/skintypefix.accesswidener @@ -0,0 +1,2 @@ +accessWidener v2 named +accessible method com/mojang/blaze3d/platform/NativeImage getPixelABGR (II)I