From d8ed4dca91d2bd641771f18e45ab75882df4897b Mon Sep 17 00:00:00 2001 From: tr7zw Date: Tue, 9 Jan 2024 22:57:29 +0100 Subject: [PATCH] Fix 1.16.5 layer issues --- .../skinlayers/config/ConfigScreenProvider.java | 2 ++ .../skinlayers/mixin/PlayerRendererMixin.java | 15 +++++++++++---- .../src/main/resources/fabric.mod.json | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/dev/tr7zw/skinlayers/config/ConfigScreenProvider.java b/src/main/java/dev/tr7zw/skinlayers/config/ConfigScreenProvider.java index e3d8532..40d2465 100644 --- a/src/main/java/dev/tr7zw/skinlayers/config/ConfigScreenProvider.java +++ b/src/main/java/dev/tr7zw/skinlayers/config/ConfigScreenProvider.java @@ -87,6 +87,7 @@ public void initialize() { @Override public void save() { SkinLayersModBase.instance.writeConfig(); + SkinLayersModBase.instance.refreshLayers(this.minecraft.player); } @Override @@ -126,6 +127,7 @@ public void render(GuiGraphics guiGraphics, int xMouse, int yMouse, float f) { public void reset() { ModBase.config = new Config(); SkinLayersModBase.instance.writeConfig(); + SkinLayersModBase.instance.refreshLayers(this.minecraft.player); } }; diff --git a/src/main/java/dev/tr7zw/skinlayers/mixin/PlayerRendererMixin.java b/src/main/java/dev/tr7zw/skinlayers/mixin/PlayerRendererMixin.java index d65387d..017c1c9 100644 --- a/src/main/java/dev/tr7zw/skinlayers/mixin/PlayerRendererMixin.java +++ b/src/main/java/dev/tr7zw/skinlayers/mixin/PlayerRendererMixin.java @@ -51,14 +51,21 @@ public PlayerRendererMixin(Context context, PlayerModel en //#endif // spotless:on - @Inject(method = "*", at = @At("RETURN")) - public void onCreate(CallbackInfo info) { - this.addLayer(new CustomLayerFeatureRenderer(this)); - } + private boolean loaded = false; + +// Somehow doing this in 1.16.5 is a bit unpredictable, only late adding layer works well. Not sure why +// @Inject(method = "*", at = @At("RETURN")) +// public void onCreate(CallbackInfo info) { +// this.addLayer(new CustomLayerFeatureRenderer(this)); +// } @SuppressWarnings("resource") @Inject(method = "setModelProperties", at = @At("RETURN")) public void setModelProperties(AbstractClientPlayer abstractClientPlayer, CallbackInfo info) { + if (!loaded) { + this.addLayer(new CustomLayerFeatureRenderer(this)); + loaded = true; + } if (Minecraft.getInstance().player == null || Minecraft.getInstance().player .distanceToSqr(abstractClientPlayer) > SkinLayersModBase.config.renderDistanceLOD * SkinLayersModBase.config.renderDistanceLOD) { diff --git a/versions/1.16.5-fabric/src/main/resources/fabric.mod.json b/versions/1.16.5-fabric/src/main/resources/fabric.mod.json index 1c0a10a..c2f0101 100644 --- a/versions/1.16.5-fabric/src/main/resources/fabric.mod.json +++ b/versions/1.16.5-fabric/src/main/resources/fabric.mod.json @@ -13,7 +13,7 @@ }, "license": "${license_name}", "icon": "icon.png", - "accessWidener" : "${mod_id}.accesswidener", + "accessWidener": "${mod_id}.accesswidener", "entrypoints": { "client": [ "${fabric_entrypoint}" @@ -31,4 +31,4 @@ "breaks": { "tlskincape": "*" } -} \ No newline at end of file +}