From 01dfac23ce5a888009b6a865d023a9e094726780 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Sat, 25 Feb 2023 19:53:41 +0900 Subject: - Fix GuiDisplayer not working sometimes Signed-off-by: syeyoung --- .../dungeonsguide/launcher/gui/screen/GuiDisplayer.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiDisplayer.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiDisplayer.java index ad942ffb..2b6acdb4 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiDisplayer.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiDisplayer.java @@ -35,14 +35,14 @@ public class GuiDisplayer { private Queue guiScreensToShow = new LinkedList<>(); private boolean isMcLoaded; - @SubscribeEvent(priority = EventPriority.LOWEST) public void onGuiOpen(GuiOpenEvent guiOpenEvent) { - if (guiOpenEvent.gui instanceof GuiMainMenu) { - isMcLoaded = true; + isMcLoaded = true; + if (Minecraft.getMinecraft().currentScreen == guiScreensToShow.peek()) { + guiScreensToShow.poll(); } - if (isMcLoaded && !guiScreensToShow.isEmpty()) { - GuiScreen gui = guiScreensToShow.poll(); + if (!guiScreensToShow.isEmpty()) { + GuiScreen gui = guiScreensToShow.peek(); if (gui == null) return; guiOpenEvent.gui = gui; } @@ -53,9 +53,11 @@ public class GuiDisplayer { if (!guiScreensToShow.contains(specialGuiScreen)) guiScreensToShow.add(specialGuiScreen); if (isMcLoaded && Minecraft.getMinecraft().isCallingFromMinecraftThread()) { - Minecraft.getMinecraft().displayGuiScreen(null); + if (guiScreensToShow.size() == 1) + Minecraft.getMinecraft().displayGuiScreen(guiScreensToShow.peek()); } else if (isMcLoaded) { - Minecraft.getMinecraft().addScheduledTask(() -> Minecraft.getMinecraft().displayGuiScreen(null)); + if (guiScreensToShow.size() == 1) + Minecraft.getMinecraft().addScheduledTask(() -> Minecraft.getMinecraft().displayGuiScreen(guiScreensToShow.peek())); } } } -- cgit