WalkAnimationState .java

net.minecraft.world.entity.WalkAnimationState (class): members: positionScale, speedOld, isMoving, setSpeed, speed, position, update, stop. imports: Mth.

net.minecraft.world.entityclass48 linescommon1.1 KB

API Surface (8)

void setSpeed(final float speed)
void update(final float targetSpeed, final float factor, final float positionScale)
void stop()
float speed()
float speed(final float partialTicks)
float position()
float position(final float partialTicks)
boolean isMoving()

Fields & Constants (4)

speedOld
speed
position
positionScale

Code Graph: Dependencies (1)

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

Full Source

WalkAnimationState.java48 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity;
2
3
import net.minecraft.util.Mth;
4
5
public class WalkAnimationState {
6
	private float speedOld;
7
	private float speed;
8
	private float position;
9
	private float positionScale = 1.0F;
10
11
	public void setSpeed(final float speed) {
12
		this.speed = speed;
13
	}
14
15
	public void update(final float targetSpeed, final float factor, final float positionScale) {
16
		this.speedOld = this.speed;
17
		this.speed = this.speed + (targetSpeed - this.speed) * factor;
18
		this.position = this.position + this.speed;
19
		this.positionScale = positionScale;
20
	}
21
22
	public void stop() {
23
		this.speedOld = 0.0F;
24
		this.speed = 0.0F;
25
		this.position = 0.0F;
26
	}
27
28
	public float speed() {
29
		return this.speed;
30
	}
31
32
	public float speed(final float partialTicks) {
33
		return Math.min(Mth.lerp(partialTicks, this.speedOld, this.speed), 1.0F);
34
	}
35
36
	public float position() {
37
		return this.position * this.positionScale;
38
	}
39
40
	public float position(final float partialTicks) {
41
		return (this.position - this.speed * (1.0F - partialTicks)) * this.positionScale;
42
	}
43
44
	public boolean isMoving() {
45
		return this.speed > 1.0E-5F;
46
	}
47
}
48

Decompiled Minecraft 26.3 source of WalkAnimationState (net/minecraft/world/entity/WalkAnimationState.java) with Mojang official mappings, stored verbatim on the site.