PiglinRenderer .java

net.minecraft.client.renderer.entity.PiglinRenderer (class): members: PIGLIN_CUSTOM_HEAD_TRANSFORMS, PIGLIN_BRUTE_LOCATION, PIGLIN_BABY_LOCATION, babyBody.

net.minecraft.client.renderer.entityclass62 linesclientextends HumanoidMobRenderer<AbstractPiglin2.8 KB

API Surface (4)

Identifier getTextureLocation(final PiglinRenderState state)
PiglinRenderState createRenderState()
void extractRenderState(final AbstractPiglin entity, final PiglinRenderState state, final float partialTicks)
boolean isShaking(final PiglinRenderState state)

Fields & Constants (8)

PIGLIN_LOCATION
PIGLIN_BABY_LOCATION
PIGLIN_BRUTE_LOCATION
PIGLIN_CUSTOM_HEAD_TRANSFORMS
context
body
babyBody
armorSet

String literals (3)

"textures/entity/piglin/piglin.png"
"textures/entity/piglin/piglin_baby.png"
"textures/entity/piglin/piglin_brute.png"

Full Source

PiglinRenderer.java62 lines · Minecraft 26.3 · verbatim
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.AdultPiglinModel;
7
import net.minecraft.client.model.monster.piglin.BabyPiglinModel;
8
import net.minecraft.client.model.monster.piglin.PiglinModel;
9
import net.minecraft.client.renderer.entity.layers.CustomHeadLayer;
10
import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
11
import net.minecraft.client.renderer.entity.state.PiglinRenderState;
12
import net.minecraft.resources.Identifier;
13
import net.minecraft.world.entity.EntityTypes;
14
import net.minecraft.world.entity.monster.piglin.AbstractPiglin;
15
import net.minecraft.world.item.CrossbowItem;
16
17
@Environment(EnvType.CLIENT)
18
public class PiglinRenderer extends HumanoidMobRenderer<AbstractPiglin, PiglinRenderState, PiglinModel> {
19
	private static final Identifier PIGLIN_LOCATION = Identifier.withDefaultNamespace("textures/entity/piglin/piglin.png");
20
	private static final Identifier PIGLIN_BABY_LOCATION = Identifier.withDefaultNamespace("textures/entity/piglin/piglin_baby.png");
21
	private static final Identifier PIGLIN_BRUTE_LOCATION = Identifier.withDefaultNamespace("textures/entity/piglin/piglin_brute.png");
22
	public static final CustomHeadLayer.Transforms PIGLIN_CUSTOM_HEAD_TRANSFORMS = new CustomHeadLayer.Transforms(0.0F, 0.0F, 1.0019531F);
23
24
	public PiglinRenderer(
25
		final EntityRendererProvider.Context context,
26
		final ModelLayerLocation body,
27
		final ModelLayerLocation babyBody,
28
		final ArmorModelSet<ModelLayerLocation> armorSet,
29
		final ArmorModelSet<ModelLayerLocation> babyArmorSet
30
	) {
31
		super(context, new AdultPiglinModel(context.bakeLayer(body)), new BabyPiglinModel(context.bakeLayer(babyBody)), 0.5F, PIGLIN_CUSTOM_HEAD_TRANSFORMS);
32
		this.addLayer(
33
			new HumanoidArmorLayer<>(
34
				this,
35
				ArmorModelSet.bake(armorSet, context.getModelSet(), AdultPiglinModel::new),
36
				ArmorModelSet.bake(babyArmorSet, context.getModelSet(), BabyPiglinModel::new),
37
				context.getEquipmentRenderer()
38
			)
39
		);
40
	}
41
42
	public Identifier getTextureLocation(final PiglinRenderState state) {
43
		return state.isBrute ? PIGLIN_BRUTE_LOCATION : (state.isBaby ? PIGLIN_BABY_LOCATION : PIGLIN_LOCATION);
44
	}
45
46
	public PiglinRenderState createRenderState() {
47
		return new PiglinRenderState();
48
	}
49
50
	public void extractRenderState(final AbstractPiglin entity, final PiglinRenderState state, final float partialTicks) {
51
		super.extractRenderState(entity, state, partialTicks);
52
		state.isBrute = entity.is(EntityTypes.PIGLIN_BRUTE);
53
		state.armPose = entity.getArmPose();
54
		state.maxCrossbowChageDuration = CrossbowItem.getChargeDuration(entity.getUseItem(), entity);
55
		state.isConverting = entity.isConverting();
56
	}
57
58
	protected boolean isShaking(final PiglinRenderState state) {
59
		return super.isShaking(state) || state.isConverting;
60
	}
61
}
62

Decompiled Minecraft 26.3 source of PiglinRenderer (net/minecraft/client/renderer/entity/PiglinRenderer.java) with Mojang official mappings, stored verbatim on the site.