File size: 1,507 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package net.minecraft.client.gui.components;

import java.util.UUID;
import net.minecraft.Util;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
import net.minecraft.world.BossEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class LerpingBossEvent extends BossEvent {
    private static final long LERP_MILLISECONDS = 100L;
    protected float targetPercent;
    protected long setTime;

    public LerpingBossEvent(
        UUID p_169021_,
        Component p_169022_,
        float p_169023_,
        BossEvent.BossBarColor p_169024_,
        BossEvent.BossBarOverlay p_169025_,
        boolean p_169026_,
        boolean p_169027_,
        boolean p_169028_
    ) {
        super(p_169021_, p_169022_, p_169024_, p_169025_);
        this.targetPercent = p_169023_;
        this.progress = p_169023_;
        this.setTime = Util.getMillis();
        this.setDarkenScreen(p_169026_);
        this.setPlayBossMusic(p_169027_);
        this.setCreateWorldFog(p_169028_);
    }

    @Override
    public void setProgress(float p_169030_) {
        this.progress = this.getProgress();
        this.targetPercent = p_169030_;
        this.setTime = Util.getMillis();
    }

    @Override
    public float getProgress() {
        long i = Util.getMillis() - this.setTime;
        float f = Mth.clamp((float)i / 100.0F, 0.0F, 1.0F);
        return Mth.lerp(f, this.progress, this.targetPercent);
    }
}