SnifferModel .java

net.minecraft.client.model.animal.sniffer.SnifferModel (class): members: WALK_ANIMATION_SPEED_MAX, sniffSearchAnimation, sniffSniffAnimation, digAnimation.

net.minecraft.client.model.animal.snifferclass136 linesclientextends EntityModel<SnifferRenderState>5.9 KB

API Surface (2)

LayerDefinition createBodyLayer()
void setupAnim(final SnifferRenderState state)

Fields & Constants (10)

WALK_ANIMATION_SPEED_MAX
WALK_ANIMATION_SCALE_FACTOR
head
sniffSearchAnimation
walkAnimation
digAnimation
longSniffAnimation
standUpAnimation
happyAnimation
sniffSniffAnimation

String literals (13)

"bone"
"body"
"head"
"right_front_leg"
"right_mid_leg"
"right_hind_leg"
"left_front_leg"
"left_mid_leg"
"left_hind_leg"
"left_ear"
"right_ear"
"nose"
"lower_beak"

Full Source

SnifferModel.java136 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.model.animal.sniffer;
2
3
import net.fabricmc.api.EnvType;
4
import net.fabricmc.api.Environment;
5
import net.minecraft.client.animation.KeyframeAnimation;
6
import net.minecraft.client.animation.definitions.SnifferAnimation;
7
import net.minecraft.client.model.EntityModel;
8
import net.minecraft.client.model.geom.ModelPart;
9
import net.minecraft.client.model.geom.PartPose;
10
import net.minecraft.client.model.geom.builders.CubeDeformation;
11
import net.minecraft.client.model.geom.builders.CubeListBuilder;
12
import net.minecraft.client.model.geom.builders.LayerDefinition;
13
import net.minecraft.client.model.geom.builders.MeshDefinition;
14
import net.minecraft.client.model.geom.builders.PartDefinition;
15
import net.minecraft.client.renderer.entity.state.SnifferRenderState;
16
17
@Environment(EnvType.CLIENT)
18
public class SnifferModel extends EntityModel<SnifferRenderState> {
19
	private static final float WALK_ANIMATION_SPEED_MAX = 9.0F;
20
	private static final float WALK_ANIMATION_SCALE_FACTOR = 100.0F;
21
	private final ModelPart head;
22
	private final KeyframeAnimation sniffSearchAnimation;
23
	private final KeyframeAnimation walkAnimation;
24
	private final KeyframeAnimation digAnimation;
25
	private final KeyframeAnimation longSniffAnimation;
26
	private final KeyframeAnimation standUpAnimation;
27
	private final KeyframeAnimation happyAnimation;
28
	private final KeyframeAnimation sniffSniffAnimation;
29
30
	public SnifferModel(final ModelPart root) {
31
		super(root);
32
		this.head = root.getChild("bone").getChild("body").getChild("head");
33
		this.sniffSearchAnimation = SnifferAnimation.SNIFFER_SNIFF_SEARCH.bake(root);
34
		this.walkAnimation = SnifferAnimation.SNIFFER_WALK.bake(root);
35
		this.digAnimation = SnifferAnimation.SNIFFER_DIG.bake(root);
36
		this.longSniffAnimation = SnifferAnimation.SNIFFER_LONGSNIFF.bake(root);
37
		this.standUpAnimation = SnifferAnimation.SNIFFER_STAND_UP.bake(root);
38
		this.happyAnimation = SnifferAnimation.SNIFFER_HAPPY.bake(root);
39
		this.sniffSniffAnimation = SnifferAnimation.SNIFFER_SNIFFSNIFF.bake(root);
40
	}
41
42
	public static LayerDefinition createBodyLayer() {
43
		MeshDefinition mesh = new MeshDefinition();
44
		PartDefinition root = mesh.getRoot();
45
		PartDefinition bone = root.addOrReplaceChild("bone", CubeListBuilder.create(), PartPose.offset(0.0F, 5.0F, 0.0F));
46
		PartDefinition body = bone.addOrReplaceChild(
47
			"body",
48
			CubeListBuilder.create()
49
				.texOffs(62, 68)
50
				.addBox(-12.5F, -14.0F, -20.0F, 25.0F, 29.0F, 40.0F, new CubeDeformation(0.0F))
51
				.texOffs(62, 0)
52
				.addBox(-12.5F, -14.0F, -20.0F, 25.0F, 24.0F, 40.0F, new CubeDeformation(0.5F))
53
				.texOffs(87, 68)
54
				.addBox(-12.5F, 12.0F, -20.0F, 25.0F, 0.0F, 40.0F, new CubeDeformation(0.0F)),
55
			PartPose.offset(0.0F, 0.0F, 0.0F)
56
		);
57
		bone.addOrReplaceChild(
58
			"right_front_leg",
59
			CubeListBuilder.create().texOffs(32, 87).addBox(-3.5F, -1.0F, -4.0F, 7.0F, 10.0F, 8.0F, new CubeDeformation(0.0F)),
60
			PartPose.offset(-7.5F, 10.0F, -15.0F)
61
		);
62
		bone.addOrReplaceChild(
63
			"right_mid_leg",
64
			CubeListBuilder.create().texOffs(32, 105).addBox(-3.5F, -1.0F, -4.0F, 7.0F, 10.0F, 8.0F, new CubeDeformation(0.0F)),
65
			PartPose.offset(-7.5F, 10.0F, 0.0F)
66
		);
67
		bone.addOrReplaceChild(
68
			"right_hind_leg",
69
			CubeListBuilder.create().texOffs(32, 123).addBox(-3.5F, -1.0F, -4.0F, 7.0F, 10.0F, 8.0F, new CubeDeformation(0.0F)),
70
			PartPose.offset(-7.5F, 10.0F, 15.0F)
71
		);
72
		bone.addOrReplaceChild(
73
			"left_front_leg",
74
			CubeListBuilder.create().texOffs(0, 87).addBox(-3.5F, -1.0F, -4.0F, 7.0F, 10.0F, 8.0F, new CubeDeformation(0.0F)),
75
			PartPose.offset(7.5F, 10.0F, -15.0F)
76
		);
77
		bone.addOrReplaceChild(
78
			"left_mid_leg",
79
			CubeListBuilder.create().texOffs(0, 105).addBox(-3.5F, -1.0F, -4.0F, 7.0F, 10.0F, 8.0F, new CubeDeformation(0.0F)),
80
			PartPose.offset(7.5F, 10.0F, 0.0F)
81
		);
82
		bone.addOrReplaceChild(
83
			"left_hind_leg",
84
			CubeListBuilder.create().texOffs(0, 123).addBox(-3.5F, -1.0F, -4.0F, 7.0F, 10.0F, 8.0F, new CubeDeformation(0.0F)),
85
			PartPose.offset(7.5F, 10.0F, 15.0F)
86
		);
87
		PartDefinition head = body.addOrReplaceChild(
88
			"head",
89
			CubeListBuilder.create()
90
				.texOffs(8, 15)
91
				.addBox(-6.5F, -7.5F, -11.5F, 13.0F, 18.0F, 11.0F, new CubeDeformation(0.0F))
92
				.texOffs(8, 4)
93
				.addBox(-6.5F, 7.5F, -11.5F, 13.0F, 0.0F, 11.0F, new CubeDeformation(0.0F)),
94
			PartPose.offset(0.0F, 6.5F, -19.48F)
95
		);
96
		head.addOrReplaceChild(
97
			"left_ear",
98
			CubeListBuilder.create().texOffs(2, 0).addBox(0.0F, 0.0F, -3.0F, 1.0F, 19.0F, 7.0F, new CubeDeformation(0.0F)),
99
			PartPose.offset(6.51F, -7.5F, -4.51F)
100
		);
101
		head.addOrReplaceChild(
102
			"right_ear",
103
			CubeListBuilder.create().texOffs(48, 0).addBox(-1.0F, 0.0F, -3.0F, 1.0F, 19.0F, 7.0F, new CubeDeformation(0.0F)),
104
			PartPose.offset(-6.51F, -7.5F, -4.51F)
105
		);
106
		head.addOrReplaceChild(
107
			"nose",
108
			CubeListBuilder.create().texOffs(10, 45).addBox(-6.5F, -2.0F, -9.0F, 13.0F, 2.0F, 9.0F, new CubeDeformation(0.0F)),
109
			PartPose.offset(0.0F, -4.5F, -11.5F)
110
		);
111
		head.addOrReplaceChild(
112
			"lower_beak",
113
			CubeListBuilder.create().texOffs(10, 57).addBox(-6.5F, -7.0F, -8.0F, 13.0F, 12.0F, 9.0F, new CubeDeformation(0.0F)),
114
			PartPose.offset(0.0F, 2.5F, -12.5F)
115
		);
116
		return LayerDefinition.create(mesh, 192, 192);
117
	}
118
119
	public void setupAnim(final SnifferRenderState state) {
120
		super.setupAnim(state);
121
		this.head.xRot = state.xRot * (float) (Math.PI / 180.0);
122
		this.head.yRot = state.yRot * (float) (Math.PI / 180.0);
123
		if (state.isSearching) {
124
			this.sniffSearchAnimation.applyWalk(state.walkAnimationPos, state.walkAnimationSpeed, 9.0F, 100.0F);
125
		} else {
126
			this.walkAnimation.applyWalk(state.walkAnimationPos, state.walkAnimationSpeed, 9.0F, 100.0F);
127
		}
128
129
		this.digAnimation.apply(state.diggingAnimationState, state.ageInTicks);
130
		this.longSniffAnimation.apply(state.sniffingAnimationState, state.ageInTicks);
131
		this.standUpAnimation.apply(state.risingAnimationState, state.ageInTicks);
132
		this.happyAnimation.apply(state.feelingHappyAnimationState, state.ageInTicks);
133
		this.sniffSniffAnimation.apply(state.scentingAnimationState, state.ageInTicks);
134
	}
135
}
136

Decompiled Minecraft 26.3 source of SnifferModel (net/minecraft/client/model/animal/sniffer/SnifferModel.java) with Mojang official mappings, stored verbatim on the site.