Files
OpenOnyx/src/openonyx/render/group_w/BossBarElement.java
T

112 lines
3.7 KiB
Java

package openonyx.render.group_w;
import net.minecraft.entity.boss.BossStatus;
import openonyx.features.hud.CustomGui;
import openonyx.render.Render2D;
import openonyx.render.group_d.Animation;
import openonyx.render.group_d.Easings;
import openonyx.render.group_e.FontFamilyMode;
import openonyx.render.group_e.FontStyle;
import openonyx.render.group_e.TargetHudTextSettingsWeightMode;
import openonyx.theme.Palette;
import openonyx.theme.ThemeManager;
public final class BossBarElement extends GuiElement {
private final Animation animation = new Animation(0.0F);
private static final float M = 0.5F;
private String L;
private float j;
private final CustomGui customGui;
private static final float h = 182.0F;
private static final float l = 3.0F;
private final Animation animation2 = new Animation(0.0F);
private static final float d = 2.0F;
private static final float i = 0.7F;
private static final FontStyle FONT_STYLE = new FontStyle(FontFamilyMode.PT24, TargetHudTextSettingsWeightMode.BOLD, 12.0F, 15.0F);
private static final float H = 10.0F;
private static final float e = 6.0F;
@Override
protected float d(Render2D render2D) {
return 182.0F;
}
@Override
protected boolean L(boolean bl) {
if (BossStatus.bossName != null && BossStatus.statusBarTime > 0) {
BossStatus.statusBarTime--;
this.L = BossStatus.bossName;
this.j = Math.clamp(BossStatus.healthScale, 0.0F, 1.0F);
return true;
} else if (bl) {
this.L = "Boss";
this.j = 0.7F;
return true;
} else {
return false;
}
}
@Override
protected float L(Render2D render2D) {
return FONT_STYLE.lineHeight() + 3.0F + 6.0F;
}
public BossBarElement(CustomGui customGui) {
super("mcgui:bossbar", customGuix.customGuiPart6.positionX, customGuix.customGuiPart6.positionY, customGuix.customGuiPart6.scale);
this.L = "";
this.customGui = customGuix;
}
@Override
protected void L(float f) {
this.animation.animateTo(this.j, 200.0F, Easings.EASING2);
this.animation.update(f);
if (this.j >= this.animation2.getTarget()) {
this.animation2.set(Math.max(this.j, this.animation.getValue()));
} else {
this.animation2.animateTo(this.j, 500.0F, Easings.EASING);
this.animation2.update(f);
}
}
@Override
protected void L(Render2D render2D, float f, float g, float i) {
Palette palette = ThemeManager.getPalette();
FormattedText.L(render2D, FONT_STYLE, this.L, f / 2.0F, render2D.centerTextY(FONT_STYLE, FONT_STYLE.lineHeight() / 2.0F), palette.onSurface());
g -= 6.0F;
render2D.roundedRect(0.0F, g, f, 6.0F, Float.MAX_VALUE, palette.surfaceContainerHighest());
if (this.customGui.customGuiPart6.segments.isEnabled()) {
this.L(render2D, palette, f, g);
} else {
float hx;
if ((hx = f * this.animation2.getValue()) > 0.5F) {
render2D.roundedRect(0.0F, g, hx, 6.0F, Float.MAX_VALUE, ThemeManager.withAlpha(palette.error(), 0.45F));
}
if ((f = f * this.animation.getValue()) > 0.5F) {
render2D.roundedRect(0.0F, g, f, 6.0F, Float.MAX_VALUE, palette.error());
}
}
}
private void L(Render2D render2D, Palette palette, float f, float g) {
float hx;
float ix = (hx = (f + 2.0F) / 10.0F) - 2.0F;
f *= this.animation.getValue();
int jx;
for (int lx = jx = 0; lx < 10.0F; lx = jx) {
float k;
if ((k = jx * hx) >= f) {
return;
}
render2D.pushScissor(k, g, Math.min(ix, f - k), 6.0F);
jx++;
render2D.roundedRect(k, g, ix, 6.0F, Float.MAX_VALUE, palette.error());
render2D.popScissor();
}
}
}