Add a villager clothing layer

This commit is contained in:
Sollace 2019-08-24 16:11:45 +02:00
parent 8c9ff0c553
commit ab23f3ccec
3 changed files with 35 additions and 39 deletions

View file

@ -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<VillagerEntity, ModelVillagerPony<VillagerEntity>> {
@ -27,21 +24,7 @@ public class RenderPonyVillager extends RenderPonyMob.Caster<VillagerEntity, Mod
@Override
protected void addLayers() {
super.addLayers();
ReloadableResourceManager resManager = (ReloadableResourceManager)MinecraftClient.getInstance().getResourceManager();
addFeature(new VillagerClothingFeatureRenderer<>(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

View file

@ -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<ZombieVillagerEntity, ModelZombieVillagerPony> {
@ -26,24 +23,9 @@ public class RenderPonyZombieVillager extends RenderPonyMob.Caster<ZombieVillage
@Override
protected void addLayers() {
super.addLayers();
ReloadableResourceManager resManager = (ReloadableResourceManager)MinecraftClient.getInstance().getResourceManager();
addFeature(new VillagerClothingFeatureRenderer<>(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);

View file

@ -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<T extends LivingEntity & VillagerDataContainer, M extends EntityModel<T> & ModelWithHat> extends VillagerClothingFeatureRenderer<T, M> {
public LayerVillagerClothing(FeatureRendererContext<T, M> 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);
}
}