From aef8d4f2b840172d3a453dc82e4043961854af63 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 11 Dec 2022 01:08:31 +0000 Subject: [PATCH] Fixed missing crown texture on piglins --- .../client/render/entity/PonyRenderer.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/minelittlepony/client/render/entity/PonyRenderer.java b/src/main/java/com/minelittlepony/client/render/entity/PonyRenderer.java index ddeae170..38bcd351 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/PonyRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/entity/PonyRenderer.java @@ -16,6 +16,9 @@ import com.minelittlepony.client.render.entity.feature.SkullFeature; import com.minelittlepony.client.render.entity.feature.ElytraFeature; import com.minelittlepony.mson.api.ModelKey; +import java.util.*; + +import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.Frustum; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRendererFactory; @@ -27,12 +30,11 @@ import net.minecraft.entity.mob.MobEntity; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import java.util.List; -import java.util.Locale; - public abstract class PonyRenderer & IPonyModel> extends MobEntityRenderer implements IPonyRenderContext { - protected EquineRenderManager manager = new EquineRenderManager<>(this); + protected final EquineRenderManager manager = new EquineRenderManager<>(this); + + private final Map wearableTextures = new EnumMap<>(Wearable.class); public PonyRenderer(EntityRendererFactory.Context context, ModelKey key) { super(context, null, 0.5F); @@ -111,8 +113,15 @@ public abstract class PonyRenderer @Override public Identifier getDefaultTexture(T entity, Wearable wearable) { - Identifier texture = getTexture(entity); - return new Identifier(texture.getNamespace(), texture.getPath().split("\\.")[0] + "_" + wearable.name().toLowerCase(Locale.ROOT) + ".png"); + return wearableTextures.computeIfAbsent(wearable, w -> { + Identifier texture = getTexture(entity); + texture = new Identifier(texture.getNamespace(), texture.getPath().split("\\.")[0] + "_" + wearable.name().toLowerCase(Locale.ROOT) + ".png"); + + if (MinecraftClient.getInstance().getResourceManager().getResource(texture).isPresent()) { + return texture; + } + return wearable.getDefaultTexture(); + }); } @Override