Upload files to "src/openonyx/features/hud"

This commit is contained in:
winterflyt committed 2026-11-30 05:50:08 +02:00
1 parent d543d7be9f
commit d6fb225fda
5 files changed
+1056

No files matched your search

@@ -0,0 +1,12 @@
package openonyx.features.hud;
import openonyx.render.group_d.Animation;
final class KeybindsPart {
private final Animation animation = new Animation(0.0F);
private String e;
private KeybindsPart(String string) {
this.e = string;
}
}
@@ -0,0 +1,524 @@
package openonyx.features.hud;
import java.util.ArrayList;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import net.minecraft.block.BlockBed;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.util.BlockPos;
import openonyx.core.OnyxClient;
import openonyx.features.Module;
import openonyx.features.ModuleCategory;
import openonyx.features.combat.BedBreaker;
import openonyx.features.hud.group_d.Notification;
import openonyx.features.hud.group_d.NotificationLevel;
import openonyx.features.player.Scaffold;
import openonyx.history.internal.BooleanSetting;
import openonyx.history.internal.NumberSetting;
import openonyx.music.TrackInfo;
import openonyx.render.Render2D;
import openonyx.render.RenderSupport_120;
import openonyx.render.group_d.Easings;
import openonyx.render.group_v.IconPaths;
import openonyx.render.group_v.RenderSupport_184;
import openonyx.render.group_v.RoundedShapes;
import openonyx.render.group_v.RoundedShapesData2;
import openonyx.theme.AlphaLevels;
import openonyx.theme.Fonts;
import openonyx.theme.Palette;
import openonyx.theme.ThemeManager;
import openonyx.ui.UiSupport_545;
import org.lwjgl.input.Mouse;
public final class Notifications extends Module {
private RoundedShapesData2 roundedShapesData2;
private static final float X = 8.0F;
private static final float w = 1.0F;
public final NumberSetting z;
private long v;
private static final float s = 34.0F;
private float Z;
private static final int O = -9706613;
public final BooleanSetting progressBar;
private final UiSupport_545 uiSupport_545;
private String x;
private static final float u = 2.0F;
private static final String y = "notifications";
private static final float n = 10.0F;
private static final float Y = 240.0F;
private static final float r = 4.5F;
private float W;
public final NumberSetting scale = new NumberSetting("Scale", 0.85, 0.5, 2.0, 0.05).withSuffix("x").describe("Popup size");
private final Set<Module> modules;
private static final float R = 10.0F;
private static final float p = 130.0F;
private BlockPos blockPos;
private boolean b;
public final NumberSetting positionY;
private static final float F = 14.0F;
private static final float G = 100.0F;
private boolean A;
private float K;
public final NumberSetting maxStack;
private static final float C = 9.0F;
private static final int J = 3;
public final BooleanSetting subtitle;
private static final float c = 5.5F;
private float a;
public final BooleanSetting scaffoldBlocks;
private final RenderSupport_184 renderSupport_184;
private float M;
private boolean L;
public final BooleanSetting bedBreaker;
private static final float m = 5.0F;
public final NumberSetting hold = new NumberSetting("Hold", 3.0, 0.5, 10.0, 0.1).withSuffix("s").describe("How long each popup stays up");
public final BooleanSetting moduleToggles;
public final NumberSetting positionX;
public final BooleanSetting nowPlaying;
private static final float i = 16.0F;
private final List<NotificationsPart> notificationsParts;
private float H;
private boolean e;
public void L(Render2D render2D, float f, float g) {
Notifications notifications1 = this;
float h = notifications1.L();
boolean bl = notifications1.isEnabled() && mc.currentScreen instanceof GuiChat;
notifications1.H();
notifications1.e();
notifications1.L(h);
ArrayList arrayList;
if ((arrayList = new ArrayList<>(notifications1.notificationsParts)).isEmpty() && bl) {
arrayList.add(notifications1.L());
}
Palette palette = ThemeManager.getPalette();
float ix = notifications1.scale.getFloat();
float j;
notifications1.K = (j = notifications1.L(render2D, arrayList)) * ix;
notifications1.Z = (arrayList.size() * 34.0F + Math.max(0, arrayList.size() - 1) * 5.0F) * ix;
if (arrayList.isEmpty()) {
IconPaths.L("notifications");
notifications1.A = notifications1.F();
} else {
float k = f - notifications1.K - 20.0F;
float l = g - notifications1.Z - 20.0F;
notifications1.a = 10.0F + L(notifications1.positionX, k);
notifications1.M = 10.0F + L(notifications1.positionY, l);
IconPaths.L("notifications", notifications1.a, notifications1.M, notifications1.K, notifications1.Z);
boolean bl1 = notifications1.L(bl, k, l, f, g);
if (bl && bl1 && !notifications1.b) {
float[] mx;
if ((mx = notifications1.renderSupport_184.L(true))[0] != 0.0F || mx[1] != 0.0F) {
L(notifications1.positionX, L(notifications1.positionX, k) + mx[0], k);
L(notifications1.positionY, L(notifications1.positionY, l) + mx[1], l);
}
} else {
notifications1.renderSupport_184.L(false);
}
notifications1.a = 10.0F + L(notifications1.positionX, k);
notifications1.M = 10.0F + L(notifications1.positionY, l);
boolean bl3;
Notifications notifications2;
if (bl && bl1) {
bl3 = true;
notifications2 = notifications1;
} else {
bl3 = false;
notifications2 = notifications1;
}
notifications1.uiSupport_545.L(h, bl3, notifications2.b);
if (notifications1.b) {
RoundedShapes.L(render2D, f, g, notifications1.roundedShapesData2);
}
RenderSupport_120.L();
boolean bl2 = notifications1.positionY.getValue() > 50.0;
int px = 0;
render2D.pushMatrix();
render2D.translate(notifications1.a, notifications1.M);
render2D.scaleAround(ix, 0.0F, 0.0F);
for (int nx = 0; px < arrayList.size(); px = nx) {
NotificationsPart notificationsPart = (NotificationsPart)arrayList.get(nx);
int o = bl2 ? arrayList.size() - 1 - nx : nx;
float q = o;
nx++;
notifications1.L(render2D, palette, notificationsPart, q * 39.0F, j);
}
render2D.popMatrix();
}
}
public boolean L(double d, double e) {
return d >= this.a && d < this.a + this.K && ex >= this.M && ex < this.M + this.Z;
}
private float L(Render2D render2D, List<NotificationsPart> list) {
Notifications notifications1 = this;
float f = 130.0F;
for (Iterator iterator1 = iterator = list.iterator(); iterator1.hasNext(); iterator1 = iterator) {
NotificationsPart notificationsPart = (NotificationsPart)iterator.next();
float g = render2D.getTextWidth(Fonts.FONT_STYLE9, notificationsPart.notification.title());
if (notifications1.subtitle.isEnabled() && notificationsPart.notification.message() != null) {
g = Math.max(g, render2D.getTextWidth(Fonts.FONT_STYLE13, notificationsPart.notification.message()));
}
f = Math.max(f, 45.0F + g);
}
return Math.min(f, 240.0F);
}
private boolean L(boolean bl, float f, float g, float h, float i) {
Notifications notifications1 = this;
float j = Minecraft.getScaledMouseX() * h / mc.displayWidth;
float k = ix - Minecraft.getScaledMouseY() * ix / mc.displayHeight - 1.0F;
boolean bl1 = notifications1.F();
boolean bl2 = notifications1.L(j, k);
Notifications notifications2;
if (bl && bl1) {
if (!notifications1.A && bl2) {
notifications1.b = true;
notifications1.H = j - notifications1.a;
notifications1.W = k - notifications1.M;
}
notifications2 = notifications1;
} else {
notifications2 = notifications1;
notifications1.b = false;
notifications1.roundedShapesData2 = RoundedShapes.ROUNDED_SHAPES_DATA2;
}
notifications2.A = bl1;
if (notifications1.b) {
notifications1.roundedShapesData2 = RoundedShapes.L(
j - notifications1.H, k - notifications1.W, notifications1.K, notifications1.Z, h, ix, 10.0F, IconPaths.L("notifications")
);
L(notifications1.positionX, notifications1.roundedShapesData2.x() - 10.0F, f);
L(notifications1.positionY, notifications1.roundedShapesData2.y() - 10.0F, g);
}
return bl2;
}
private NotificationsPart L() {
NotificationsPart notificationsPart = new NotificationsPart(
new Notification("Notifications", "Drag to move", NotificationLevel.INFO), this.hold.getFloat() * 1000.0F
);
notificationsPart.animation.set(1.0F);
return notificationsPart;
}
private void H() {
Notifications notifications1 = this;
if (notifications1.moduleToggles.isEnabled() && OnyxClient.moduleManager != null) {
Iterator iterator = OnyxClient.moduleManager.getModules().iterator();
label46:
while (true) {
Iterator iterator1 = iterator;
while (iterator1.hasNext()) {
Module module;
if ((module = (Module)iterator.next()) == notifications1) {
continue label46;
}
if (module == OnyxClient.moduleManager.clickGUI) {
iterator1 = iterator;
} else {
boolean bl = module.isEnabled();
boolean bl1 = notifications1.modules.contains(module);
if (bl != bl1) {
Notifications notifications2;
if (bl) {
notifications1.modules.add(module);
notifications2 = notifications1;
} else {
notifications1.modules.remove(module);
notifications2 = notifications1;
}
if (notifications2.e) {
Notification notification = new Notification;
String string = module.getName();
String string1;
boolean bl2;
if (bl) {
string1 = "Enabled";
bl2 = bl;
} else {
string1 = "Disabled";
bl2 = bl;
}
notification./* $VF: Unable to resugar constructor */<init>(string, string1, bl2 ? NotificationLevel.SUCCESS : NotificationLevel.INFO);
notifications1.L(notification);
}
continue label46;
}
iterator1 = iterator;
}
}
notifications1.e = true;
return;
}
} else {
notifications1.modules.clear();
notifications1.e = false;
}
}
private void e() {
if (OnyxClient.moduleManager != null) {
this.F();
this.h();
this.l();
}
}
private void k() {
this.L = false;
this.blockPos = null;
this.x = "";
}
private static float L(NumberSetting numberSetting, float f) {
return f <= 0.0F ? 0.0F : (float)(f * numberSetting.getValue() / 100.0);
}
public static void L(String string, NotificationLevel notificationLevel) {
L(string, null, notificationLevel);
}
private void F() {
Notifications notifications1 = this;
Scaffold scaffold = OnyxClient.moduleManager.scaffold;
if (notifications1.scaffoldBlocks.isEnabled() && scaffold != null && scaffold.isEnabled()) {
int ix;
boolean bl = (ix = scaffold.L()) <= notifications1.z.getInt();
if (bl && !notifications1.L) {
Notification notification = new Notification;
String string;
int j;
if (ix <= 0) {
string = "Out of blocks";
j = ix;
} else {
string = ix + " blocks left";
j = ix;
}
notification./* $VF: Unable to resugar constructor */<init>("Scaffold", string, j <= 0 ? NotificationLevel.ERROR : NotificationLevel.WARNING);
notifications1.L(notification);
}
notifications1.L = bl;
} else {
notifications1.L = false;
}
}
private void l() {
Notifications notifications1 = this;
Watermark watermark = OnyxClient.moduleManager.watermark;
if (notifications1.nowPlaying.isEnabled() && watermark != null) {
TrackInfo trackInfo;
if ((trackInfo = watermark.L()) != null && trackInfo.title() != null && !trackInfo.title().isEmpty()) {
if (!trackInfo.title().equals(notifications1.x)) {
notifications1.x = trackInfo.title();
notifications1.L(
new Notification(
trackInfo.title(),
trackInfo.artist() != null && !trackInfo.artist().isEmpty() ? trackInfo.artist() : "Now playing",
NotificationLevel.INFO
)
);
}
} else {
notifications1.x = "";
}
} else {
notifications1.x = "";
}
}
public Notifications() {
super("Notifications", "Popups for module toggles and client events", ModuleCategory.HUD);
this.maxStack = new NumberSetting("Max stack", 5.0, 1.0, 10.0, 1.0).describe("How many popups can be on screen at once");
this.moduleToggles = new BooleanSetting("Module toggles", true).describe("Announce modules turning on and off");
this.scaffoldBlocks = new BooleanSetting("Scaffold blocks", true).describe("Warn when Scaffold is running low on blocks");
this.z = new NumberSetting("Low blocks", 32.0, 1.0, 128.0, 1.0).describe("Count at which the warning goes up").visibleWhen(this.scaffoldBlocks);
this.bedBreaker = new BooleanSetting("Bed breaker", true).describe("Announce when BedBreaker takes a bed down");
this.nowPlaying = new BooleanSetting("Now playing", true).describe("Announce whatever the system starts playing");
this.progressBar = new BooleanSetting("Progress bar", true).describe("Show the time each popup has left");
this.subtitle = new BooleanSetting("Subtitle", true).describe("Show the second line of each popup");
this.positionX = new NumberSetting("Position X", 82.0, 0.0, 100.0, 0.01).visibleWhen(() -> false);
this.positionY = new NumberSetting("Position Y", 8.0, 0.0, 100.0, 0.01).visibleWhen(() -> false);
this.notificationsParts = new ArrayList<>();
this.x = "";
this.modules = Collections.newSetFromMap(new IdentityHashMap<>());
this.uiSupport_545 = new UiSupport_545();
this.renderSupport_184 = new RenderSupport_184();
this.roundedShapesData2 = RoundedShapes.ROUNDED_SHAPES_DATA2;
}
private static void L(NumberSetting numberSetting, float f, float g) {
if (!(g <= 0.0F)) {
numberSetting.setValue(Math.clamp(f / g, 0.0F, 1.0F) * 100.0);
}
}
public static void L(String string, String string1, NotificationLevel notificationLevel) {
String string2 = string;
if (OnyxClient.moduleManager != null) {
Notifications notifications = OnyxClient.moduleManager.notifications;
if (OnyxClient.moduleManager.notifications != null && notifications.isEnabled()) {
notifications.L(new Notification(string2, string1, notificationLevel));
}
}
}
private void L(Render2D render2D, Palette palette, NotificationsPart notificationsPart, float f, float g) {
float h;
if (!((h = notificationsPart.animation.getValue()) <= 0.001F)) {
int ix = notificationsPart.notification.accent() != null ? notificationsPart.notification.accent() : notificationsPart.notification.level().L(palette);
int j = AlphaLevels.L(3, palette);
render2D.pushAlpha(h);
render2D.pushMatrix();
render2D.translate((1.0F - h) * 14.0F, f);
render2D.shadow(0.0F, 0.0F, g, 34.0F, 12.0F, 3);
RenderSupport_120.L(render2D, 0.0F, 0.0F, g, 34.0F, 12.0F, j);
render2D.drawIcon(notificationsPart.notification.level().d(), 18.0F, 17.0F, 16.0F, ix);
f = 35.0F;
h = g - f - 10.0F;
boolean bl = this.subtitle.isEnabled() && notificationsPart.notification.message() != null;
String string = render2D.trimToWidth(Fonts.FONT_STYLE9, notificationsPart.notification.title(), h);
Notifications notifications1;
if (bl) {
render2D.drawTextVCentered(Fonts.FONT_STYLE9, string, f, 11.5F, palette.onSurface());
notifications1 = this;
render2D.drawTextVCentered(
Fonts.FONT_STYLE13, render2D.trimToWidth(Fonts.FONT_STYLE13, notificationsPart.notification.message(), h), f, 21.5F, palette.onSurfaceVariant()
);
} else {
render2D.drawTextVCentered(Fonts.FONT_STYLE9, string, f, 17.0F, palette.onSurface());
notifications1 = this;
}
if (notifications1.progressBar.isEnabled() && notificationsPart.e > 0.0F) {
float k = Math.clamp(notificationsPart.H / notificationsPart.e, 0.0F, 1.0F);
render2D.roundedRect(10.0F, 29.0F, (g - 20.0F) * k, 2.0F, Float.MAX_VALUE, ThemeManager.withAlpha(ix, 0.85F));
}
this.uiSupport_545.L(render2D, 0.0F, 0.0F, g, 34.0F, 12.0F, palette.onSurface());
render2D.roundedOutline(0.0F, 0.0F, g, 34.0F, 12.0F, 1.0F, palette.outlineVariant());
render2D.popMatrix();
render2D.popAlpha();
}
}
private void h() {
Notifications notifications1 = this;
BedBreaker bedBreakerx = OnyxClient.moduleManager.bedBreaker;
if (notifications1.bedBreaker.isEnabled() && bedBreakerx != null && bedBreakerx.isEnabled() && mc.theWorld != null) {
BlockPos blockPosx;
if ((blockPosx = bedBreakerx.getBlockPos()) != null) {
notifications1.blockPos = blockPosx;
} else {
if (notifications1.blockPos != null && !(mc.theWorld.getBlockState(notifications1.blockPos).getBlock() instanceof BlockBed)) {
notifications1.L(new Notification("BedBreaker", "Bed broken", NotificationLevel.SUCCESS, -9706613));
}
notifications1.blockPos = null;
}
} else {
notifications1.blockPos = null;
}
}
private boolean F() {
return Mouse.isButtonDown(0);
}
private float L() {
Notifications notifications1 = this;
long l = System.nanoTime();
float f = notifications1.v == 0L ? 16.0F : Math.min((float)(l - notifications1.v) / 1000000.0F, 100.0F);
notifications1.v = l;
return f;
}
@Override
protected void onEnable() {
this.e = false;
this.v = 0L;
}
public boolean l() {
return mc.thePlayer != null && mc.theWorld != null && this.isEnabled();
}
@Override
protected void onDisable() {
this.notificationsParts.clear();
this.modules.clear();
this.k();
this.e = false;
this.b = false;
IconPaths.L("notifications");
}
private void L(Notification notification) {
Notifications notifications1 = this;
this.notificationsParts.add(new NotificationsPart(notification, this.hold.getFloat() * 1000.0F));
while (notifications1.notificationsParts.size() > this.maxStack.getInt()) {
notifications1 = this;
this.notificationsParts.remove(0);
}
}
private void L(float f) {
this.notificationsParts.removeIf(notificationsPart -> {
float g = f;
notificationsPart.H -= g;
boolean bl = notificationsPart.H <= 0.0F;
float ix;
boolean bl1;
if (bl) {
ix = 0.0F;
bl1 = bl;
} else {
ix = 1.0F;
bl1 = bl;
}
float h;
boolean bl2;
if (bl1) {
h = 200.0F;
bl2 = bl;
} else {
h = 300.0F;
bl2 = bl;
}
notificationsPart.animation.animateTo(ix, h, bl2 ? Easings.EASING : Easings.EASING7);
notificationsPart.animation.update(g);
return bl && notificationsPart.animation.isFinished() && notificationsPart.animation.getValue() <= 0.0F;
});
}
}
@@ -0,0 +1,17 @@
package openonyx.features.hud;
import openonyx.features.hud.group_d.Notification;
import openonyx.render.group_d.Animation;
final class NotificationsPart {
private final Animation animation = new Animation(0.0F);
private final Notification notification;
private float H;
private final float e;
private NotificationsPart(Notification notification, float f) {
this.notification = notificationx;
this.e = f;
this.H = f;
}
}
+14
View File
@@ -0,0 +1,14 @@
package openonyx.features.hud;
public enum Position {
SCREEN,
WORLD;
private static Position[] L() {
Position[] positions = new Position[2];
boolean bl = true;
positions[0] = SCREEN;
positions[1] = WORLD;
return positions;
}
}
+489
View File
@@ -0,0 +1,489 @@
package openonyx.features.hud;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.resources.I18n;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import openonyx.features.Module;
import openonyx.features.ModuleCategory;
import openonyx.history.internal.BooleanSetting;
import openonyx.history.internal.EnumSetting;
import openonyx.history.internal.NumberSetting;
import openonyx.render.Render2D;
import openonyx.render.RenderSupport_120;
import openonyx.render.group_d.Animation;
import openonyx.render.group_d.Easings;
import openonyx.render.group_v.IconPaths;
import openonyx.render.group_v.RenderSupport_184;
import openonyx.render.group_v.RoundedShapes;
import openonyx.render.group_v.RoundedShapesData2;
import openonyx.theme.AlphaLevels;
import openonyx.theme.Fonts;
import openonyx.theme.Palette;
import openonyx.theme.ThemeManager;
import openonyx.ui.UiSupport_545;
import org.lwjgl.input.Mouse;
public final class PotionHUD extends Module {
private RoundedShapesData2 roundedShapesData2;
private static final float S = 3.0F;
private static final int o = 200;
private final UiSupport_545 uiSupport_545;
private static final float X = 10.0F;
private final Animation animation;
private static final float z = 100.0F;
public final EnumSetting<SortMode> sort;
public final BooleanSetting icons;
public final BooleanSetting hideAmbient;
private float O;
private static final float N = 5.0F;
private static final float q = 10.0F;
public final BooleanSetting x;
private boolean u;
public final NumberSetting y;
private static final float n = 5.0F;
private static final float Y = 12.0F;
private float r;
private final Animation animation2;
private static final float P = 6.0F;
private static final float V = 5.0F;
private float R;
private float p;
private static final float t = 1.0F;
private static final float b = 1.0F;
private static final float E = 0.94F;
private static final float F = 18.0F;
private long G;
private boolean A;
private final Map<Integer, PotionHUDPart> potionHUDPartMap;
private static final float B = 16.0F;
private final Animation animation3;
private static final float J = 110.0F;
private static final float D = 6.0F;
private final RenderSupport_184 renderSupport_184;
private static final int a = 3;
private float k;
public final BooleanSetting duration;
public final BooleanSetting potionColor;
private static final ResourceLocation RESOURCE_LOCATION = new ResourceLocation("textures/gui/container/inventory.png");
private static final float j = 31.0F;
private boolean m;
public final BooleanSetting lowTimeWarning;
public final NumberSetting scale = new NumberSetting("Scale", 0.85, 0.5, 2.0, 0.05).withSuffix("x").describe("Potion list size");
private static final float I = 20.0F;
public final NumberSetting positionX;
private static final float i = 4.0F;
private static final String f = "potions";
private float H;
private static final String[] e;
private boolean L(boolean bl, float f, float g, float h, float i) {
PotionHUD potionHUD1 = this;
float jx = Minecraft.getScaledMouseX() * h / mc.displayWidth;
float kx = ix - Minecraft.getScaledMouseY() * ix / mc.displayHeight - 1.0F;
boolean bl1 = potionHUD1.l();
boolean bl2 = potionHUD1.L(jx, kx);
PotionHUD potionHUD2;
if (bl && bl1) {
if (!potionHUD1.u && bl2) {
potionHUD1.m = true;
potionHUD1.H = jx - potionHUD1.p;
potionHUD1.R = kx - potionHUD1.r;
}
potionHUD2 = potionHUD1;
} else {
potionHUD2 = potionHUD1;
potionHUD1.m = false;
potionHUD1.roundedShapesData2 = RoundedShapes.ROUNDED_SHAPES_DATA2;
}
potionHUD2.u = bl1;
if (potionHUD1.m) {
potionHUD1.roundedShapesData2 = RoundedShapes.L(jx - potionHUD1.H, kx - potionHUD1.R, potionHUD1.O, potionHUD1.k, h, ix, 10.0F, IconPaths.L("potions"));
L(potionHUD1.positionX, potionHUD1.roundedShapesData2.x() - 10.0F, fx);
L(potionHUD1.y, potionHUD1.roundedShapesData2.y() - 10.0F, g);
}
return bl2;
}
@Override
protected void onEnable() {
this.A = false;
this.G = 0L;
}
public void L(Render2D render2D, float f, float g) {
PotionHUD potionHUD1 = this;
float h = potionHUD1.L();
boolean bl = potionHUD1.isEnabled() && mc.currentScreen instanceof GuiChat;
List list;
boolean bl2 = potionHUD1.L(list = potionHUD1.L(bl), h);
float nx;
boolean bl3;
if (bl2) {
nx = 1.0F;
bl3 = bl2;
} else {
nx = 0.0F;
bl3 = bl2;
}
float mx;
boolean bl4;
if (bl3) {
mx = 300.0F;
bl4 = bl2;
} else {
mx = 200.0F;
bl4 = bl2;
}
potionHUD1.animation2.animateTo(nx, mx, bl4 ? Easings.EASING7 : Easings.EASING);
potionHUD1.animation2.update(h);
if (potionHUD1.potionHUDPartMap.isEmpty() && potionHUD1.animation2.isFinished() && potionHUD1.animation2.getValue() <= 0.0F) {
potionHUD1.h();
potionHUD1.O = 0.0F;
potionHUD1.k = 0.0F;
potionHUD1.u = potionHUD1.l();
} else {
Palette palette = ThemeManager.getPalette();
potionHUD1.L(render2D, list, h);
float ix = potionHUD1.scale.getFloat() * (0.94F + 0.060000002F * potionHUD1.animation2.getValue());
potionHUD1.O = potionHUD1.animation.getValue() * ix;
potionHUD1.k = potionHUD1.animation3.getValue() * ix;
float jx = fx - potionHUD1.O - 20.0F;
float kx = g - potionHUD1.k - 20.0F;
potionHUD1.p = 10.0F + L(potionHUD1.positionX, jx);
potionHUD1.r = 10.0F + L(potionHUD1.y, kx);
IconPaths.L("potions", potionHUD1.p, potionHUD1.r, potionHUD1.O, potionHUD1.k);
boolean bl1 = potionHUD1.L(bl, jx, kx, fx, g);
if (bl && bl1 && !potionHUD1.m) {
float[] l;
if ((l = potionHUD1.renderSupport_184.L(true))[0] != 0.0F || l[1] != 0.0F) {
L(potionHUD1.positionX, L(potionHUD1.positionX, jx) + l[0], jx);
L(potionHUD1.y, L(potionHUD1.y, kx) + l[1], kx);
}
} else {
potionHUD1.renderSupport_184.L(false);
}
potionHUD1.p = 10.0F + L(potionHUD1.positionX, jx);
potionHUD1.r = 10.0F + L(potionHUD1.y, kx);
PotionHUD potionHUD2;
if (bl && bl1) {
bl3 = true;
potionHUD2 = potionHUD1;
} else {
bl3 = false;
potionHUD2 = potionHUD1;
}
potionHUD1.uiSupport_545.L(h, bl3, potionHUD2.m);
if (potionHUD1.m) {
RoundedShapes.L(render2D, fx, g, potionHUD1.roundedShapesData2);
}
RenderSupport_120.L();
render2D.pushAlpha(potionHUD1.animation2.getValue());
render2D.pushMatrix();
render2D.translate(potionHUD1.p, potionHUD1.r + (1.0F - potionHUD1.animation2.getValue()) * 5.0F);
render2D.scaleAround(ix, 0.0F, 0.0F);
potionHUD1.L(render2D, palette, list);
render2D.popMatrix();
render2D.popAlpha();
potionHUD1.h();
}
}
private static void L(NumberSetting numberSetting, float f, float g) {
if (!(g <= 0.0F)) {
numberSetting.setValue(Math.clamp(fx / g, 0.0F, 1.0F) * 100.0);
}
}
static {
String[] strings = new String[8];
boolean bl = true;
strings[0] = "";
strings[1] = "II";
strings[2] = "III";
strings[3] = "IV";
strings[4] = "V";
strings[5] = "VI";
strings[6] = "VII";
strings[7] = "VIII";
e = strings;
}
private void L(Render2D render2D, List<PotionHUDData> list, float f) {
PotionHUD potionHUD1 = this;
float g = 29.0F + render2D.getTextWidth(Fonts.FONT_STYLE9, "Potions");
Iterator iterator;
for (Iterator iterator1 = iterator = list.iterator(); iterator1.hasNext(); iterator1 = iterator) {
PotionHUDData potionHUDData = (PotionHUDData)iterator.next();
float h = Math.min(render2D.getTextWidth(Fonts.FONT_STYLE8, potionHUD1.D(potionHUDData)), 110.0F);
float ix = 18.0F + h;
if (potionHUD1.icons.isEnabled()) {
ix += 18.0F;
}
if (potionHUD1.duration.isEnabled()) {
ix += 10.0F + render2D.getTextWidth(Fonts.FONT_STYLE8, potionHUD1.d(potionHUDData));
}
g = Math.max(g, ix);
}
int jx = list.size();
float kx = 37.0F + jx * 20.0F + Math.max(0, jx - 1) * 4.0F;
potionHUD1.animation.animateTo(g, 300.0F, Easings.EASING2);
potionHUD1.animation3.animateTo(kx, 300.0F, Easings.EASING2);
potionHUD1.animation.update(fx);
potionHUD1.animation3.update(fx);
}
private String D(PotionHUDData potionHUDData) {
String string = this.L(potionHUDData);
if (this.x.isEnabled() && potionHUDData.effect() != null) {
int ix;
return (ix = potionHUDData.effect().getAmplifier()) > 0 && ix < e.length
? new StringBuilder().insert(0, string).append(" ").append(e[ix]).toString()
: string;
} else {
return string;
}
}
private void L(Render2D render2D, Palette palette, PotionHUDData potionHUDData, float f, float g) {
float h = 6.0F;
int ix = potionHUDData.potion() == null ? palette.primary() : 0xFF000000 | potionHUDData.potion().getLiquidColor();
if (this.icons.isEnabled()) {
if (this.potionColor.isEnabled()) {
render2D.roundedRect(6.0F, fx + 1.0F, 18.0F, 18.0F, 4.0F, ThemeManager.withAlpha(ix, 0.22F));
}
if (potionHUDData.potion() != null && potionHUDData.potion().hasStatusIcon()) {
int jx = potionHUDData.potion().getStatusIconIndex();
render2D.L(RESOURCE_LOCATION, 7.0F, fx + 1.0F + 1.0F, 16.0F, 16.0F, jx % 8 * 18, 198 + jx / 8 * 18, 18.0F, 18.0F, 256, 256);
}
h += 24.0F;
}
String string = render2D.trimToWidth(Fonts.FONT_STYLE8, this.D(potionHUDData), 110.0F);
render2D.drawTextVCentered(Fonts.FONT_STYLE8, string, h, fx + 10.0F, this.potionColor.isEnabled() ? ix : palette.onSurface());
if (this.duration.isEnabled()) {
boolean bl = this.lowTimeWarning.isEnabled()
&& potionHUDData.effect() != null
&& !potionHUDData.effect().getIsPotionDurationMax()
&& potionHUDData.effect().getDuration() < 200;
render2D.drawTextRightVCentered(Fonts.FONT_STYLE8, this.d(potionHUDData), g - 6.0F, fx + 10.0F, bl ? palette.error() : palette.onSurfaceVariant());
}
}
private boolean l() {
return Mouse.isButtonDown(0);
}
private String d(PotionHUDData potionHUDData) {
if (potionHUDData.effect() == null) {
return "0:00";
} else {
return potionHUDData.effect().getIsPotionDurationMax() ? "**:**" : Potion.getDurationString(potionHUDData.effect());
}
}
private boolean L(List<PotionHUDData> list, float f) {
PotionHUD potionHUD1 = this;
boolean bl = false;
for (Iterator iterator1 = iterator = list.iterator(); iterator1.hasNext(); bl = true) {
PotionHUDData potionHUDData = (PotionHUDData)iterator.next();
PotionHUDPart potionHUDPart = potionHUD1.potionHUDPartMap.computeIfAbsent(potionHUDData.id(), integer -> new PotionHUDPart());
iterator1 = iterator;
potionHUDPart.e = true;
potionHUDPart.animation.animateTo(1.0F, 150.0F, Easings.EASING7);
potionHUDPart.animation.update(fx);
}
potionHUD1.potionHUDPartMap.entrySet().removeIf(entry -> {
PotionHUDPart potionHUDPart1;
if (!(potionHUDPart1 = entry.getValue()).e) {
potionHUDPart1.animation.animateTo(0.0F, 100.0F, Easings.EASING);
potionHUDPart1.animation.update(fx);
}
potionHUDPart1.e = false;
return potionHUDPart1.animation.isFinished() && potionHUDPart1.animation.getValue() <= 0.0F && potionHUDPart1.animation.getTarget() <= 0.0F;
});
return bl;
}
@Override
protected void onDisable() {
this.A = true;
this.m = false;
}
private Comparator<PotionHUDData> L() {
switch ((SortMode)this.sort.getValue()) {
case DURATION:
while (false) {
}
return Comparator.comparingInt(potionHUDData -> potionHUDData.effect() == null ? Integer.MAX_VALUE : potionHUDData.effect().getDuration());
case LEVEL:
return Comparator.comparing(potionHUDData -> {
if (potionHUDData.potion() == null) {
return "Effect";
}
String string = potionHUDData.potion().getName();
Object[] objects = new Object[0];
boolean bl = true;
return I18n.format(string, objects);
}, String.CASE_INSENSITIVE_ORDER);
case NAME:
return Comparator.<PotionHUDData>comparingInt(potionHUDData -> potionHUDData.effect() == null ? 0 : -potionHUDData.effect().getAmplifier())
.thenComparing(potionHUDData -> {
if (potionHUDData.potion() == null) {
return "Effect";
}
String string = potionHUDData.potion().getName();
Object[] objects = new Object[0];
boolean bl = true;
return I18n.format(string, objects);
}, String.CASE_INSENSITIVE_ORDER);
default:
throw new MatchException(null, null);
}
}
public PotionHUD() {
super("PotionHUD", "Shows your active potion effects", ModuleCategory.HUD);
this.sort = new EnumSetting<>("Sort", SortMode.DURATION).describe("Row order");
this.icons = new BooleanSetting("Icons", true).describe("Show the vanilla effect icon");
this.duration = new BooleanSetting("Duration", true).describe("Show the time remaining");
this.x = new BooleanSetting("Amplifier", true).describe("Show the effect level as a roman numeral");
this.potionColor = new BooleanSetting("Potion color", true).describe("Tint each row with the potion's own colour");
this.lowTimeWarning = new BooleanSetting("Low time warning", true).describe("Turn the timer red as an effect runs out");
this.hideAmbient = new BooleanSetting("Hide ambient", false).describe("Skip beacon effects");
this.positionX = new NumberSetting("Position X", 6.78, 0.0, 100.0, 0.01).visibleWhen(() -> false);
this.y = new NumberSetting("Position Y", 45.0, 0.0, 100.0, 0.01).visibleWhen(() -> false);
this.potionHUDPartMap = new HashMap<>();
this.animation2 = new Animation(0.0F);
this.animation = new Animation(36.0F);
this.animation3 = new Animation(57.0F);
this.uiSupport_545 = new UiSupport_545();
this.roundedShapesData2 = RoundedShapes.ROUNDED_SHAPES_DATA2;
this.renderSupport_184 = new RenderSupport_184();
}
public boolean L(double d, double e) {
return d >= this.p && d < this.p + this.O && ex >= this.r && ex < this.r + this.k;
}
private void L(Render2D render2D, Palette palette, List<PotionHUDData> list) {
PotionHUD potionHUD1 = this;
float kx = potionHUD1.animation.getValue();
float fx = potionHUD1.animation3.getValue();
int ix = AlphaLevels.L(3, palette);
render2D.shadow(0.0F, 0.0F, kx, fx, 12.0F, 3);
RenderSupport_120.L(render2D, 0.0F, 0.0F, kx, fx, 12.0F, ix);
float h = 14.0F;
render2D.drawIcon("\uea4b", 12.0F, h, 12.0F, palette.primary());
render2D.drawTextVCentered(Fonts.FONT_STYLE9, "Potions", 23.0F, h, palette.onSurface());
render2D.rect(6.0F, 25.0F, kx - 12.0F, 1.0F, ThemeManager.withAlpha(palette.outlineVariant(), 0.7F));
float jx = 31.0F;
Iterator iterator;
for (Iterator iterator1 = iterator = list.iterator(); iterator1.hasNext(); jx += 24.0F) {
PotionHUDData potionHUDData = (PotionHUDData)iterator.next();
PotionHUDPart potionHUDPart;
float g = (potionHUDPart = potionHUD1.potionHUDPartMap.get(potionHUDData.id())) == null ? 1.0F : potionHUDPart.animation.getValue();
iterator1 = iterator;
render2D.pushAlpha(g);
render2D.pushMatrix();
render2D.translate((1.0F - g) * 5.0F, 0.0F);
potionHUD1.L(render2D, palette, potionHUDData, jx, kx);
render2D.popMatrix();
render2D.popAlpha();
}
potionHUD1.uiSupport_545.L(render2D, 0.0F, 0.0F, kx, fx, 12.0F, palette.onSurface());
render2D.roundedOutline(0.0F, 0.0F, kx, fx, 12.0F, 1.0F, palette.outlineVariant());
}
private float L() {
PotionHUD potionHUD1 = this;
long l = System.nanoTime();
float fx = potionHUD1.G == 0L ? 16.0F : Math.min((float)(l - potionHUD1.G) / 1000000.0F, 100.0F);
potionHUD1.G = l;
return fx;
}
public boolean I() {
return mc.thePlayer != null && mc.theWorld != null && (this.isEnabled() || this.A);
}
private List<PotionHUDData> L(boolean bl) {
PotionHUD potionHUD1 = this;
ArrayList arrayList = new ArrayList();
if (potionHUD1.isEnabled() && mc.thePlayer != null) {
Iterator iterator;
Iterator iterator1 = iterator = new ArrayList<>(mc.thePlayer.getActivePotionEffects()).iterator();
while (iterator1.hasNext()) {
PotionEffect potionEffect;
if ((potionEffect = (PotionEffect)iterator.next()) == null) {
iterator1 = iterator;
} else if (potionHUD1.hideAmbient.isEnabled() && potionEffect.getIsAmbient()) {
iterator1 = iterator;
} else {
Potion potion = potionEffect.getPotionID() >= 0 && potionEffect.getPotionID() < Potion.potionTypes.length
? Potion.potionTypes[potionEffect.getPotionID()]
: null;
if (potion == null) {
iterator1 = iterator;
} else {
arrayList.add(new PotionHUDData(potionEffect.getPotionID(), potion, potionEffect));
iterator1 = iterator;
}
}
}
}
if (arrayList.isEmpty() && bl) {
arrayList.add(new PotionHUDData(-1, null, null));
}
arrayList.sort(potionHUD1.L());
return arrayList;
}
private void h() {
if (!this.isEnabled() && this.potionHUDPartMap.isEmpty() && this.animation2.isFinished() && !(this.animation2.getValue() > 0.0F)) {
this.A = false;
this.G = 0L;
this.O = 0.0F;
this.k = 0.0F;
IconPaths.L("potions");
}
}
private static float L(NumberSetting numberSetting, float f) {
return fx <= 0.0F ? 0.0F : (float)(fx * numberSetting.getValue() / 100.0);
}
}