SmoothDouble .java

net.minecraft.util.SmoothDouble (class, 28 lines): members: getNewDeltaValue, remainingValue, targetValue, lastAmount, reset.

net.minecraft.utilclass28 linescommon720 B

API Surface (2)

double getNewDeltaValue(final double targetDelta, final double time)
void reset()

Fields & Constants (3)

targetValue
remainingValue
lastAmount

Code Graph: Dependencies (1)

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

Full Source

SmoothDouble.java28 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util;
2
3
public class SmoothDouble {
4
	private double targetValue;
5
	private double remainingValue;
6
	private double lastAmount;
7
8
	public double getNewDeltaValue(final double targetDelta, final double time) {
9
		this.targetValue += targetDelta;
10
		double delta = this.targetValue - this.remainingValue;
11
		double newLastAmount = Mth.lerp(0.5, this.lastAmount, delta);
12
		double deltaSign = Math.signum(delta);
13
		if (deltaSign * delta > deltaSign * this.lastAmount) {
14
			delta = newLastAmount;
15
		}
16
17
		this.lastAmount = newLastAmount;
18
		this.remainingValue += delta * time;
19
		return delta * time;
20
	}
21
22
	public void reset() {
23
		this.targetValue = 0.0;
24
		this.remainingValue = 0.0;
25
		this.lastAmount = 0.0;
26
	}
27
}
28

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