CreakingModel .java

net.minecraft.client.model.monster.creaking.CreakingModel (class): members: invulnerableAnimation, deathAnimation, attackAnimation, createEyesLayer, head.

net.minecraft.client.model.monster.creakingclass118 linesclientextends EntityModel<CreakingRenderState>4.6 KB

API Surface (3)

LayerDefinition createBodyLayer()
LayerDefinition createEyesLayer()
void setupAnim(final CreakingRenderState state)

Fields & Constants (5)

head
walkAnimation
attackAnimation
invulnerableAnimation
deathAnimation

String literals (8)

"root"
"upper_body"
"head"
"body"
"right_arm"
"left_arm"
"left_leg"
"right_leg"

Same Package (1)

Full Source

CreakingModel.java118 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.model.monster.creaking;
2
3
import java.util.Set;
4
import net.fabricmc.api.EnvType;
5
import net.fabricmc.api.Environment;
6
import net.minecraft.client.animation.KeyframeAnimation;
7
import net.minecraft.client.animation.definitions.CreakingAnimation;
8
import net.minecraft.client.model.EntityModel;
9
import net.minecraft.client.model.geom.ModelPart;
10
import net.minecraft.client.model.geom.PartPose;
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.CreakingRenderState;
16
17
@Environment(EnvType.CLIENT)
18
public class CreakingModel extends EntityModel<CreakingRenderState> {
19
	private final ModelPart head;
20
	private final KeyframeAnimation walkAnimation;
21
	private final KeyframeAnimation attackAnimation;
22
	private final KeyframeAnimation invulnerableAnimation;
23
	private final KeyframeAnimation deathAnimation;
24
25
	public CreakingModel(final ModelPart roots) {
26
		super(roots);
27
		ModelPart root = roots.getChild("root");
28
		ModelPart upperBody = root.getChild("upper_body");
29
		this.head = upperBody.getChild("head");
30
		this.walkAnimation = CreakingAnimation.CREAKING_WALK.bake(root);
31
		this.attackAnimation = CreakingAnimation.CREAKING_ATTACK.bake(root);
32
		this.invulnerableAnimation = CreakingAnimation.CREAKING_INVULNERABLE.bake(root);
33
		this.deathAnimation = CreakingAnimation.CREAKING_DEATH.bake(root);
34
	}
35
36
	private static MeshDefinition createMesh() {
37
		MeshDefinition meshDefinition = new MeshDefinition();
38
		PartDefinition partDefinition = meshDefinition.getRoot();
39
		PartDefinition root = partDefinition.addOrReplaceChild("root", CubeListBuilder.create(), PartPose.offset(0.0F, 24.0F, 0.0F));
40
		PartDefinition upperBody = root.addOrReplaceChild("upper_body", CubeListBuilder.create(), PartPose.offset(-1.0F, -19.0F, 0.0F));
41
		upperBody.addOrReplaceChild(
42
			"head",
43
			CubeListBuilder.create()
44
				.texOffs(0, 0)
45
				.addBox(-3.0F, -10.0F, -3.0F, 6.0F, 10.0F, 6.0F)
46
				.texOffs(28, 31)
47
				.addBox(-3.0F, -13.0F, -3.0F, 6.0F, 3.0F, 6.0F)
48
				.texOffs(12, 40)
49
				.addBox(3.0F, -13.0F, 0.0F, 9.0F, 14.0F, 0.0F)
50
				.texOffs(34, 12)
51
				.addBox(-12.0F, -14.0F, 0.0F, 9.0F, 14.0F, 0.0F),
52
			PartPose.offset(-3.0F, -11.0F, 0.0F)
53
		);
54
		upperBody.addOrReplaceChild(
55
			"body",
56
			CubeListBuilder.create().texOffs(0, 16).addBox(0.0F, -3.0F, -3.0F, 6.0F, 13.0F, 5.0F).texOffs(24, 0).addBox(-6.0F, -4.0F, -3.0F, 6.0F, 7.0F, 5.0F),
57
			PartPose.offset(0.0F, -7.0F, 1.0F)
58
		);
59
		upperBody.addOrReplaceChild(
60
			"right_arm",
61
			CubeListBuilder.create().texOffs(22, 13).addBox(-2.0F, -1.5F, -1.5F, 3.0F, 21.0F, 3.0F).texOffs(46, 0).addBox(-2.0F, 19.5F, -1.5F, 3.0F, 4.0F, 3.0F),
62
			PartPose.offset(-7.0F, -9.5F, 1.5F)
63
		);
64
		upperBody.addOrReplaceChild(
65
			"left_arm",
66
			CubeListBuilder.create()
67
				.texOffs(30, 40)
68
				.addBox(0.0F, -1.0F, -1.5F, 3.0F, 16.0F, 3.0F)
69
				.texOffs(52, 12)
70
				.addBox(0.0F, -5.0F, -1.5F, 3.0F, 4.0F, 3.0F)
71
				.texOffs(52, 19)
72
				.addBox(0.0F, 15.0F, -1.5F, 3.0F, 4.0F, 3.0F),
73
			PartPose.offset(6.0F, -9.0F, 0.5F)
74
		);
75
		root.addOrReplaceChild(
76
			"left_leg",
77
			CubeListBuilder.create().texOffs(42, 40).addBox(-1.5F, 0.0F, -1.5F, 3.0F, 16.0F, 3.0F).texOffs(45, 55).addBox(-1.5F, 15.7F, -4.5F, 5.0F, 0.0F, 9.0F),
78
			PartPose.offset(1.5F, -16.0F, 0.5F)
79
		);
80
		root.addOrReplaceChild(
81
			"right_leg",
82
			CubeListBuilder.create()
83
				.texOffs(0, 34)
84
				.addBox(-3.0F, -1.5F, -1.5F, 3.0F, 19.0F, 3.0F)
85
				.texOffs(45, 46)
86
				.addBox(-5.0F, 17.2F, -4.5F, 5.0F, 0.0F, 9.0F)
87
				.texOffs(12, 34)
88
				.addBox(-3.0F, -4.5F, -1.5F, 3.0F, 3.0F, 3.0F),
89
			PartPose.offset(-1.0F, -17.5F, 0.5F)
90
		);
91
		return meshDefinition;
92
	}
93
94
	public static LayerDefinition createBodyLayer() {
95
		MeshDefinition mesh = createMesh();
96
		return LayerDefinition.create(mesh, 64, 64);
97
	}
98
99
	public static LayerDefinition createEyesLayer() {
100
		MeshDefinition mesh = createMesh();
101
		mesh.getRoot().retainExactParts(Set.of("head"));
102
		return LayerDefinition.create(mesh, 64, 64);
103
	}
104
105
	public void setupAnim(final CreakingRenderState state) {
106
		super.setupAnim(state);
107
		this.head.xRot = state.xRot * (float) (Math.PI / 180.0);
108
		this.head.yRot = state.yRot * (float) (Math.PI / 180.0);
109
		if (state.canMove) {
110
			this.walkAnimation.applyWalk(state.walkAnimationPos, state.walkAnimationSpeed, 1.0F, 1.0F);
111
		}
112
113
		this.attackAnimation.apply(state.attackAnimationState, state.ageInTicks);
114
		this.invulnerableAnimation.apply(state.invulnerabilityAnimationState, state.ageInTicks);
115
		this.deathAnimation.apply(state.deathAnimationState, state.ageInTicks);
116
	}
117
}
118

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