minecraft-src/net/minecraft/client/renderer/entity/VillagerRenderer.java
2025-07-04 01:41:11 +03:00

41 lines
1.7 KiB
Java

package net.minecraft.client.renderer.entity;
import com.mojang.blaze3d.vertex.PoseStack;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.model.VillagerModel;
import net.minecraft.client.model.geom.ModelLayers;
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.resources.ResourceLocation;
import net.minecraft.world.entity.npc.Villager;
@Environment(EnvType.CLIENT)
public class VillagerRenderer extends MobRenderer<Villager, VillagerModel<Villager>> {
private static final ResourceLocation VILLAGER_BASE_SKIN = ResourceLocation.withDefaultNamespace("textures/entity/villager/villager.png");
public VillagerRenderer(EntityRendererProvider.Context context) {
super(context, new VillagerModel<>(context.bakeLayer(ModelLayers.VILLAGER)), 0.5F);
this.addLayer(new CustomHeadLayer<>(this, context.getModelSet(), context.getItemInHandRenderer()));
this.addLayer(new VillagerProfessionLayer<>(this, context.getResourceManager(), "villager"));
this.addLayer(new CrossedArmsItemLayer<>(this, context.getItemInHandRenderer()));
}
/**
* Returns the location of an entity's texture.
*/
public ResourceLocation getTextureLocation(Villager entity) {
return VILLAGER_BASE_SKIN;
}
protected void scale(Villager livingEntity, PoseStack poseStack, float partialTickTime) {
float f = 0.9375F * livingEntity.getAgeScale();
poseStack.scale(f, f, f);
}
protected float getShadowRadius(Villager entity) {
float f = super.getShadowRadius(entity);
return entity.isBaby() ? f * 0.5F : f;
}
}