From 1797440fcdc21c816c3d3a472f261c4e6da6f024 Mon Sep 17 00:00:00 2001 From: heyngra Date: Fri, 9 Dec 2022 12:45:03 +0100 Subject: Fix mining overlay not update while chat is opened (and more) (#481) Fixes undefined --- .../moulberry/notenoughupdates/overlays/MiningOverlay.java | 7 ++++--- .../moulberry/notenoughupdates/overlays/TextTabOverlay.java | 13 +++++-------- .../moulberry/notenoughupdates/overlays/TimersOverlay.java | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java index 025d4e21..f25407b6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java @@ -31,6 +31,7 @@ import io.github.moulberry.notenoughupdates.util.StarCultCalculator; import io.github.moulberry.notenoughupdates.util.TabListUtils; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiChat; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.init.Items; @@ -450,8 +451,8 @@ public class MiningOverlay extends TextTabOverlay { if (starCultDisplay) { if(overlayStrings == null) overlayStrings = new ArrayList<>(); - if (!NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayOnlyShowTab || - Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindPlayerList.getKeyCode())) { + if (!NotEnoughUpdates.INSTANCE.config.mining.starCultDisplayOnlyShowTab || + lastTabState) { if (NotEnoughUpdates.INSTANCE.config.mining.starCultDisplayEnabledLocations == 1 && !SBInfo.getInstance().isInDungeon) { overlayStrings.add( @@ -469,7 +470,7 @@ public class MiningOverlay extends TextTabOverlay { if(overlayStrings == null) overlayStrings = new ArrayList<>(); if (!NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayOnlyShowTab || - Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindPlayerList.getKeyCode())) { + lastTabState) { if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayEnabledLocations == 1 && !SBInfo.getInstance().isInDungeon) { overlayStrings.addAll(getForgeStrings(profileConfig.forgeItems)); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextTabOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextTabOverlay.java index fa263db7..c64fe21e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextTabOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextTabOverlay.java @@ -36,7 +36,7 @@ public abstract class TextTabOverlay extends TextOverlay { super(position, dummyStrings, styleSupplier); } - private boolean lastTabState = false; + protected boolean lastTabState = false; private boolean shouldUpdateOverlay = true; @Override @@ -48,7 +48,7 @@ public abstract class TextTabOverlay extends TextOverlay { public void realTick() { shouldUpdateOverlay = shouldUpdate(); - if (shouldUpdateOverlay) { + if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChat)) { int keycode = Minecraft.getMinecraft().gameSettings.keyBindPlayerList.getKeyCode(); boolean currentTabState; if (keycode > 0) { @@ -58,17 +58,14 @@ public abstract class TextTabOverlay extends TextOverlay { } if (lastTabState != currentTabState) { lastTabState = currentTabState; - update(); } + } else lastTabState = false; // disallow showing overlays that use tab while having chat open + if (shouldUpdateOverlay) { + update(); } } private boolean shouldUpdate() { - //prevent rendering when tab completing a command - if (Minecraft.getMinecraft().currentScreen instanceof GuiChat) { - return false; - } - //prevent rendering when tab completing in ah search overlay if (AuctionSearchOverlay.shouldReplace()) { return false; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java index a276f207..b35f06dc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -242,7 +242,7 @@ public class TimersOverlay extends TextTabOverlay { if (hidden == null) return; if (NotEnoughUpdates.INSTANCE.config.miscOverlays.todoOverlayOnlyShowTab && - !Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindPlayerList.getKeyCode())) { + !lastTabState) { overlayStrings = null; return; } -- cgit