From 507663359986363c38778dc219cad27b56a82ada Mon Sep 17 00:00:00 2001 From: CleverNucleus Date: Tue, 30 Aug 2022 22:53:40 +0100 Subject: [PATCH] Fix and versioning *HOPEFULLY we fixed the compat issue with Geckolib. I only know it exists because may player's have provided error logs that show as much, however I still cannot replicate the crash for testing purposes. So while I THINK this fixes it, I cannot actually verify this. +Incremented version *Now uses VersionDependency instead of ModDependency --- build.gradle | 4 ++-- gradle.properties | 4 ++-- .../impl/ArmorRenderLibImpl.java | 4 ++-- .../impl/ArmorTextureCache.java | 5 +++- .../mixin/ArmorFeatureRendererInvoker.java | 2 -- .../mixin/ArmorFeatureRendererMixin.java | 24 +++++++++++++++++-- src/main/resources/fabric.mod.json | 2 +- 7 files changed, 33 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index 19330d7..b07431d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -import com.modrinth.minotaur.dependencies.ModDependency +import com.modrinth.minotaur.dependencies.VersionDependency plugins { id 'fabric-loom' version '0.12-SNAPSHOT' @@ -69,5 +69,5 @@ modrinth { uploadFile = remapJar gameVersions = ["${project.minecraft_version}"] loaders = ["fabric"] - dependencies = [new ModDependency("P7dR8mSH", "required")] + dependencies = [new VersionDependency("4XRtXhtL", "required")] } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 7dabb7a..85d703c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ minecraft_version=1.18.2 yarn_mappings=1.18.2+build.3 loader_version=0.14.6 -mod_version = 0.1.2 +mod_version = 0.1.3 maven_group = com.github.clevernucleus archives_base_name = armorrenderlib -fabric_version=0.55.1+1.18.2 +fabric_version=0.58.0+1.18.2 diff --git a/src/main/java/com/github/clevernucleus/armorrenderlib/impl/ArmorRenderLibImpl.java b/src/main/java/com/github/clevernucleus/armorrenderlib/impl/ArmorRenderLibImpl.java index 3517fc8..76a9984 100644 --- a/src/main/java/com/github/clevernucleus/armorrenderlib/impl/ArmorRenderLibImpl.java +++ b/src/main/java/com/github/clevernucleus/armorrenderlib/impl/ArmorRenderLibImpl.java @@ -34,7 +34,7 @@ private static , A extends if(item.getSlotType() != slot) return; var entityRenderer = MinecraftClient.getInstance().getEntityRenderDispatcher().getRenderer(entity); ArmorFeatureRenderer armorFeatureRenderer = (ArmorFeatureRenderer)((FeatureRendererAccessor)entityRenderer).getFeatureRenderer(); - A model = ((ArmorFeatureRendererInvoker)armorFeatureRenderer).invokeGetArmor(slot); + A model = ((ArmorTextureCache)armorFeatureRenderer).getArmorCustom(slot); contextModel.setAttributes((BipedEntityModel)model); ((ArmorFeatureRendererInvoker)armorFeatureRenderer).invokeSetVisible(model, slot); @@ -44,7 +44,7 @@ private static , A extends float green = (float)(color >> 8 & 0xFF) / 255.0F; float blue = (float)(color & 0xFF) / 255.0F; - VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumers, RenderLayer.getArmorCutoutNoCull(((ArmorTextureCache)armorFeatureRenderer).getOrCache(path)), false, glint); + VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumers, RenderLayer.getArmorCutoutNoCull(((ArmorTextureCache)armorFeatureRenderer).getOrCache(path)), false, glint); model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, red, green, blue, 1.0F); }); } diff --git a/src/main/java/com/github/clevernucleus/armorrenderlib/impl/ArmorTextureCache.java b/src/main/java/com/github/clevernucleus/armorrenderlib/impl/ArmorTextureCache.java index 492415a..29fb42d 100644 --- a/src/main/java/com/github/clevernucleus/armorrenderlib/impl/ArmorTextureCache.java +++ b/src/main/java/com/github/clevernucleus/armorrenderlib/impl/ArmorTextureCache.java @@ -1,7 +1,10 @@ package com.github.clevernucleus.armorrenderlib.impl; +import net.minecraft.entity.EquipmentSlot; import net.minecraft.util.Identifier; -public interface ArmorTextureCache { +public interface ArmorTextureCache { + A getArmorCustom(EquipmentSlot slot); + Identifier getOrCache(final String path); } diff --git a/src/main/java/com/github/clevernucleus/armorrenderlib/mixin/ArmorFeatureRendererInvoker.java b/src/main/java/com/github/clevernucleus/armorrenderlib/mixin/ArmorFeatureRendererInvoker.java index 541d6e5..ca2a948 100644 --- a/src/main/java/com/github/clevernucleus/armorrenderlib/mixin/ArmorFeatureRendererInvoker.java +++ b/src/main/java/com/github/clevernucleus/armorrenderlib/mixin/ArmorFeatureRendererInvoker.java @@ -10,8 +10,6 @@ @Mixin(ArmorFeatureRenderer.class) public interface ArmorFeatureRendererInvoker, A extends BipedEntityModel> { - @Invoker("getArmor") - public A invokeGetArmor(EquipmentSlot slot); @Invoker("setVisible") public void invokeSetVisible(A bipedModel, EquipmentSlot slot); diff --git a/src/main/java/com/github/clevernucleus/armorrenderlib/mixin/ArmorFeatureRendererMixin.java b/src/main/java/com/github/clevernucleus/armorrenderlib/mixin/ArmorFeatureRendererMixin.java index bf0e49e..f4b1334 100644 --- a/src/main/java/com/github/clevernucleus/armorrenderlib/mixin/ArmorFeatureRendererMixin.java +++ b/src/main/java/com/github/clevernucleus/armorrenderlib/mixin/ArmorFeatureRendererMixin.java @@ -9,15 +9,35 @@ import com.github.clevernucleus.armorrenderlib.impl.ArmorTextureCache; import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer; +import net.minecraft.client.render.entity.model.BipedEntityModel; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; import net.minecraft.util.Identifier; -@Mixin(value = ArmorFeatureRenderer.class, priority = 900) -abstract class ArmorFeatureRendererMixin implements ArmorTextureCache { +@Mixin(ArmorFeatureRenderer.class) +abstract class ArmorFeatureRendererMixin, A extends BipedEntityModel> implements ArmorTextureCache { @Shadow @Final private static Map ARMOR_TEXTURE_CACHE; + @Shadow + @Final + private A leggingsModel; + + @Shadow + @Final + private A bodyModel; + + /* + * We do this instead of just an invoker because Geckolib Injects into #getArmor and runs an instanced set/get exiting the method, + * which causes the game to crash anytime that method is accessed from anywhere else - and we want to be compatible with Geckolib. + */ + @Override + public A getArmorCustom(EquipmentSlot slot) { + return slot == EquipmentSlot.LEGS ? this.leggingsModel : this.bodyModel; + } + @Override public Identifier getOrCache(final String path) { return ARMOR_TEXTURE_CACHE.computeIfAbsent(path, Identifier::new); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index ae5c2a6..393e4ce 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -26,7 +26,7 @@ ], "depends": { "fabricloader": ">=0.14.6", - "fabric": ">=0.55.1", + "fabric": ">=0.58.0", "minecraft": "1.18.2", "java": ">=17" }