From ab23f3ccec0a241e0e2434e829258f37ebeae99b Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 24 Aug 2019 16:11:45 +0200 Subject: [PATCH] Add a villager clothing layer --- .../render/entities/RenderPonyVillager.java | 21 ++----------- .../entities/RenderPonyZombieVillager.java | 22 ++----------- .../render/layer/LayerVillagerClothing.java | 31 +++++++++++++++++++ 3 files changed, 35 insertions(+), 39 deletions(-) create mode 100644 src/main/java/com/minelittlepony/client/render/layer/LayerVillagerClothing.java 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); + } +}