From 5d2aa40fdee044c0579f426bff279b9d631e306f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 17 Aug 2022 09:38:24 +0200 Subject: Probably fixing Lag spikes (#229) * using method getOpenChestName instead of field lastOpenContainerName * probably fixing lag spikes in power stone stats display * using new getOpenChestName in EnchantingSolvers --- .../moulberry/notenoughupdates/util/SBInfo.java | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java index 9419be4f..8bd7c581 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -88,7 +88,11 @@ public class SBInfo { public Date currentTimeDate = null; - public String lastOpenContainerName = ""; + /** + * Use Utils.getOpenChestName() instead + */ + @Deprecated + public String currentlyOpenChestName = ""; private long lastManualLocRaw = -1; private long lastLocRaw = -1; @@ -131,19 +135,18 @@ public class SBInfo { GuiChest chest = (GuiChest) event.gui; ContainerChest container = (ContainerChest) chest.inventorySlots; - lastOpenContainerName = container.getLowerChestInventory().getDisplayName().getUnformattedText(); + currentlyOpenChestName = container.getLowerChestInventory().getDisplayName().getUnformattedText(); + } else { + currentlyOpenChestName = ""; } } @SubscribeEvent public void onGuiTick(TickEvent event) { if (tickCount++ % 10 != 0) return; - GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen; - if (currentScreen instanceof GuiChest) { - ContainerChest container = (ContainerChest) ((GuiChest) currentScreen).inventorySlots; - if ("Profile Management".equals(container.getLowerChestInventory().getDisplayName().getUnformattedText())) { - updateProfileInformation(container); - } + if (Utils.getOpenChestName().equals("Profile Management")) { + ContainerChest container = (ContainerChest) ((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots; + updateProfileInformation(container); } } @@ -226,7 +229,7 @@ public class SBInfo { locraw = null; this.setLocation(null); joinedWorld = System.currentTimeMillis(); - lastOpenContainerName = ""; + currentlyOpenChestName = ""; hasNewTab = false; } -- cgit