BinaryAnimator .java

net.minecraft.util.BinaryAnimator (class, 34 lines): members: animationLength, getFactor, ticksOld, easing, ticks, tick.

net.minecraft.utilclass34 linescommon815 B

API Surface (2)

void tick(final boolean active)
float getFactor(final float partialTicks)

Fields & Constants (4)

animationLength
easing
ticks
ticksOld

Code Graph: Dependencies (2)

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

Full Source

BinaryAnimator.java34 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util;
2
3
public class BinaryAnimator {
4
	private final int animationLength;
5
	private final EasingType easing;
6
	private int ticks;
7
	private int ticksOld;
8
9
	public BinaryAnimator(final int animationLength, final EasingType easing) {
10
		this.animationLength = animationLength;
11
		this.easing = easing;
12
	}
13
14
	public BinaryAnimator(final int animationLength) {
15
		this(animationLength, EasingType.LINEAR);
16
	}
17
18
	public void tick(final boolean active) {
19
		this.ticksOld = this.ticks;
20
		if (active) {
21
			if (this.ticks < this.animationLength) {
22
				this.ticks++;
23
			}
24
		} else if (this.ticks > 0) {
25
			this.ticks--;
26
		}
27
	}
28
29
	public float getFactor(final float partialTicks) {
30
		float factor = Mth.lerp(partialTicks, this.ticksOld, this.ticks) / this.animationLength;
31
		return this.easing.apply(factor);
32
	}
33
}
34

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