From f05ca3fd031e2c9635dcfe14c223079325fa4ee0 Mon Sep 17 00:00:00 2001 From: ThatGravyBoat <thatgravyboat@gmail.com> Date: Tue, 21 Nov 2023 23:25:22 -0330 Subject: [PATCH] Fix progress bar not capping when over 100% --- .../terrarium/heracles/api/client/WidgetUtils.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/earth/terrarium/heracles/api/client/WidgetUtils.java b/common/src/main/java/earth/terrarium/heracles/api/client/WidgetUtils.java index 9a1e1ee7..e9641051 100644 --- a/common/src/main/java/earth/terrarium/heracles/api/client/WidgetUtils.java +++ b/common/src/main/java/earth/terrarium/heracles/api/client/WidgetUtils.java @@ -51,7 +51,7 @@ public static void drawStatusSummaryBackground(GuiGraphics graphics, int x, int public static <T extends Tag> void drawProgressBar(GuiGraphics graphics, int minX, int minY, int maxX, int maxY, QuestTask<?, T, ?> task, TaskProgress<T> progress) { RenderSystem.enableBlend(); graphics.blitNineSliced(TEXTURE, minX, minY, maxX - minX, maxY - minY, 3, 128, 8, 0, 168 + (progress.isComplete() ? 8 : 0)); - float fill = task.getProgress(progress.progress()); + float fill = Math.min(1f, task.getProgress(progress.progress())); if (fill != 0.0 && !progress.isComplete()) { int progressWidth = (int) ((maxX - minX) * fill); graphics.blitNineSliced(TEXTURE, minX, minY, progressWidth, maxY - minY, 3, 128, 8, 0, 168 + 8 + 8); @@ -70,8 +70,8 @@ public static <T extends Tag> void drawProgressText(GuiGraphics graphics, int x, } public static void drawEntity(GuiGraphics graphics, int x, int y, int size, Entity entity) { - y += size / 2f; - x += size / 4f; + y += (int) (size / 2f); + x += (int) (size / 4f); Minecraft mc = Minecraft.getInstance(); float scaledSize = 25 / (Math.max(entity.getBbWidth(), entity.getBbHeight())); if (Math.abs(entity.getBbHeight() - entity.getBbWidth()) > 5) { @@ -82,8 +82,8 @@ public static void drawEntity(GuiGraphics graphics, int x, int y, int size, Enti scaledSize *= size / 40f; - x += size / 40f < 1 ? -6 * size / 40f : 5 * size / 40f; - y += size / 40f < 1 ? -6 * size / 40f : 8 * size / 35f; + x += (int) (size / 40f < 1 ? -6 * size / 40f : 5 * size / 40f); + y += (int) (size / 40f < 1 ? -6 * size / 40f : 8 * size / 35f); float rot = 45f; if (entity instanceof EnderDragon) {