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

55 lines
2.8 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package net.minecraft.client.renderer.entity;
import net.minecraft.client.model.PiglinModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.renderer.entity.ArmorModelSet;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.HumanoidMobRenderer;
import net.minecraft.client.renderer.entity.layers.CustomHeadLayer;
import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
import net.minecraft.client.renderer.entity.state.PiglinRenderState;
import net.minecraft.resources.Identifier;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.monster.piglin.AbstractPiglin;
import net.minecraft.world.item.CrossbowItem;
public class PiglinRenderer
extends HumanoidMobRenderer<AbstractPiglin, PiglinRenderState, PiglinModel> {
private static final Identifier PIGLIN_LOCATION = Identifier.withDefaultNamespace("textures/entity/piglin/piglin.png");
private static final Identifier PIGLIN_BRUTE_LOCATION = Identifier.withDefaultNamespace("textures/entity/piglin/piglin_brute.png");
public static final CustomHeadLayer.Transforms PIGLIN_CUSTOM_HEAD_TRANSFORMS = new CustomHeadLayer.Transforms(0.0f, 0.0f, 1.0019531f);
public PiglinRenderer(EntityRendererProvider.Context context, ModelLayerLocation body, ModelLayerLocation babyBody, ArmorModelSet<ModelLayerLocation> armorSet, ArmorModelSet<ModelLayerLocation> babyArmorSet) {
super(context, new PiglinModel(context.bakeLayer(body)), new PiglinModel(context.bakeLayer(babyBody)), 0.5f, PIGLIN_CUSTOM_HEAD_TRANSFORMS);
this.addLayer(new HumanoidArmorLayer<PiglinRenderState, PiglinModel, PiglinModel>(this, ArmorModelSet.bake(armorSet, context.getModelSet(), PiglinModel::new), ArmorModelSet.bake(babyArmorSet, context.getModelSet(), PiglinModel::new), context.getEquipmentRenderer()));
}
@Override
public Identifier getTextureLocation(PiglinRenderState state) {
return state.isBrute ? PIGLIN_BRUTE_LOCATION : PIGLIN_LOCATION;
}
@Override
public PiglinRenderState createRenderState() {
return new PiglinRenderState();
}
@Override
public void extractRenderState(AbstractPiglin entity, PiglinRenderState state, float partialTicks) {
super.extractRenderState(entity, state, partialTicks);
state.isBrute = entity.getType() == EntityType.PIGLIN_BRUTE;
state.armPose = entity.getArmPose();
state.maxCrossbowChageDuration = CrossbowItem.getChargeDuration(entity.getUseItem(), entity);
state.isConverting = entity.isConverting();
}
@Override
protected boolean isShaking(PiglinRenderState state) {
return super.isShaking(state) || state.isConverting;
}
}