diff --git a/src/api/java/baritone/api/utils/Helper.java b/src/api/java/baritone/api/utils/Helper.java index 1fe5b421..324efbef 100755 --- a/src/api/java/baritone/api/utils/Helper.java +++ b/src/api/java/baritone/api/utils/Helper.java @@ -71,7 +71,7 @@ public interface Helper { * @param message The message to display in the popup */ default void logToast(ITextComponent title, ITextComponent message) { - BaritoneToast.addOrUpdate(mc.getToastGui(), title, message, BaritoneAPI.getSettings().toastTimer.value); + mc.addScheduledTask(() -> BaritoneToast.addOrUpdate(mc.getToastGui(), title, message, BaritoneAPI.getSettings().toastTimer.value)); } /** diff --git a/src/api/java/baritone/api/utils/gui/BaritoneToast.java b/src/api/java/baritone/api/utils/gui/BaritoneToast.java index fa3d7739..82df6741 100644 --- a/src/api/java/baritone/api/utils/gui/BaritoneToast.java +++ b/src/api/java/baritone/api/utils/gui/BaritoneToast.java @@ -23,25 +23,21 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; -public class BaritoneToast implements IToast -{ +public class BaritoneToast implements IToast { private String title; private String subtitle; private long firstDrawTime; private boolean newDisplay; private long totalShowTime; - public BaritoneToast(ITextComponent titleComponent, ITextComponent subtitleComponent, long totalShowTime) - { + public BaritoneToast(ITextComponent titleComponent, ITextComponent subtitleComponent, long totalShowTime) { this.title = titleComponent.getFormattedText(); this.subtitle = subtitleComponent == null ? null : subtitleComponent.getFormattedText(); this.totalShowTime = totalShowTime; } - public Visibility draw(GuiToast toastGui, long delta) - { - if (this.newDisplay) - { + public Visibility draw(GuiToast toastGui, long delta) { + if (this.newDisplay) { this.firstDrawTime = delta; this.newDisplay = false; } @@ -50,12 +46,9 @@ public class BaritoneToast implements IToast GlStateManager.color(1.0F, 1.0F, 1.0F, 255.0f); toastGui.drawTexturedModalRect(0, 0, 0, 32, 160, 32); - if (this.subtitle == null) - { + if (this.subtitle == null) { toastGui.getMinecraft().fontRenderer.drawString(this.title, 18, 12, -11534256); - } - else - { + } else { toastGui.getMinecraft().fontRenderer.drawString(this.title, 18, 7, -11534256); toastGui.getMinecraft().fontRenderer.drawString(this.subtitle, 18, 18, -16777216); } @@ -63,23 +56,18 @@ public class BaritoneToast implements IToast return delta - this.firstDrawTime < totalShowTime ? Visibility.SHOW : Visibility.HIDE; } - public void setDisplayedText(ITextComponent titleComponent, ITextComponent subtitleComponent) - { + public void setDisplayedText(ITextComponent titleComponent, ITextComponent subtitleComponent) { this.title = titleComponent.getFormattedText(); this.subtitle = subtitleComponent == null ? null : subtitleComponent.getFormattedText(); this.newDisplay = true; } - public static void addOrUpdate(GuiToast toast, ITextComponent title, ITextComponent subtitle, long totalShowTime) - { + public static void addOrUpdate(GuiToast toast, ITextComponent title, ITextComponent subtitle, long totalShowTime) { BaritoneToast baritonetoast = toast.getToast(BaritoneToast.class, new Object()); - if (baritonetoast == null) - { + if (baritonetoast == null) { toast.add(new BaritoneToast(title, subtitle, totalShowTime)); - } - else - { + } else { baritonetoast.setDisplayedText(title, subtitle); } }