diff options
author | Lulonaut <67191924+Lulonaut@users.noreply.github.com> | 2022-09-14 14:33:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-14 14:33:04 +0200 |
commit | 989b633329f00d9dd0b02e2ffc4ccf2a5d18bd30 (patch) | |
tree | e7c5949e39dff281bc893d388453c0e88bfb9199 | |
parent | 12fdc80608962c0ae70e0deb246076c1d40f7d8a (diff) | |
download | NotEnoughUpdates-989b633329f00d9dd0b02e2ffc4ccf2a5d18bd30.tar.gz NotEnoughUpdates-989b633329f00d9dd0b02e2ffc4ccf2a5d18bd30.tar.bz2 NotEnoughUpdates-989b633329f00d9dd0b02e2ffc4ccf2a5d18bd30.zip |
Fix tab overlay rendering in some guis (#278)
* Don't render overlays when pressing tab in some guis
* Made it only show if no gui screen is open
Co-authored-by: nopo <nopotheemail@gmail.com>
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/overlays/TextTabOverlay.java | 25 |
1 files changed, 21 insertions, 4 deletions
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 69a0cd00..8073062c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextTabOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextTabOverlay.java @@ -36,12 +36,29 @@ public abstract class TextTabOverlay extends TextOverlay { } private boolean lastTabState = false; + private boolean shouldUpdateOverlay = true; - public void realTick() { - boolean currentTabState = Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindPlayerList.getKeyCode()); - if (lastTabState != currentTabState) { - lastTabState = currentTabState; + @Override + public void tick() { + if (shouldUpdateOverlay) { update(); } } + + public void realTick() { + shouldUpdateOverlay = shouldUpdate(); + if (shouldUpdateOverlay) { + boolean currentTabState = + Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindPlayerList.getKeyCode()); + if (lastTabState != currentTabState) { + lastTabState = currentTabState; + update(); + } + } + } + + private boolean shouldUpdate() { + //prevent rendering unless no gui is open + return Minecraft.getMinecraft().currentScreen == null; + } } |