Skip to content

Commit

Permalink
Fix 1.16.5 layer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Jan 9, 2024
1 parent 744f7d4 commit d8ed4dc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void initialize() {
@Override
public void save() {
SkinLayersModBase.instance.writeConfig();
SkinLayersModBase.instance.refreshLayers(this.minecraft.player);
}

@Override
Expand Down Expand Up @@ -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);
}

};
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/dev/tr7zw/skinlayers/mixin/PlayerRendererMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,21 @@ public PlayerRendererMixin(Context context, PlayerModel<AbstractClientPlayer> en
//#endif
// spotless:on

@Inject(method = "<init>*", 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 = "<init>*", 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) {
Expand Down
4 changes: 2 additions & 2 deletions versions/1.16.5-fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"license": "${license_name}",
"icon": "icon.png",
"accessWidener" : "${mod_id}.accesswidener",
"accessWidener": "${mod_id}.accesswidener",
"entrypoints": {
"client": [
"${fabric_entrypoint}"
Expand All @@ -31,4 +31,4 @@
"breaks": {
"tlskincape": "*"
}
}
}

0 comments on commit d8ed4dc

Please sign in to comment.