StriderModel .java

net.minecraft.client.model.monster.strider.StriderModel (class): members: animateBristle, secondBristle, firstBristle, thirdBristle, bristleFlow, SPEED.

net.minecraft.client.model.monster.striderclass63 linesclientextends EntityModel<StriderRenderState>2.5 KB

API Surface (2)

void setupAnim(final StriderRenderState state)
void animateBristle(final float ageInTicks, final float bristleFlow, final ModelPart firstBristle, final ModelPart secondBristle, final ModelPart thirdBristle, final BiConsumer<ModelPart, Float> addRotationFunction)

Fields & Constants (9)

SPEED
rightLeg
leftLeg
body
ageInTicks
bristleFlow
firstBristle
secondBristle
thirdBristle

String literals (3)

"right_leg"
"left_leg"
"body"

Code Graph: Dependencies (4)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

StriderModel.java63 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.model.monster.strider;
2
3
import java.util.function.BiConsumer;
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.renderer.entity.state.StriderRenderState;
9
import net.minecraft.util.Mth;
10
11
@Environment(EnvType.CLIENT)
12
public abstract class StriderModel extends EntityModel<StriderRenderState> {
13
	protected static final float SPEED = 1.5F;
14
	protected final ModelPart rightLeg;
15
	protected final ModelPart leftLeg;
16
	protected final ModelPart body;
17
18
	public StriderModel(final ModelPart root) {
19
		super(root);
20
		this.rightLeg = root.getChild("right_leg");
21
		this.leftLeg = root.getChild("left_leg");
22
		this.body = root.getChild("body");
23
	}
24
25
	public void setupAnim(final StriderRenderState state) {
26
		super.setupAnim(state);
27
		float animationPos = state.walkAnimationPos;
28
		float animationSpeed = Math.min(state.walkAnimationSpeed, 0.25F);
29
		if (!state.isRidden) {
30
			this.body.xRot = state.xRot * (float) (Math.PI / 180.0);
31
			this.body.yRot = state.yRot * (float) (Math.PI / 180.0);
32
		} else {
33
			this.body.xRot = 0.0F;
34
			this.body.yRot = 0.0F;
35
		}
36
37
		this.body.zRot = 0.1F * Mth.sin(animationPos * 1.5F) * 4.0F * animationSpeed;
38
		this.leftLeg.xRot = Mth.sin(animationPos * 1.5F * 0.5F) * 2.0F * animationSpeed;
39
		this.rightLeg.xRot = Mth.sin(animationPos * 1.5F * 0.5F + (float) Math.PI) * 2.0F * animationSpeed;
40
		this.leftLeg.zRot = (float) (Math.PI / 18) * Mth.cos(animationPos * 1.5F * 0.5F) * animationSpeed;
41
		this.rightLeg.zRot = (float) (Math.PI / 18) * Mth.cos(animationPos * 1.5F * 0.5F + (float) Math.PI) * animationSpeed;
42
		this.customAnimations(animationPos, animationSpeed, state.ageInTicks);
43
	}
44
45
	protected abstract void customAnimations(final float animationPos, final float animationSpeed, final float ageInTicks);
46
47
	public void animateBristle(
48
		final float ageInTicks,
49
		final float bristleFlow,
50
		final ModelPart firstBristle,
51
		final ModelPart secondBristle,
52
		final ModelPart thirdBristle,
53
		final BiConsumer<ModelPart, Float> addRotationFunction
54
	) {
55
		addRotationFunction.accept(firstBristle, bristleFlow * 0.6F);
56
		addRotationFunction.accept(secondBristle, bristleFlow * 1.2F);
57
		addRotationFunction.accept(thirdBristle, bristleFlow * 1.3F);
58
		addRotationFunction.accept(firstBristle, 0.1F * Mth.sin(ageInTicks * 0.4F));
59
		addRotationFunction.accept(secondBristle, 0.1F * Mth.sin(ageInTicks * 0.2F));
60
		addRotationFunction.accept(thirdBristle, 0.05F * Mth.sin(ageInTicks * -0.4F));
61
	}
62
}
63

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