diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java | 82 |
1 files changed, 39 insertions, 43 deletions
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 8ac0151a..ed05ee79 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java @@ -45,50 +45,46 @@ public class AuctionSortModeWarning { } public void onPostGuiRender() { - if (isAuctionBrowser()) { - GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; - - ItemStack stack = chest.inventorySlots.getSlot(50).getStack(); - - 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())); - } - } - - if (selectedSort != null) { - if (!selectedSort.trim().equals("Lowest Price")) { - GlStateManager.disableLighting(); - GlStateManager.pushMatrix(); - GlStateManager.translate(0, 0, 500); - - String selectedColour = "\u00a7e"; - - if (selectedSort.trim().equals("Highest Price")) { - selectedColour = "\u00a7c"; - } - - String warningText = "\u00a7aSort: " + selectedColour + selectedSort; - int warningLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(warningText); - - int centerX = - ((AccessorGuiContainer) chest).getGuiLeft() + ((AccessorGuiContainer) chest).getXSize() / 2 + 9; - int centerY = ((AccessorGuiContainer) chest).getGuiTop() + 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(); - } - } + if (!isAuctionBrowser()) return; + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + + ItemStack stack = chest.inventorySlots.getSlot(50).getStack(); + + if (stack == null) return; + 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())); } } + + if (selectedSort == null) return; + if (selectedSort.trim().equals("Lowest Price")) return; + GlStateManager.disableLighting(); + GlStateManager.pushMatrix(); + GlStateManager.translate(0, 0, 500); + + String selectedColour = "\u00a7e"; + + if (selectedSort.trim().equals("Highest Price")) { + selectedColour = "\u00a7c"; + } + + String warningText = "\u00a7aSort: " + selectedColour + selectedSort; + int warningLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(warningText); + + int centerX = + ((AccessorGuiContainer) chest).getGuiLeft() + ((AccessorGuiContainer) chest).getXSize() / 2 + 9; + int centerY = ((AccessorGuiContainer) chest).getGuiTop() + 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(); } } |