diff --git a/src/main/java/com/minelittlepony/client/render/entities/RenderPonyVillager.java b/src/main/java/com/minelittlepony/client/render/entities/RenderPonyVillager.java index ad626d6b..a95619a7 100644 --- a/src/main/java/com/minelittlepony/client/render/entities/RenderPonyVillager.java +++ b/src/main/java/com/minelittlepony/client/render/entities/RenderPonyVillager.java @@ -1,17 +1,14 @@ package com.minelittlepony.client.render.entities; import com.minelittlepony.client.model.entities.ModelVillagerPony; +import com.minelittlepony.client.render.layer.LayerVillagerClothing; import com.minelittlepony.util.resources.FormattedTextureSupplier; import com.minelittlepony.util.resources.ITextureSupplier; import com.mojang.blaze3d.platform.GlStateManager; import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.entity.EntityRenderDispatcher; -import net.minecraft.client.render.entity.feature.VillagerClothingFeatureRenderer; -import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.entity.passive.VillagerEntity; -import net.minecraft.resource.ReloadableResourceManager; import net.minecraft.util.Identifier; public class RenderPonyVillager extends RenderPonyMob.Caster> { @@ -27,21 +24,7 @@ public class RenderPonyVillager extends RenderPonyMob.Caster(this, resManager, "villager")); - } - - @Override - public void bindTexture(Identifier texture) { - - if (texture != SpriteAtlasTexture.BLOCK_ATLAS_TEX) { - if (!"minelittlepony".contentEquals(texture.getNamespace())) { - texture = new Identifier("minelittlepony", texture.getPath()); - } - } - - super.bindTexture(texture); + addFeature(new LayerVillagerClothing<>(this, "villager")); } @Override diff --git a/src/main/java/com/minelittlepony/client/render/entities/RenderPonyZombieVillager.java b/src/main/java/com/minelittlepony/client/render/entities/RenderPonyZombieVillager.java index 42ff1e82..1a3d07d1 100644 --- a/src/main/java/com/minelittlepony/client/render/entities/RenderPonyZombieVillager.java +++ b/src/main/java/com/minelittlepony/client/render/entities/RenderPonyZombieVillager.java @@ -1,16 +1,13 @@ package com.minelittlepony.client.render.entities; import com.minelittlepony.client.model.entities.ModelZombieVillagerPony; +import com.minelittlepony.client.render.layer.LayerVillagerClothing; import com.minelittlepony.util.resources.FormattedTextureSupplier; import com.minelittlepony.util.resources.ITextureSupplier; import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.entity.EntityRenderDispatcher; -import net.minecraft.client.render.entity.feature.VillagerClothingFeatureRenderer; -import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.entity.mob.ZombieVillagerEntity; -import net.minecraft.resource.ReloadableResourceManager; import net.minecraft.util.Identifier; public class RenderPonyZombieVillager extends RenderPonyMob.Caster { @@ -26,24 +23,9 @@ public class RenderPonyZombieVillager extends RenderPonyMob.Caster(this, resManager, "zombie_villager")); + addFeature(new LayerVillagerClothing<>(this, "zombie_villager")); } - @Override - public void bindTexture(Identifier texture) { - - if (texture != SpriteAtlasTexture.BLOCK_ATLAS_TEX) { - if (!"minelittlepony".contentEquals(texture.getNamespace())) { - texture = new Identifier("minelittlepony", texture.getPath()); - } - } - - super.bindTexture(texture); - } - - @Override public Identifier findTexture(ZombieVillagerEntity entity) { return PROFESSIONS.supplyTexture(entity); diff --git a/src/main/java/com/minelittlepony/client/render/layer/LayerVillagerClothing.java b/src/main/java/com/minelittlepony/client/render/layer/LayerVillagerClothing.java new file mode 100644 index 00000000..e082c82f --- /dev/null +++ b/src/main/java/com/minelittlepony/client/render/layer/LayerVillagerClothing.java @@ -0,0 +1,31 @@ +package com.minelittlepony.client.render.layer; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.entity.feature.FeatureRendererContext; +import net.minecraft.client.render.entity.feature.VillagerClothingFeatureRenderer; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.render.entity.model.ModelWithHat; +import net.minecraft.client.texture.SpriteAtlasTexture; +import net.minecraft.entity.LivingEntity; +import net.minecraft.resource.ReloadableResourceManager; +import net.minecraft.util.Identifier; +import net.minecraft.village.VillagerDataContainer; + +public class LayerVillagerClothing & ModelWithHat> extends VillagerClothingFeatureRenderer { + + public LayerVillagerClothing(FeatureRendererContext context, String type) { + super(context, (ReloadableResourceManager)MinecraftClient.getInstance().getResourceManager(), type); + } + + @Override + public void bindTexture(Identifier texture) { + + if (texture != SpriteAtlasTexture.BLOCK_ATLAS_TEX) { + if (!"minelittlepony".contentEquals(texture.getNamespace())) { + texture = new Identifier("minelittlepony", texture.getPath()); + } + } + + super.bindTexture(texture); + } +}