GhastModel .java

net.minecraft.client.model.monster.ghast.GhastModel (class, 60 lines): members: animateTentacles, tentacles, setupAnim, createBodyLayer. strings: "body".

net.minecraft.client.model.monster.ghastclass60 linesclientextends EntityModel<GhastRenderState>2.3 KB

API Surface (3)

LayerDefinition createBodyLayer()
void setupAnim(final GhastRenderState state)
void animateTentacles(final EntityRenderState state, final ModelPart[] tentacles)

Fields & Constants (1)

tentacles

String literals (1)

"body"

Same Package (1)

Full Source

GhastModel.java60 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.model.monster.ghast;
2
3
import net.fabricmc.api.EnvType;
4
import net.fabricmc.api.Environment;
5
import net.minecraft.client.model.EntityModel;
6
import net.minecraft.client.model.geom.ModelPart;
7
import net.minecraft.client.model.geom.PartNames;
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.MeshTransformer;
13
import net.minecraft.client.model.geom.builders.PartDefinition;
14
import net.minecraft.client.renderer.entity.state.EntityRenderState;
15
import net.minecraft.client.renderer.entity.state.GhastRenderState;
16
import net.minecraft.util.Mth;
17
import net.minecraft.util.RandomSource;
18
19
@Environment(EnvType.CLIENT)
20
public class GhastModel extends EntityModel<GhastRenderState> {
21
	private final ModelPart[] tentacles = new ModelPart[9];
22
23
	public GhastModel(final ModelPart root) {
24
		super(root);
25
26
		for (int i = 0; i < this.tentacles.length; i++) {
27
			this.tentacles[i] = root.getChild(PartNames.tentacle(i));
28
		}
29
	}
30
31
	public static LayerDefinition createBodyLayer() {
32
		MeshDefinition mesh = new MeshDefinition();
33
		PartDefinition root = mesh.getRoot();
34
		root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 0).addBox(-8.0F, -8.0F, -8.0F, 16.0F, 16.0F, 16.0F), PartPose.offset(0.0F, 17.6F, 0.0F));
35
		RandomSource random = RandomSource.createThreadLocalInstance(1660L);
36
37
		for (int i = 0; i < 9; i++) {
38
			float xo = ((i % 3 - i / 3 % 2 * 0.5F + 0.25F) / 2.0F * 2.0F - 1.0F) * 5.0F;
39
			float yo = (i / 3 / 2.0F * 2.0F - 1.0F) * 5.0F;
40
			int len = random.nextInt(7) + 8;
41
			root.addOrReplaceChild(
42
				PartNames.tentacle(i), CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, len, 2.0F), PartPose.offset(xo, 24.6F, yo)
43
			);
44
		}
45
46
		return LayerDefinition.create(mesh, 64, 32).apply(MeshTransformer.scaling(4.5F));
47
	}
48
49
	public void setupAnim(final GhastRenderState state) {
50
		super.setupAnim(state);
51
		animateTentacles(state, this.tentacles);
52
	}
53
54
	public static void animateTentacles(final EntityRenderState state, final ModelPart[] tentacles) {
55
		for (int i = 0; i < tentacles.length; i++) {
56
			tentacles[i].xRot = 0.2F * Mth.sin(state.ageInTicks * 0.3F + i) + 0.4F;
57
		}
58
	}
59
}
60

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