ArmorStandRenderer .java

net.minecraft.client.renderer.entity.ArmorStandRenderer (class): members: DEFAULT_SKIN_LOCATION, forceTransparent, bigModel, getRenderType, smallModel.

net.minecraft.client.renderer.entityclass102 linesclientextends LivingEntityRenderer<ArmorStand4.6 KB

API Surface (6)

Identifier getTextureLocation(final ArmorStandRenderState state)
ArmorStandRenderState createRenderState()
void extractRenderState(final ArmorStand entity, final ArmorStandRenderState state, final float partialTicks)
void submit(final ArmorStandRenderState state, final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector, final CameraRenderState camera)
void setupRotations(final ArmorStandRenderState state, final PoseStack poseStack, final float bodyRot, final float entityScale)
boolean shouldShowName(final ArmorStand entity, final double distanceToCameraSq)

Fields & Constants (4)

DEFAULT_SKIN_LOCATION
bigModel
smallModel
forceTransparent

String literals (1)

"textures/entity/armorstand/armorstand.png"

Full Source

ArmorStandRenderer.java102 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.entity;
2
3
import com.mojang.blaze3d.vertex.PoseStack;
4
import com.mojang.math.Axis;
5
import net.fabricmc.api.EnvType;
6
import net.fabricmc.api.Environment;
7
import net.minecraft.client.model.geom.ModelLayers;
8
import net.minecraft.client.model.object.armorstand.ArmorStandArmorModel;
9
import net.minecraft.client.model.object.armorstand.ArmorStandModel;
10
import net.minecraft.client.renderer.SubmitNodeCollector;
11
import net.minecraft.client.renderer.entity.layers.CustomHeadLayer;
12
import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
13
import net.minecraft.client.renderer.entity.layers.ItemInHandLayer;
14
import net.minecraft.client.renderer.entity.layers.WingsLayer;
15
import net.minecraft.client.renderer.entity.state.ArmorStandRenderState;
16
import net.minecraft.client.renderer.rendertype.RenderType;
17
import net.minecraft.client.renderer.rendertype.RenderTypes;
18
import net.minecraft.client.renderer.state.level.CameraRenderState;
19
import net.minecraft.resources.Identifier;
20
import net.minecraft.util.Mth;
21
import net.minecraft.world.entity.decoration.ArmorStand;
22
import org.jspecify.annotations.Nullable;
23
24
@Environment(EnvType.CLIENT)
25
public class ArmorStandRenderer extends LivingEntityRenderer<ArmorStand, ArmorStandRenderState, ArmorStandArmorModel> {
26
	public static final Identifier DEFAULT_SKIN_LOCATION = Identifier.withDefaultNamespace("textures/entity/armorstand/armorstand.png");
27
	private final ArmorStandArmorModel bigModel = this.getModel();
28
	private final ArmorStandArmorModel smallModel;
29
30
	public ArmorStandRenderer(final EntityRendererProvider.Context context) {
31
		super(context, new ArmorStandModel(context.bakeLayer(ModelLayers.ARMOR_STAND)), 0.0F);
32
		this.smallModel = new ArmorStandModel(context.bakeLayer(ModelLayers.ARMOR_STAND_SMALL));
33
		this.addLayer(
34
			new HumanoidArmorLayer<>(
35
				this,
36
				ArmorModelSet.bake(ModelLayers.ARMOR_STAND_ARMOR, context.getModelSet(), ArmorStandArmorModel::new),
37
				ArmorModelSet.bake(ModelLayers.ARMOR_STAND_SMALL_ARMOR, context.getModelSet(), ArmorStandArmorModel::new),
38
				context.getEquipmentRenderer()
39
			)
40
		);
41
		this.addLayer(new ItemInHandLayer<>(this));
42
		this.addLayer(new WingsLayer<>(this, context.getModelSet(), context.getEquipmentRenderer()));
43
		this.addLayer(new CustomHeadLayer<>(this, context.getModelSet(), context.getPlayerSkinRenderCache()));
44
	}
45
46
	public Identifier getTextureLocation(final ArmorStandRenderState state) {
47
		return DEFAULT_SKIN_LOCATION;
48
	}
49
50
	public ArmorStandRenderState createRenderState() {
51
		return new ArmorStandRenderState();
52
	}
53
54
	public void extractRenderState(final ArmorStand entity, final ArmorStandRenderState state, final float partialTicks) {
55
		super.extractRenderState(entity, state, partialTicks);
56
		HumanoidMobRenderer.extractHumanoidRenderState(entity, state, partialTicks, this.itemModelResolver);
57
		state.yRot = Mth.rotLerp(partialTicks, entity.yRotO, entity.getYRot());
58
		state.isMarker = entity.isMarker();
59
		state.isSmall = entity.isSmall();
60
		state.showArms = entity.showArms();
61
		state.showBasePlate = entity.showBasePlate();
62
		state.bodyPose = entity.getBodyPose();
63
		state.headPose = entity.getHeadPose();
64
		state.leftArmPose = entity.getLeftArmPose();
65
		state.rightArmPose = entity.getRightArmPose();
66
		state.leftLegPose = entity.getLeftLegPose();
67
		state.rightLegPose = entity.getRightLegPose();
68
		state.wiggle = (float)(entity.level().getGameTime() - entity.lastHit) + partialTicks;
69
	}
70
71
	public void submit(final ArmorStandRenderState state, final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector, final CameraRenderState camera) {
72
		this.model = state.isSmall ? this.smallModel : this.bigModel;
73
		super.submit(state, poseStack, submitNodeCollector, camera);
74
	}
75
76
	protected void setupRotations(final ArmorStandRenderState state, final PoseStack poseStack, final float bodyRot, final float entityScale) {
77
		poseStack.rotateDegrees(Axis.YP, 180.0F - bodyRot);
78
		if (state.wiggle < 5.0F) {
79
			poseStack.rotateDegrees(Axis.YP, Mth.sin(state.wiggle / 1.5F * (float) Math.PI) * 3.0F);
80
		}
81
	}
82
83
	protected boolean shouldShowName(final ArmorStand entity, final double distanceToCameraSq) {
84
		return entity.isCustomNameVisible();
85
	}
86
87
	protected @Nullable RenderType getRenderType(
88
		final ArmorStandRenderState state, final boolean isBodyVisible, final boolean forceTransparent, final boolean appearGlowing
89
	) {
90
		if (!state.isMarker) {
91
			return super.getRenderType(state, isBodyVisible, forceTransparent, appearGlowing);
92
		} else {
93
			Identifier texture = this.getTextureLocation(state);
94
			if (forceTransparent) {
95
				return RenderTypes.entityTranslucent(texture, false);
96
			} else {
97
				return isBodyVisible ? RenderTypes.entityCutout(texture, false) : null;
98
			}
99
		}
100
	}
101
}
102

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