BlazeModel .java

net.minecraft.client.model.monster.blaze.BlazeModel (class, 103 lines): members: upperBodyParts, head, setupAnim, createBodyLayer. strings: "part", "head".

net.minecraft.client.model.monster.blazeclass103 linesclientextends EntityModel<LivingEntityRenderState>3.5 KB

API Surface (2)

LayerDefinition createBodyLayer()
void setupAnim(final LivingEntityRenderState state)

Fields & Constants (2)

upperBodyParts
head

String literals (2)

"head"
"part"

Same Package (1)

Full Source

BlazeModel.java103 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.model.monster.blaze;
2
3
import java.util.Arrays;
4
import net.fabricmc.api.EnvType;
5
import net.fabricmc.api.Environment;
6
import net.minecraft.client.model.EntityModel;
7
import net.minecraft.client.model.geom.ModelPart;
8
import net.minecraft.client.model.geom.PartPose;
9
import net.minecraft.client.model.geom.builders.CubeListBuilder;
10
import net.minecraft.client.model.geom.builders.LayerDefinition;
11
import net.minecraft.client.model.geom.builders.MeshDefinition;
12
import net.minecraft.client.model.geom.builders.PartDefinition;
13
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
14
import net.minecraft.util.Mth;
15
16
@Environment(EnvType.CLIENT)
17
public class BlazeModel extends EntityModel<LivingEntityRenderState> {
18
	private final ModelPart[] upperBodyParts;
19
	private final ModelPart head;
20
21
	public BlazeModel(final ModelPart root) {
22
		super(root);
23
		this.head = root.getChild("head");
24
		this.upperBodyParts = new ModelPart[12];
25
		Arrays.setAll(this.upperBodyParts, i -> root.getChild(getPartName(i)));
26
	}
27
28
	private static String getPartName(final int i) {
29
		return "part" + i;
30
	}
31
32
	public static LayerDefinition createBodyLayer() {
33
		MeshDefinition mesh = new MeshDefinition();
34
		PartDefinition root = mesh.getRoot();
35
		root.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F), PartPose.ZERO);
36
		float angle = 0.0F;
37
		CubeListBuilder rod = CubeListBuilder.create().texOffs(0, 16).addBox(0.0F, 0.0F, 0.0F, 2.0F, 8.0F, 2.0F);
38
39
		for (int i = 0; i < 4; i++) {
40
			float x = Mth.cos(angle) * 9.0F;
41
			float y = -2.0F + Mth.cos(i * 2 * 0.25F);
42
			float z = Mth.sin(angle) * 9.0F;
43
			root.addOrReplaceChild(getPartName(i), rod, PartPose.offset(x, y, z));
44
			angle += (float) (Math.PI / 2);
45
		}
46
47
		angle = (float) (Math.PI / 4);
48
49
		for (int i = 4; i < 8; i++) {
50
			float x = Mth.cos(angle) * 7.0F;
51
			float y = 2.0F + Mth.cos(i * 2 * 0.25F);
52
			float z = Mth.sin(angle) * 7.0F;
53
			root.addOrReplaceChild(getPartName(i), rod, PartPose.offset(x, y, z));
54
			angle += (float) (Math.PI / 2);
55
		}
56
57
		angle = 0.47123894F;
58
59
		for (int i = 8; i < 12; i++) {
60
			float x = Mth.cos(angle) * 5.0F;
61
			float y = 11.0F + Mth.cos(i * 1.5F * 0.5F);
62
			float z = Mth.sin(angle) * 5.0F;
63
			root.addOrReplaceChild(getPartName(i), rod, PartPose.offset(x, y, z));
64
			angle += (float) (Math.PI / 2);
65
		}
66
67
		return LayerDefinition.create(mesh, 64, 32);
68
	}
69
70
	public void setupAnim(final LivingEntityRenderState state) {
71
		super.setupAnim(state);
72
		float angle = state.ageInTicks * (float) Math.PI * -0.1F;
73
74
		for (int i = 0; i < 4; i++) {
75
			this.upperBodyParts[i].y = -2.0F + Mth.cos((i * 2 + state.ageInTicks) * 0.25F);
76
			this.upperBodyParts[i].x = Mth.cos(angle) * 9.0F;
77
			this.upperBodyParts[i].z = Mth.sin(angle) * 9.0F;
78
			angle += (float) (Math.PI / 2);
79
		}
80
81
		angle = (float) (Math.PI / 4) + state.ageInTicks * (float) Math.PI * 0.03F;
82
83
		for (int i = 4; i < 8; i++) {
84
			this.upperBodyParts[i].y = 2.0F + Mth.cos((i * 2 + state.ageInTicks) * 0.25F);
85
			this.upperBodyParts[i].x = Mth.cos(angle) * 7.0F;
86
			this.upperBodyParts[i].z = Mth.sin(angle) * 7.0F;
87
			angle += (float) (Math.PI / 2);
88
		}
89
90
		angle = 0.47123894F + state.ageInTicks * (float) Math.PI * -0.05F;
91
92
		for (int i = 8; i < 12; i++) {
93
			this.upperBodyParts[i].y = 11.0F + Mth.cos((i * 1.5F + state.ageInTicks) * 0.5F);
94
			this.upperBodyParts[i].x = Mth.cos(angle) * 5.0F;
95
			this.upperBodyParts[i].z = Mth.sin(angle) * 5.0F;
96
			angle += (float) (Math.PI / 2);
97
		}
98
99
		this.head.yRot = state.yRot * (float) (Math.PI / 180.0);
100
		this.head.xRot = state.xRot * (float) (Math.PI / 180.0);
101
	}
102
}
103

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