DragonFlightHistory .java

net.minecraft.world.entity.boss.enderdragon.DragonFlightHistory (class): members: Sample, samples, LENGTH, record, MASK, copyFrom, head, get. imports: Mth.

net.minecraft.world.entity.boss.enderdragonclass47 linescommon1.4 KB

API Surface (5)

void copyFrom(final DragonFlightHistory history)
void record(final double y, final float yRot)
DragonFlightHistory.Sample get(final int delay)
DragonFlightHistory.Sample get(final int delay, final float partialTicks)
record Sample(double y, float yRot)

Fields & Constants (4)

LENGTH
MASK
samples
head

Code Graph: Dependencies (1)

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

Full Source

DragonFlightHistory.java47 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.boss.enderdragon;
2
3
import java.util.Arrays;
4
import net.minecraft.util.Mth;
5
6
public class DragonFlightHistory {
7
	public static final int LENGTH = 64;
8
	private static final int MASK = 63;
9
	private final DragonFlightHistory.Sample[] samples = new DragonFlightHistory.Sample[64];
10
	private int head = -1;
11
12
	public DragonFlightHistory() {
13
		Arrays.fill(this.samples, new DragonFlightHistory.Sample(0.0, 0.0F));
14
	}
15
16
	public void copyFrom(final DragonFlightHistory history) {
17
		System.arraycopy(history.samples, 0, this.samples, 0, 64);
18
		this.head = history.head;
19
	}
20
21
	public void record(final double y, final float yRot) {
22
		DragonFlightHistory.Sample sample = new DragonFlightHistory.Sample(y, yRot);
23
		if (this.head < 0) {
24
			Arrays.fill(this.samples, sample);
25
		}
26
27
		if (++this.head == 64) {
28
			this.head = 0;
29
		}
30
31
		this.samples[this.head] = sample;
32
	}
33
34
	public DragonFlightHistory.Sample get(final int delay) {
35
		return this.samples[this.head - delay & 63];
36
	}
37
38
	public DragonFlightHistory.Sample get(final int delay, final float partialTicks) {
39
		DragonFlightHistory.Sample sample = this.get(delay);
40
		DragonFlightHistory.Sample sampleOld = this.get(delay + 1);
41
		return new DragonFlightHistory.Sample(Mth.lerp(partialTicks, sampleOld.y, sample.y), Mth.rotLerp(partialTicks, sampleOld.yRot, sample.yRot));
42
	}
43
44
	public record Sample(double y, float yRot) {
45
	}
46
}
47

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