diff options
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures')
32 files changed, 9326 insertions, 8380 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java index 1b418b86..c76a22b4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java @@ -24,216 +24,270 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class AuctionBINWarning extends GuiElement { - private static final AuctionBINWarning INSTANCE = new AuctionBINWarning(); - - public static AuctionBINWarning getInstance() { - return INSTANCE; - } - - private static final Pattern ITEM_PRICE_REGEX = Pattern.compile("\u00a7fItem price: \u00a76([0-9,]+) coins"); - - private boolean showWarning = false; - private List<String> sellingTooltip; - private String sellingName; - private int sellingPrice; - private int lowestPrice; - - private boolean shouldPerformCheck() { - if (!NotEnoughUpdates.INSTANCE.config.ahTweaks.enableBINWarning || - !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { - sellingTooltip = null; - showWarning = false; - return false; - } - - if (Minecraft.getMinecraft().currentScreen instanceof GuiChest && - SBInfo.getInstance().lastOpenContainerName.startsWith("Create BIN Auction")) { - return true; - } else { - sellingTooltip = null; - showWarning = false; - return false; - } - } - - public boolean shouldShow() { - return shouldPerformCheck() && showWarning; - } - - public boolean onMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType) { - if (!shouldPerformCheck()) return false; - - if (slotId == 29) { - GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; - - sellingPrice = -1; - - ItemStack priceStack = chest.inventorySlots.getSlot(31).getStack(); - if (priceStack != null) { - String displayName = priceStack.getDisplayName(); - Matcher priceMatcher = ITEM_PRICE_REGEX.matcher(displayName); - - if (priceMatcher.matches()) { - try { - sellingPrice = Integer.parseInt(priceMatcher.group(1).replace(",", "")); - } catch (NumberFormatException ignored) {} - } - } - - ItemStack sellStack = chest.inventorySlots.getSlot(13).getStack(); - String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(sellStack); - - if (internalname == null) { - return false; - } - - JsonObject itemInfo = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(internalname); - if (itemInfo == null || !itemInfo.has("displayname")) { - sellingName = internalname; - } else { - sellingName = itemInfo.get("displayname").getAsString(); - } - - sellingTooltip = sellStack.getTooltip(Minecraft.getMinecraft().thePlayer, - Minecraft.getMinecraft().gameSettings.advancedItemTooltips); - - lowestPrice = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname); - if (lowestPrice <= 0) { - lowestPrice = (int) NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalname); - } - - //TODO: Add option for warning if lowest price does not exist - - float factor = 1 - NotEnoughUpdates.INSTANCE.config.ahTweaks.warningThreshold / 100; - if (factor < 0) factor = 0; - if (factor > 1) factor = 1; - - if (sellingPrice > 0 && lowestPrice > 0 && sellingPrice < lowestPrice * factor) { - showWarning = true; - return true; - } else { - return false; - } - } - return false; - } - - public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) { - if (shouldShow()) { - cir.setReturnValue(false); - } - } - - @Override - public void render() { - final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - final int width = scaledResolution.getScaledWidth(); - final int height = scaledResolution.getScaledHeight(); - - GlStateManager.disableLighting(); - - GlStateManager.pushMatrix(); - GlStateManager.translate(0, 0, 500); - - Gui.drawRect(0, 0, width, height, 0x80000000); - - RenderUtils.drawFloatingRectDark(width / 2 - 90, height / 2 - 45, 180, 90); - - int neuLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth("\u00a7lNEU"); - Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7lNEU", width / 2 + 90 - neuLength - 3, height / 2 - 45 + 4, 0xff000000); - - TextRenderUtils.drawStringCenteredScaledMaxWidth("Are you SURE?", Minecraft.getMinecraft().fontRendererObj, - width / 2, height / 2 - 45 + 10, false, 170, 0xffff4040); - - String lowestPriceStr; - if (lowestPrice > 999) { - lowestPriceStr = Utils.shortNumberFormat(lowestPrice, 0); - } else { - lowestPriceStr = "" + lowestPrice; - } - - String sellingPriceStr; - if (sellingPrice > 999) { - sellingPriceStr = Utils.shortNumberFormat(sellingPrice, 0); - } else { - sellingPriceStr = "" + sellingPrice; - } - - String sellLine = "\u00a77[ \u00a7r" + sellingName + "\u00a77 ]"; - - TextRenderUtils.drawStringCenteredScaledMaxWidth(sellLine, Minecraft.getMinecraft().fontRendererObj, - width / 2, height / 2 - 45 + 25, false, 170, 0xffffffff); - TextRenderUtils.drawStringCenteredScaledMaxWidth("has a lowest BIN of \u00a76" + lowestPriceStr + "\u00a7r coins", Minecraft.getMinecraft().fontRendererObj, - width / 2, height / 2 - 45 + 34, false, 170, 0xffa0a0a0); - - int buyPercentage = 100 - sellingPrice * 100 / lowestPrice; - if (buyPercentage <= 0) buyPercentage = 1; - - TextRenderUtils.drawStringCenteredScaledMaxWidth("Continue selling it for", Minecraft.getMinecraft().fontRendererObj, - width / 2, height / 2 - 45 + 50, false, 170, 0xffa0a0a0); - TextRenderUtils.drawStringCenteredScaledMaxWidth("\u00a76" + sellingPriceStr + "\u00a7r coins? (\u00a7c-" + buyPercentage + "%\u00a7r)", - Minecraft.getMinecraft().fontRendererObj, - width / 2, height / 2 - 45 + 59, false, 170, 0xffa0a0a0); - - RenderUtils.drawFloatingRectDark(width / 2 - 43, height / 2 + 23, 40, 16, false); - RenderUtils.drawFloatingRectDark(width / 2 + 3, height / 2 + 23, 40, 16, false); - - TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GREEN + "[Y]es", Minecraft.getMinecraft().fontRendererObj, - width / 2 - 23, height / 2 + 31, true, 36, 0xff00ff00); - TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.RED + "[n]o", Minecraft.getMinecraft().fontRendererObj, - width / 2 + 23, height / 2 + 31, true, 36, 0xffff0000); - - if (sellingTooltip != null) { - int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - - int sellLineLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(sellLine); - - if (mouseX >= width / 2 - sellLineLength / 2 && mouseX <= width / 2 + sellLineLength / 2 && - mouseY >= height / 2 - 45 + 20 && mouseY <= height / 2 - 45 + 30) { - Utils.drawHoveringText(sellingTooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj); - } - } - - GlStateManager.popMatrix(); - } - - @Override - public boolean mouseInput(int mouseX, int mouseY) { - final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - final int width = scaledResolution.getScaledWidth(); - final int height = scaledResolution.getScaledHeight(); - - if (Mouse.getEventButtonState()) { - if (mouseY >= height / 2 + 23 && mouseY <= height / 2 + 23 + 16) { - if (mouseX >= width / 2 - 43 && mouseX <= width / 2 - 3) { - GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; - Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, - 29, 0, 0, Minecraft.getMinecraft().thePlayer); - } - showWarning = false; - } - - if (mouseX < width / 2 - 90 || mouseX > width / 2 + 90 || - mouseY < height / 2 - 45 || mouseY > height / 2 + 45) { - showWarning = false; - } - } - - return false; - } - - @Override - public boolean keyboardInput() { - if (!Keyboard.getEventKeyState()) { - if (Keyboard.getEventKey() == Keyboard.KEY_Y || Keyboard.getEventKey() == Keyboard.KEY_RETURN) { - GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; - Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, - 29, 0, 0, Minecraft.getMinecraft().thePlayer); - } - showWarning = false; - } - - return false; - } + private static final AuctionBINWarning INSTANCE = new AuctionBINWarning(); + + public static AuctionBINWarning getInstance() { + return INSTANCE; + } + + private static final Pattern ITEM_PRICE_REGEX = Pattern.compile("\u00a7fItem price: \u00a76([0-9,]+) coins"); + + private boolean showWarning = false; + private List<String> sellingTooltip; + private String sellingName; + private int sellingPrice; + private int lowestPrice; + + private boolean shouldPerformCheck() { + if (!NotEnoughUpdates.INSTANCE.config.ahTweaks.enableBINWarning || + !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { + sellingTooltip = null; + showWarning = false; + return false; + } + + if (Minecraft.getMinecraft().currentScreen instanceof GuiChest && + SBInfo.getInstance().lastOpenContainerName.startsWith("Create BIN Auction")) { + return true; + } else { + sellingTooltip = null; + showWarning = false; + return false; + } + } + + public boolean shouldShow() { + return shouldPerformCheck() && showWarning; + } + + public boolean onMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType) { + if (!shouldPerformCheck()) return false; + + if (slotId == 29) { + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + + sellingPrice = -1; + + ItemStack priceStack = chest.inventorySlots.getSlot(31).getStack(); + if (priceStack != null) { + String displayName = priceStack.getDisplayName(); + Matcher priceMatcher = ITEM_PRICE_REGEX.matcher(displayName); + + if (priceMatcher.matches()) { + try { + sellingPrice = Integer.parseInt(priceMatcher.group(1).replace(",", "")); + } catch (NumberFormatException ignored) { + } + } + } + + ItemStack sellStack = chest.inventorySlots.getSlot(13).getStack(); + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(sellStack); + + if (internalname == null) { + return false; + } + + JsonObject itemInfo = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(internalname); + if (itemInfo == null || !itemInfo.has("displayname")) { + sellingName = internalname; + } else { + sellingName = itemInfo.get("displayname").getAsString(); + } + + sellingTooltip = sellStack.getTooltip( + Minecraft.getMinecraft().thePlayer, + Minecraft.getMinecraft().gameSettings.advancedItemTooltips + ); + + lowestPrice = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname); + if (lowestPrice <= 0) { + lowestPrice = (int) NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalname); + } + + //TODO: Add option for warning if lowest price does not exist + + float factor = 1 - NotEnoughUpdates.INSTANCE.config.ahTweaks.warningThreshold / 100; + if (factor < 0) factor = 0; + if (factor > 1) factor = 1; + + if (sellingPrice > 0 && lowestPrice > 0 && sellingPrice < lowestPrice * factor) { + showWarning = true; + return true; + } else { + return false; + } + } + return false; + } + + public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) { + if (shouldShow()) { + cir.setReturnValue(false); + } + } + + @Override + public void render() { + final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + final int width = scaledResolution.getScaledWidth(); + final int height = scaledResolution.getScaledHeight(); + + GlStateManager.disableLighting(); + + GlStateManager.pushMatrix(); + GlStateManager.translate(0, 0, 500); + + Gui.drawRect(0, 0, width, height, 0x80000000); + + RenderUtils.drawFloatingRectDark(width / 2 - 90, height / 2 - 45, 180, 90); + + int neuLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth("\u00a7lNEU"); + Minecraft.getMinecraft().fontRendererObj.drawString( + "\u00a7lNEU", + width / 2 + 90 - neuLength - 3, + height / 2 - 45 + 4, + 0xff000000 + ); + + TextRenderUtils.drawStringCenteredScaledMaxWidth("Are you SURE?", Minecraft.getMinecraft().fontRendererObj, + width / 2, height / 2 - 45 + 10, false, 170, 0xffff4040 + ); + + String lowestPriceStr; + if (lowestPrice > 999) { + lowestPriceStr = Utils.shortNumberFormat(lowestPrice, 0); + } else { + lowestPriceStr = "" + lowestPrice; + } + + String sellingPriceStr; + if (sellingPrice > 999) { + sellingPriceStr = Utils.shortNumberFormat(sellingPrice, 0); + } else { + sellingPriceStr = "" + sellingPrice; + } + + String sellLine = "\u00a77[ \u00a7r" + sellingName + "\u00a77 ]"; + + TextRenderUtils.drawStringCenteredScaledMaxWidth(sellLine, Minecraft.getMinecraft().fontRendererObj, + width / 2, height / 2 - 45 + 25, false, 170, 0xffffffff + ); + TextRenderUtils.drawStringCenteredScaledMaxWidth( + "has a lowest BIN of \u00a76" + lowestPriceStr + "\u00a7r coins", + Minecraft.getMinecraft().fontRendererObj, + width / 2, + height / 2 - 45 + 34, + false, + 170, + 0xffa0a0a0 + ); + + int buyPercentage = 100 - sellingPrice * 100 / lowestPrice; + if (buyPercentage <= 0) buyPercentage = 1; + + TextRenderUtils.drawStringCenteredScaledMaxWidth( + "Continue selling it for", + Minecraft.getMinecraft().fontRendererObj, + width / 2, + height / 2 - 45 + 50, + false, + 170, + 0xffa0a0a0 + ); + TextRenderUtils.drawStringCenteredScaledMaxWidth( + "\u00a76" + sellingPriceStr + "\u00a7r coins? (\u00a7c-" + buyPercentage + "%\u00a7r)", + Minecraft.getMinecraft().fontRendererObj, + width / 2, + height / 2 - 45 + 59, + false, + 170, + 0xffa0a0a0 + ); + + RenderUtils.drawFloatingRectDark(width / 2 - 43, height / 2 + 23, 40, 16, false); + RenderUtils.drawFloatingRectDark(width / 2 + 3, height / 2 + 23, 40, 16, false); + + TextRenderUtils.drawStringCenteredScaledMaxWidth( + EnumChatFormatting.GREEN + "[Y]es", + Minecraft.getMinecraft().fontRendererObj, + width / 2 - 23, + height / 2 + 31, + true, + 36, + 0xff00ff00 + ); + TextRenderUtils.drawStringCenteredScaledMaxWidth( + EnumChatFormatting.RED + "[n]o", + Minecraft.getMinecraft().fontRendererObj, + width / 2 + 23, + height / 2 + 31, + true, + 36, + 0xffff0000 + ); + + if (sellingTooltip != null) { + int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + int sellLineLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(sellLine); + + if (mouseX >= width / 2 - sellLineLength / 2 && mouseX <= width / 2 + sellLineLength / 2 && + mouseY >= height / 2 - 45 + 20 && mouseY <= height / 2 - 45 + 30) { + Utils.drawHoveringText( + sellingTooltip, + mouseX, + mouseY, + width, + height, + -1, + Minecraft.getMinecraft().fontRendererObj + ); + } + } + + GlStateManager.popMatrix(); + } + + @Override + public boolean mouseInput(int mouseX, int mouseY) { + final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + final int width = scaledResolution.getScaledWidth(); + final int height = scaledResolution.getScaledHeight(); + + if (Mouse.getEventButtonState()) { + if (mouseY >= height / 2 + 23 && mouseY <= height / 2 + 23 + 16) { + if (mouseX >= width / 2 - 43 && mouseX <= width / 2 - 3) { + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, + 29, 0, 0, Minecraft.getMinecraft().thePlayer + ); + } + showWarning = false; + } + + if (mouseX < width / 2 - 90 || mouseX > width / 2 + 90 || + mouseY < height / 2 - 45 || mouseY > height / 2 + 45) { + showWarning = false; + } + } + + return false; + } + + @Override + public boolean keyboardInput() { + if (!Keyboard.getEventKeyState()) { + if (Keyboard.getEventKey() == Keyboard.KEY_Y || Keyboard.getEventKey() == Keyboard.KEY_RETURN) { + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, + 29, 0, 0, Minecraft.getMinecraft().thePlayer + ); + } + showWarning = false; + } + + return false; + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java index ce2edcf6..4b526185 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java @@ -13,61 +13,63 @@ import net.minecraft.item.ItemStack; import java.util.List; public class AuctionSortModeWarning { - private static final AuctionSortModeWarning INSTANCE = new AuctionSortModeWarning(); + private static final AuctionSortModeWarning INSTANCE = new AuctionSortModeWarning(); - public static AuctionSortModeWarning getInstance() { - return INSTANCE; - } + public static AuctionSortModeWarning getInstance() { + return INSTANCE; + } - private boolean isAuctionBrowser() { - return NotEnoughUpdates.INSTANCE.config.ahTweaks.enableSortWarning && - Minecraft.getMinecraft().currentScreen instanceof GuiChest && - (SBInfo.getInstance().lastOpenContainerName.startsWith("Auctions Browser") || - SBInfo.getInstance().lastOpenContainerName.startsWith("Auctions: \"")); - } + private boolean isAuctionBrowser() { + return NotEnoughUpdates.INSTANCE.config.ahTweaks.enableSortWarning && + Minecraft.getMinecraft().currentScreen instanceof GuiChest && + (SBInfo.getInstance().lastOpenContainerName.startsWith("Auctions Browser") || + SBInfo.getInstance().lastOpenContainerName.startsWith("Auctions: \"")); + } - public void onPostGuiRender() { - if (isAuctionBrowser()) { - GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + public void onPostGuiRender() { + if (isAuctionBrowser()) { + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; - ItemStack stack = chest.inventorySlots.getSlot(50).getStack(); + ItemStack stack = chest.inventorySlots.getSlot(50).getStack(); - if (stack != null) { - List<String> tooltip = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + if (stack != null) { + List<String> tooltip = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false); - String selectedSort = null; - for (String line : tooltip) { - if (line.startsWith("\u00a75\u00a7o\u00a7b\u25B6 ")) { - selectedSort = Utils.cleanColour(line.substring("\u00a75\u00a7o\u00a7b\u25B6 ".length())); - } - } + String selectedSort = null; + for (String line : tooltip) { + if (line.startsWith("\u00a75\u00a7o\u00a7b\u25B6 ")) { + selectedSort = Utils.cleanColour(line.substring("\u00a75\u00a7o\u00a7b\u25B6 ".length())); + } + } - if (selectedSort != null) { - if (!selectedSort.trim().equals("Lowest Price")) { - GlStateManager.disableLighting(); - GlStateManager.pushMatrix(); - GlStateManager.translate(0, 0, 500); + if (selectedSort != null) { + if (!selectedSort.trim().equals("Lowest Price")) { + GlStateManager.disableLighting(); + GlStateManager.pushMatrix(); + GlStateManager.translate(0, 0, 500); - String selectedColour = "\u00a7e"; + String selectedColour = "\u00a7e"; - if (selectedSort.trim().equals("Highest Price")) { - selectedColour = "\u00a7c"; - } + if (selectedSort.trim().equals("Highest Price")) { + selectedColour = "\u00a7c"; + } - String warningText = "\u00a7aSort: " + selectedColour + selectedSort; - int warningLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(warningText); + String warningText = "\u00a7aSort: " + selectedColour + selectedSort; + int warningLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(warningText); - int centerX = chest.guiLeft + chest.xSize / 2 + 9; - int centerY = chest.guiTop + 26; + int centerX = chest.guiLeft + chest.xSize / 2 + 9; + int centerY = chest.guiTop + 26; - RenderUtils.drawFloatingRectDark(centerX - warningLength / 2 - 4, centerY - 6, - warningLength + 8, 12, false); - TextRenderUtils.drawStringCenteredScaledMaxWidth(warningText, Minecraft.getMinecraft().fontRendererObj, - centerX, centerY, true, chest.width / 2, 0xffffffff); - GlStateManager.popMatrix(); - } - } - } - } - } + RenderUtils.drawFloatingRectDark(centerX - warningLength / 2 - 4, centerY - 6, + warningLength + 8, 12, false + ); + TextRenderUtils.drawStringCenteredScaledMaxWidth(warningText, Minecraft.getMinecraft().fontRendererObj, + centerX, centerY, true, chest.width / 2, 0xffffffff + ); + GlStateManager.popMatrix(); + } + } + } + } + } } 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 d8c0db24..c1ce229c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java @@ -28,447 +28,520 @@ import java.nio.charset.StandardCharsets; import java.util.HashMap; public class BetterContainers { - private static final ResourceLocation TOGGLE_OFF = new ResourceLocation("notenoughupdates:dynamic_54/toggle_off.png"); - private static final ResourceLocation TOGGLE_ON = new ResourceLocation("notenoughupdates:dynamic_54/toggle_on.png"); - - private static final ResourceLocation DYNAMIC_54_BASE = new ResourceLocation("notenoughupdates:dynamic_54/style1/dynamic_54.png"); - private static final ResourceLocation DYNAMIC_54_SLOT = new ResourceLocation("notenoughupdates:dynamic_54/style1/dynamic_54_slot_ctm.png"); - private static final ResourceLocation DYNAMIC_54_BUTTON = new ResourceLocation("notenoughupdates:dynamic_54/style1/dynamic_54_button_ctm.png"); - private static final ResourceLocation rl = new ResourceLocation("notenoughupdates:dynamic_chest_inventory.png"); - private static boolean loaded = false; - private static DynamicTexture texture = null; - private static int textColour = 4210752; - - private static int lastClickedSlot = 0; - private static int clickedSlot = 0; - private static long clickedSlotMillis = 0; - public static long lastRenderMillis = 0; - - private static int lastInvHashcode = 0; - private static final int lastHashcodeCheck = 0; - - public static HashMap<Integer, ItemStack> itemCache = new HashMap<>(); - - public static int profileViewerStackIndex = -1; - - public static void clickSlot(int slot) { - clickedSlotMillis = System.currentTimeMillis(); - clickedSlot = slot; - } - - public static int getClickedSlot() { - if(System.currentTimeMillis() - clickedSlotMillis < 500) { - return clickedSlot; - } - return -1; - } - - public static void bindHook(TextureManager textureManager, ResourceLocation location) { - long currentMillis = System.currentTimeMillis(); - - if(isChestOpen() && NEUEventListener.inventoryLoaded) { - 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); - |
