ParrotOnShoulderLayer .java

net.minecraft.client.renderer.entity.layers.ParrotOnShoulderLayer (class): members: parrotVariant, playerState, xRot, model, lightCoords, yRot, poseStack.

net.minecraft.client.renderer.entity.layersclass71 linesclientextends RenderLayer<AvatarRenderState2.8 KB

API Surface (1)

void submit(final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector, final int lightCoords, final AvatarRenderState state, final float yRot, final float xRot)

Fields & Constants (9)

model
poseStack
submitNodeCollector
lightCoords
state
yRot
playerState
parrotVariant
xRot

Full Source

ParrotOnShoulderLayer.java71 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.entity.layers;
2
3
import com.mojang.blaze3d.vertex.PoseStack;
4
import net.fabricmc.api.EnvType;
5
import net.fabricmc.api.Environment;
6
import net.minecraft.client.model.animal.parrot.ParrotModel;
7
import net.minecraft.client.model.geom.EntityModelSet;
8
import net.minecraft.client.model.geom.ModelLayers;
9
import net.minecraft.client.model.player.PlayerModel;
10
import net.minecraft.client.renderer.SubmitNodeCollector;
11
import net.minecraft.client.renderer.entity.ParrotRenderer;
12
import net.minecraft.client.renderer.entity.RenderLayerParent;
13
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
14
import net.minecraft.client.renderer.entity.state.ParrotRenderState;
15
import net.minecraft.client.renderer.texture.OverlayTexture;
16
import net.minecraft.world.entity.animal.parrot.Parrot.Variant;
17
18
@Environment(EnvType.CLIENT)
19
public class ParrotOnShoulderLayer extends RenderLayer<AvatarRenderState, PlayerModel> {
20
	private final ParrotModel model;
21
22
	public ParrotOnShoulderLayer(final RenderLayerParent<AvatarRenderState, PlayerModel> renderer, final EntityModelSet modelSet) {
23
		super(renderer);
24
		this.model = new ParrotModel(modelSet.bakeLayer(ModelLayers.PARROT));
25
	}
26
27
	public void submit(
28
		final PoseStack poseStack,
29
		final SubmitNodeCollector submitNodeCollector,
30
		final int lightCoords,
31
		final AvatarRenderState state,
32
		final float yRot,
33
		final float xRot
34
	) {
35
		Variant parrotOnLeftShoulder = state.parrotOnLeftShoulder;
36
		if (parrotOnLeftShoulder != null) {
37
			this.submitOnShoulder(poseStack, submitNodeCollector, lightCoords, state, parrotOnLeftShoulder, yRot, xRot, true);
38
		}
39
40
		Variant parrotOnRightShoulder = state.parrotOnRightShoulder;
41
		if (parrotOnRightShoulder != null) {
42
			this.submitOnShoulder(poseStack, submitNodeCollector, lightCoords, state, parrotOnRightShoulder, yRot, xRot, false);
43
		}
44
	}
45
46
	private void submitOnShoulder(
47
		final PoseStack poseStack,
48
		final SubmitNodeCollector submitNodeCollector,
49
		final int lightCoords,
50
		final AvatarRenderState playerState,
51
		final Variant parrotVariant,
52
		final float yRot,
53
		final float xRot,
54
		final boolean isLeft
55
	) {
56
		poseStack.pushPose();
57
		poseStack.translate(isLeft ? 0.4F : -0.4F, playerState.isCrouching ? -1.3F : -1.5F, 0.0F);
58
		ParrotRenderState parrotState = new ParrotRenderState();
59
		parrotState.pose = ParrotModel.Pose.ON_SHOULDER;
60
		parrotState.ageInTicks = playerState.ageInTicks;
61
		parrotState.walkAnimationPos = playerState.walkAnimationPos;
62
		parrotState.walkAnimationSpeed = playerState.walkAnimationSpeed;
63
		parrotState.yRot = yRot;
64
		parrotState.xRot = xRot;
65
		submitNodeCollector.submitModel(
66
			this.model, parrotState, poseStack, ParrotRenderer.getVariantTexture(parrotVariant), lightCoords, OverlayTexture.NO_OVERLAY, playerState.outlineColor
67
		);
68
		poseStack.popPose();
69
	}
70
}
71

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