Fix vanilla skin texture ownership

This commit is contained in:
f1den committed 2026-09-04 14:02:56 +03:00
1 parent 82da98cc35
commit 5f02d9cbc5
2 files changed
+19 -5

No files matched your search

@@ -22,6 +22,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
*/
@Mixin(HttpTexture.class)
public abstract class SkinMagicMixin {
private static final int VANILLA_SKIN_WIDTH = 64;
private static final int MAX_HD_SKIN_WIDTH = 2048;
private static final Logger SKINSG_LOGGER = LoggerFactory.getLogger("skinsg");
@Shadow
@@ -36,6 +38,14 @@ public abstract class SkinMagicMixin {
final int h = image.getHeight();
final int w = image.getWidth();
// Vanilla already owns the complete 64x32/64x64 lifecycle, including replacing and
// closing legacy images. Intercepting those images here needlessly duplicates that
// ownership path and can hand HttpTexture an already released image when another
// texture-loading mixin is present. Only HD skins belong to this mixin.
if (!skinsg$isSupportedHdSkin(w, h)) {
return;
}
final int s = w / 8;
final int x64 = s * 8;
final int x32 = s * 4;
@@ -48,10 +58,6 @@ public abstract class SkinMagicMixin {
final int x52 = x48 + x4;
final int x48m4 = x48 - x4;
if (w != x64 || (h != x32 && h != x64)) {
return;
}
final boolean legacy = h == x32;
if (legacy) {
NativeImage newImg = new NativeImage(x64, x64, true);
@@ -98,6 +104,14 @@ public abstract class SkinMagicMixin {
}
}
private static boolean skinsg$isSupportedHdSkin(int width, int height) {
return width > VANILLA_SKIN_WIDTH
&& width <= MAX_HD_SKIN_WIDTH
&& width % VANILLA_SKIN_WIDTH == 0
&& (width & (width - 1)) == 0
&& (height == width / 2 || height == width);
}
private static NativeImage skinsg$loadSteve() {
try {
var resource = Minecraft.getInstance().getResourceManager()
+1 -1
View File
@@ -6,7 +6,7 @@ org.gradle.parallel=true
# --- Mod ---
mod_id=skinsg
mod_name=HD Skin Support (Gravit)
mod_version=0.1.2
mod_version=0.1.3
mod_group_id=xyz.nightsync.skinsg
mod_license=All Rights Reserved
mod_author=Nghtly