2025-11-24 22:52:51 +03:00

58 lines
2.7 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package net.minecraft.client.renderer.entity;
import net.minecraft.client.model.VillagerModel;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.renderer.entity.AgeableMobRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.layers.CrossedArmsItemLayer;
import net.minecraft.client.renderer.entity.layers.CustomHeadLayer;
import net.minecraft.client.renderer.entity.layers.VillagerProfessionLayer;
import net.minecraft.client.renderer.entity.state.HoldingEntityRenderState;
import net.minecraft.client.renderer.entity.state.VillagerRenderState;
import net.minecraft.resources.Identifier;
import net.minecraft.world.entity.npc.Villager;
public class VillagerRenderer
extends AgeableMobRenderer<Villager, VillagerRenderState, VillagerModel> {
private static final Identifier VILLAGER_BASE_SKIN = Identifier.withDefaultNamespace("textures/entity/villager/villager.png");
public static final CustomHeadLayer.Transforms CUSTOM_HEAD_TRANSFORMS = new CustomHeadLayer.Transforms(-0.1171875f, -0.07421875f, 1.0f);
public VillagerRenderer(EntityRendererProvider.Context context) {
super(context, new VillagerModel(context.bakeLayer(ModelLayers.VILLAGER)), new VillagerModel(context.bakeLayer(ModelLayers.VILLAGER_BABY)), 0.5f);
this.addLayer(new CustomHeadLayer<VillagerRenderState, VillagerModel>(this, context.getModelSet(), context.getPlayerSkinRenderCache(), CUSTOM_HEAD_TRANSFORMS));
this.addLayer(new VillagerProfessionLayer<VillagerRenderState, VillagerModel>(this, context.getResourceManager(), "villager", new VillagerModel(context.bakeLayer(ModelLayers.VILLAGER_NO_HAT)), new VillagerModel(context.bakeLayer(ModelLayers.VILLAGER_BABY_NO_HAT))));
this.addLayer(new CrossedArmsItemLayer<VillagerRenderState, VillagerModel>(this));
}
@Override
public Identifier getTextureLocation(VillagerRenderState state) {
return VILLAGER_BASE_SKIN;
}
@Override
protected float getShadowRadius(VillagerRenderState state) {
float radius = super.getShadowRadius(state);
if (state.isBaby) {
return radius * 0.5f;
}
return radius;
}
@Override
public VillagerRenderState createRenderState() {
return new VillagerRenderState();
}
@Override
public void extractRenderState(Villager entity, VillagerRenderState state, float partialTicks) {
super.extractRenderState(entity, state, partialTicks);
HoldingEntityRenderState.extractHoldingEntityRenderState(entity, state, this.itemModelResolver);
state.isUnhappy = entity.getUnhappyCounter() > 0;
state.villagerData = entity.getVillagerData();
}
}