LerpingBossEvent .java

net.minecraft.client.gui.components.LerpingBossEvent (class, 52 lines): members: LERP_MILLISECONDS, targetPercent, playMusic, darkenScreen, setTime, color.

net.minecraft.client.gui.componentsclass52 linesclientextends BossEvent1.5 KB

API Surface (2)

void setProgress(final float progress)
float getProgress()

Fields & Constants (10)

LERP_MILLISECONDS
targetPercent
setTime
id
name
progress
color
overlay
darkenScreen
playMusic

Code Graph: Dependencies (4)

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

Full Source

LerpingBossEvent.java52 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.gui.components;
2
3
import java.util.UUID;
4
import net.fabricmc.api.EnvType;
5
import net.fabricmc.api.Environment;
6
import net.minecraft.network.chat.Component;
7
import net.minecraft.util.Mth;
8
import net.minecraft.util.Util;
9
import net.minecraft.world.BossEvent;
10
import net.minecraft.world.BossEvent.BossBarColor;
11
import net.minecraft.world.BossEvent.BossBarOverlay;
12
13
@Environment(EnvType.CLIENT)
14
public class LerpingBossEvent extends BossEvent {
15
	private static final long LERP_MILLISECONDS = 100L;
16
	protected float targetPercent;
17
	protected long setTime;
18
19
	public LerpingBossEvent(
20
		final UUID id,
21
		final Component name,
22
		final float progress,
23
		final BossBarColor color,
24
		final BossBarOverlay overlay,
25
		final boolean darkenScreen,
26
		final boolean playMusic,
27
		final boolean createWorldFog
28
	) {
29
		super(id, name, color, overlay);
30
		this.targetPercent = progress;
31
		this.progress = progress;
32
		this.setTime = Util.getMillis();
33
		this.setDarkenScreen(darkenScreen);
34
		this.setPlayBossMusic(playMusic);
35
		this.setCreateWorldFog(createWorldFog);
36
	}
37
38
	@Override
39
	public void setProgress(final float progress) {
40
		this.progress = this.getProgress();
41
		this.targetPercent = progress;
42
		this.setTime = Util.getMillis();
43
	}
44
45
	@Override
46
	public float getProgress() {
47
		long timeSinceSet = Util.getMillis() - this.setTime;
48
		float lerpPercent = Mth.clamp((float)timeSinceSet / 100.0F, 0.0F, 1.0F);
49
		return Mth.lerp(lerpPercent, this.progress, this.targetPercent);
50
	}
51
}
52

Decompiled Minecraft 26.3 source of LerpingBossEvent (net/minecraft/client/gui/components/LerpingBossEvent.java) with Mojang official mappings, stored verbatim on the site.