From 6cce31434122fb8ad6fe1ecd7f30dfa5e28140e5 Mon Sep 17 00:00:00 2001 From: PeTcHeNkA <60981731+PeTcHeNkA@users.noreply.github.com> Date: Wed, 24 Dec 2025 03:28:09 +0300 Subject: [PATCH] fix: add fallback skin for invalid CustomNPC texture paths - Add empty string check in skinType 0 else branch - Set textureLocation to fallBackSkin(npc) for invalid textures - Add null safety check before returning textureLocation - Prevents transparent NPCs when invalid paths like "customnpcs:textures/entity/test.png" or "teststring" are used --- .../npcs/client/renderer/RenderNPCInterface.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index 2d1d1f258..951bfc84c 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -536,7 +536,6 @@ public class RenderNPCInterface extends RenderLiving { @Override public ResourceLocation getEntityTexture(Entity entity) { - EntityNPCInterface npc = (EntityNPCInterface) entity; if (npc.textureLocation == null) { if (npc.display.skinType == 0) { @@ -548,10 +547,15 @@ public class RenderNPCInterface extends RenderLiving { } } } else { - npc.textureLocation = new ResourceLocation(npc.display.texture); + if (!(npc.display.texture).isEmpty()) { + npc.textureLocation = new ResourceLocation(npc.display.texture); + // TODO: Also validate if this ResourceLocation actually exists + } else { + npc.textureLocation = fallBackSkin(npc); + } } } else if (npc.display.skinType == 1 && npc.display.playerProfile != null) { - Minecraft minecraft = Minecraft.getMinecraft(); + final Minecraft minecraft = Minecraft.getMinecraft(); Map map = minecraft.func_152342_ad().func_152788_a(npc.display.playerProfile); if (map.containsKey(Type.SKIN)) { npc.textureLocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture) map.get(Type.SKIN), Type.SKIN); @@ -594,7 +598,8 @@ public class RenderNPCInterface extends RenderLiving { return fallBackSkin(npc); } } - return npc.textureLocation; + + return npc.textureLocation == null ? fallBackSkin(npc) : npc.textureLocation; } private ResourceLocation adjustLocalTexture(EntityNPCInterface npc, ResourceLocation location) throws IOException {