| 1 | package net.minecraft.client.renderer.entity;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.model.geom.ModelLayerLocation;
|
| 6 | import net.minecraft.client.model.monster.piglin.AdultZombifiedPiglinModel;
|
| 7 | import net.minecraft.client.model.monster.piglin.BabyZombifiedPiglinModel;
|
| 8 | import net.minecraft.client.model.monster.piglin.ZombifiedPiglinModel;
|
| 9 | import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
|
| 10 | import net.minecraft.client.renderer.entity.state.ZombifiedPiglinRenderState;
|
| 11 | import net.minecraft.resources.Identifier;
|
| 12 | import net.minecraft.world.entity.monster.zombie.ZombifiedPiglin;
|
| 13 |
|
| 14 | @Environment(EnvType.CLIENT)
|
| 15 | public class ZombifiedPiglinRenderer extends HumanoidMobRenderer<ZombifiedPiglin, ZombifiedPiglinRenderState, ZombifiedPiglinModel> {
|
| 16 | private static final Identifier ZOMBIFIED_PIGLIN_LOCATION = Identifier.withDefaultNamespace("textures/entity/piglin/zombified_piglin.png");
|
| 17 | private static final Identifier BABY_ZOMBIFIED_PIGLIN_LOCATION = Identifier.withDefaultNamespace("textures/entity/piglin/zombified_piglin_baby.png");
|
| 18 |
|
| 19 | public ZombifiedPiglinRenderer(
|
| 20 | final EntityRendererProvider.Context context,
|
| 21 | final ModelLayerLocation body,
|
| 22 | final ModelLayerLocation babyBody,
|
| 23 | final ArmorModelSet<ModelLayerLocation> armorSet,
|
| 24 | final ArmorModelSet<ModelLayerLocation> babyArmorSet
|
| 25 | ) {
|
| 26 | super(
|
| 27 | context,
|
| 28 | new AdultZombifiedPiglinModel(context.bakeLayer(body)),
|
| 29 | new BabyZombifiedPiglinModel(context.bakeLayer(babyBody)),
|
| 30 | 0.5F,
|
| 31 | PiglinRenderer.PIGLIN_CUSTOM_HEAD_TRANSFORMS
|
| 32 | );
|
| 33 | this.addLayer(
|
| 34 | new HumanoidArmorLayer<>(
|
| 35 | this,
|
| 36 | ArmorModelSet.bake(armorSet, context.getModelSet(), AdultZombifiedPiglinModel::new),
|
| 37 | ArmorModelSet.bake(babyArmorSet, context.getModelSet(), BabyZombifiedPiglinModel::new),
|
| 38 | context.getEquipmentRenderer()
|
| 39 | )
|
| 40 | );
|
| 41 | }
|
| 42 |
|
| 43 | public Identifier getTextureLocation(final ZombifiedPiglinRenderState state) {
|
| 44 | return state.isBaby ? BABY_ZOMBIFIED_PIGLIN_LOCATION : ZOMBIFIED_PIGLIN_LOCATION;
|
| 45 | }
|
| 46 |
|
| 47 | public ZombifiedPiglinRenderState createRenderState() {
|
| 48 | return new ZombifiedPiglinRenderState();
|
| 49 | }
|
| 50 |
|
| 51 | public void extractRenderState(final ZombifiedPiglin entity, final ZombifiedPiglinRenderState state, final float partialTicks) {
|
| 52 | super.extractRenderState(entity, state, partialTicks);
|
| 53 | state.isAggressive = entity.isAggressive();
|
| 54 | }
|
| 55 | }
|
| 56 |
|