diff --git a/src/main/java/com/minelittlepony/client/render/entities/VillagerProfessionTextureCache.java b/src/main/java/com/minelittlepony/client/render/entities/VillagerProfessionTextureCache.java index b16ad097..fddba3a0 100644 --- a/src/main/java/com/minelittlepony/client/render/entities/VillagerProfessionTextureCache.java +++ b/src/main/java/com/minelittlepony/client/render/entities/VillagerProfessionTextureCache.java @@ -11,9 +11,9 @@ import net.minecraft.village.VillagerType; import com.minelittlepony.MineLittlePony; import com.minelittlepony.util.resources.ITextureSupplier; -import java.io.IOException; import java.util.HashMap; import java.util.Map; +import java.util.Optional; /** * Cached pool of villager textures. @@ -55,33 +55,43 @@ class VillagerProfessionTextureCache { + return verifyTexture(formatter.supplyTexture(k)).orElseGet(() -> { + if (type == VillagerType.PLAINS) { + // if texture loading fails, use the fallback. + return fallback; + } + + return getTexture(VillagerType.PLAINS, profession); + }); + }); + } + + protected Optional verifyTexture(Identifier texture) { + if (!MinecraftClient.getInstance().getResourceManager().containsResource(texture)) { + MineLittlePony.logger.warn("Villager texture `" + texture + "` was not found."); + return Optional.empty(); + } + + return Optional.of(texture); } }