aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java
diff options
context:
space:
mode:
authorBuildTools <james.jenour@protonmail.com>2021-07-23 02:44:58 +0800
committerBuildTools <james.jenour@protonmail.com>2021-07-23 02:44:58 +0800
commit9814220f8a621f4c310c5f38c57c6bcab358c707 (patch)
tree59377672fad4cb804841f7b5d641c2ba6948f4f4 /src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java
parent47438cca0b864602b4faa3b56195aff4278b2094 (diff)
downloadnotenoughupdates-9814220f8a621f4c310c5f38c57c6bcab358c707.tar.gz
notenoughupdates-9814220f8a621f4c310c5f38c57c6bcab358c707.tar.bz2
notenoughupdates-9814220f8a621f4c310c5f38c57c6bcab358c707.zip
PRE30
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java
index 48601df3..0aa5e84d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java
@@ -51,9 +51,10 @@ public class BetterContainers {
private static long clickedSlotMillis = 0;
public static long lastRenderMillis = 0;
+ private static int lastInvHashcode = 0;
+ private static int lastHashcodeCheck = 0;
+
public static HashMap<Integer, ItemStack> itemCache = new HashMap<>();
- public static boolean lastUsingCached = false;
- public static boolean usingCached = false;
public static void clickSlot(int slot) {
clickedSlotMillis = System.currentTimeMillis();
@@ -68,22 +69,30 @@ public class BetterContainers {
}
public static void bindHook(TextureManager textureManager, ResourceLocation location) {
+ long currentMillis = System.currentTimeMillis();
+
if(isChestOpen() && NEUEventListener.inventoryLoaded) {
- if((texture != null && lastClickedSlot != getClickedSlot()) ||
- lastUsingCached != getUsingCache() || !loaded) {
- lastUsingCached = getUsingCache();
+ int invHashcode = lastInvHashcode;
+
+ if(currentMillis - lastHashcodeCheck > 50) {
+ Container container = ((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots;
+ invHashcode = container.getInventory().hashCode();
+ }
+
+ if((texture != null && lastClickedSlot != getClickedSlot()) || !loaded || lastInvHashcode != invHashcode) {
+ lastInvHashcode = invHashcode;
lastClickedSlot = getClickedSlot();
generateTex(location);
}
if(texture != null && loaded) {
- lastRenderMillis = System.currentTimeMillis();
+ lastRenderMillis = currentMillis;
GlStateManager.color(1, 1, 1, 1);
textureManager.loadTexture(rl, texture);
textureManager.bindTexture(rl);
return;
}
- } else if(System.currentTimeMillis() - lastRenderMillis < 200 && texture != null) {
+ } else if(currentMillis - lastRenderMillis < 200 && texture != null) {
GlStateManager.color(1, 1, 1, 1);
textureManager.loadTexture(rl, texture);
textureManager.bindTexture(rl);
@@ -94,7 +103,7 @@ public class BetterContainers {
}
public static boolean getUsingCache() {
- return usingCached && System.currentTimeMillis() - lastRenderMillis < 300;
+ return false;
}
public static boolean isBlacklistedInventory() {