From 7bdf7f256fe3968fe7129928c0a7100c30628bf9 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 8 Jul 2020 16:28:49 +1000 Subject: 1.9.7 --- .../moulberry/notenoughupdates/GuiItemRecipe.java | 8 + .../moulberry/notenoughupdates/GuiItemUsages.java | 2 + .../moulberry/notenoughupdates/GuiTextures.java | 1 + .../moulberry/notenoughupdates/NEUManager.java | 140 ++-- .../moulberry/notenoughupdates/NEUOverlay.java | 94 ++- .../notenoughupdates/NotEnoughUpdates.java | 119 ++- .../notenoughupdates/auction/AuctionManager.java | 143 +++- .../notenoughupdates/auction/CustomAH.java | 846 +++++++++++++++------ .../infopanes/CollectionLogInfoPane.java | 6 +- .../notenoughupdates/infopanes/DevInfoPane.java | 14 +- .../notenoughupdates/options/Options.java | 1 + .../moulberry/notenoughupdates/util/Utils.java | 40 + 12 files changed, 1042 insertions(+), 372 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiItemRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiItemRecipe.java index 0cdef647..613ebe5f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/GuiItemRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiItemRecipe.java @@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack; public class GuiItemRecipe extends GuiCrafting { private ItemStack[] craftMatrix; + private JsonObject result; private String text; private String craftText = ""; private NEUManager manager; @@ -20,9 +21,14 @@ public class GuiItemRecipe extends GuiCrafting { public GuiItemRecipe(ItemStack[] craftMatrix, JsonObject result, String text, NEUManager manager) { super(Minecraft.getMinecraft().thePlayer.inventory, Minecraft.getMinecraft().theWorld); this.craftMatrix = craftMatrix; + this.result = result; this.text = text; this.manager = manager; + setContents(); + } + + public void setContents() { ContainerWorkbench cw = (ContainerWorkbench) this.inventorySlots; for(int i=0; i removedItems = neuio.getRemovedItems(currentlyInstalledItems); + Set removedItems; + if(config.autoupdate.value) { + removedItems = neuio.getRemovedItems(currentlyInstalledItems); + } else { + removedItems = new HashSet<>(); + } for(File f : itemsLocation.listFiles()) { String internalname = f.getName().substring(0, f.getName().length()-5); if(!removedItems.contains(internalname)) { @@ -454,6 +462,11 @@ public class NEUManager { if(json == null) { return; } + + String itemid = json.get("itemid").getAsString(); + itemid = Item.getByNameOrId(itemid).getRegistryName(); + json.addProperty("itemid", itemid); + itemMap.put(internalName, json); if(json.has("recipe")) { @@ -767,67 +780,84 @@ public class NEUManager { public JsonObject getJsonFromItemBytes(String item_bytes) { try { NBTTagCompound tag = CompressedStreamTools.readCompressed(new ByteArrayInputStream(Base64.getDecoder().decode(item_bytes))); - tag = tag.getTagList("i", 10).getCompoundTagAt(0); - int id = tag.getShort("id"); - int damage = tag.getShort("Damage"); - int count = tag.getShort("Count"); - tag = tag.getCompoundTag("tag"); - - String internalname = ""; - if(tag != null && tag.hasKey("ExtraAttributes", 10)) { - NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); - - if(ea.hasKey("id", 8)) { - internalname = ea.getString("id"); - } - } + return getJsonFromNBT(tag); + } catch(IOException e) { + return null; + } + } - String[] lore = new String[0]; - NBTTagCompound display = tag.getCompoundTag("display"); + public String getInternalnameFromNBT(NBTTagCompound tag) { + String internalname = "UNKNOWN"; + if(tag != null && tag.hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); - if(display.hasKey("Lore", 9)) { - NBTTagList list = display.getTagList("Lore", 8); - lore = new String[list.tagCount()]; - for(int k=0; k 0) { - JsonArray jsonLore = new JsonArray(); - for (String line : lore) { - jsonLore.add(new JsonPrimitive(line)); - } - item.add("lore", jsonLore); - } + NBTTagCompound display = tag.getCompoundTag("display"); + String[] lore = getLoreFromNBT(tag); - item.addProperty("damage", damage); - if(count > 1) item.addProperty("count", count); - item.addProperty("nbttag", tag.toString()); + Item itemMc = Item.getItemById(id); + String itemid = "null"; + if(itemMc != null) { + itemid = itemMc.getRegistryName(); + } + String displayname = display.getString("Name"); + String[] info = new String[0]; + String clickcommand = ""; - return item; - } catch(IOException e) { - return null; + + //public JsonObject createItemJson(String internalname, String itemid, String displayname, String[] lore, + // String crafttext, String infoType, String[] info, + // String clickcommand, int damage, NBTTagCompound nbttag) { + + JsonObject item = new JsonObject(); + item.addProperty("internalname", internalname); + item.addProperty("itemid", itemid); + item.addProperty("displayname", displayname); + + if(lore != null && lore.length > 0) { + JsonArray jsonLore = new JsonArray(); + for (String line : lore) { + jsonLore.add(new JsonPrimitive(line)); + } + item.add("lore", jsonLore); } + + item.addProperty("damage", damage); + if(count > 1) item.addProperty("count", count); + item.addProperty("nbttag", tag.toString()); + + return item; } private String clean(String str) { @@ -1269,7 +1299,7 @@ public class NEUManager { } if(stack.getItem() == null) { - stack = new ItemStack(Items.diamond, 1, 10); //Purple broken texture item + stack = new ItemStack(Item.getItemFromBlock(Blocks.stone), 0, 255); //Purple broken texture item } else { if(json.has("damage")) { stack.setItemDamage(json.get("damage").getAsInt()); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 95ceb21f..1d50daa6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -76,6 +76,8 @@ public class NEUOverlay extends Gui { private final int searchBarYSize = 40; private final int searchBarPadding = 2; + private float oldWidthMult = 0; + public static final int ITEM_PADDING = 4; public static final int ITEM_SIZE = 16; @@ -246,10 +248,12 @@ public class NEUOverlay extends Gui { int leftPrev = leftSide-1; if(mouseX > leftPrev && mouseX < leftPrev+buttonXSize) { //"Previous" button setPage(page-1); + Utils.playPressSound(); } int leftNext = rightSide+1-buttonXSize; if(mouseX > leftNext && mouseX < leftNext+buttonXSize) { //"Next" button setPage(page+1); + Utils.playPressSound(); } } @@ -268,9 +272,11 @@ public class NEUOverlay extends Gui { if(Mouse.getEventButton() == 0) { manager.config.compareMode.value = new Double(i); updateSearch(); + Utils.playPressSound(); } else if(Mouse.getEventButton() == 1) { manager.config.compareAscending.value.set(i, !manager.config.compareAscending.value.get(i)); updateSearch(); + Utils.playPressSound(); } } } @@ -280,6 +286,7 @@ public class NEUOverlay extends Gui { if(mouseX >= sortIconX && mouseX <= sortIconX+scaledITEM_SIZE) { manager.config.sortMode.value = new Double(i); updateSearch(); + Utils.playPressSound(); } } } @@ -287,15 +294,17 @@ public class NEUOverlay extends Gui { return true; } - if(Mouse.getEventButton() == 2) { - Slot slot = Utils.getSlotUnderMouse((GuiContainer)Minecraft.getMinecraft().currentScreen); - if(slot != null) { - ItemStack hover = slot.getStack(); - if(hover != null) { - textField.setText("id:"+manager.getInternalNameForItem(hover)); - updateSearch(); - searchMode = true; - return true; + if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) { + if(Mouse.getEventButton() == 2) { + Slot slot = Utils.getSlotUnderMouse((GuiContainer)Minecraft.getMinecraft().currentScreen); + if(slot != null) { + ItemStack hover = slot.getStack(); + if(hover != null) { + textField.setText("id:"+manager.getInternalNameForItem(hover)); + updateSearch(); + searchMode = true; + return true; + } } } } @@ -334,9 +343,11 @@ public class NEUOverlay extends Gui { String command = quickCommand.split(":")[0].trim(); if(command.startsWith("/")) { NotEnoughUpdates.INSTANCE.sendChatMessage(command); + Utils.playPressSound(); return true; } else { ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, command); + Utils.playPressSound(); return true; } } @@ -375,6 +386,7 @@ public class NEUOverlay extends Gui { if(Mouse.getEventButtonState()) { displayInformationPane(HTMLInfoPane.createFromWikiUrl(this, manager, "Help", "https://moulberry.github.io/files/neu_help.html")); + Utils.playPressSound(); } } else if(mouseX > width/2 - getSearchBarXSize()/2 - paddingUnscaled*6 - iconSize && mouseX < width/2 - getSearchBarXSize()/2 - paddingUnscaled*6) { @@ -384,6 +396,7 @@ public class NEUOverlay extends Gui { } else { displayInformationPane(new SettingsInfoPane(this, manager)); } + Utils.playPressSound(); } } } @@ -405,7 +418,7 @@ public class NEUOverlay extends Gui { */ public int getSearchBarXSize() { if(scaledresolution.getScaleFactor()==4) return (int)(searchBarXSize*0.8); - return searchBarXSize; + return (int)(searchBarXSize); } /** @@ -505,8 +518,9 @@ public class NEUOverlay extends Gui { AtomicReference internalname = new AtomicReference<>(null); AtomicReference itemstack = new AtomicReference<>(null); - Slot slot = Utils.getSlotUnderMouse((GuiContainer)Minecraft.getMinecraft().currentScreen); - if(slot != null) { + if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer && + Utils.getSlotUnderMouse((GuiContainer)Minecraft.getMinecraft().currentScreen) != null) { + Slot slot = Utils.getSlotUnderMouse((GuiContainer)Minecraft.getMinecraft().currentScreen); ItemStack hover = slot.getStack(); if(hover != null) { internalname.set(manager.getInternalNameForItem(hover)); @@ -842,7 +856,8 @@ public class NEUOverlay extends Gui { public float getWidthMult() { float scaleFMult = 1; - if(scaledresolution.getScaleFactor()==4) scaleFMult = 0.9f; + if(scaledresolution.getScaleFactor()==4) scaleFMult *= 0.9f; + if(manager.auctionManager.customAH.isRenderOverAuctionView()) scaleFMult *= 0.8f; return (float)Math.max(0.5, Math.min(1.5, manager.config.paneWidthMult.value.floatValue()))*scaleFMult; } @@ -1047,32 +1062,34 @@ public class NEUOverlay extends Gui { */ public void renderOverlay(int mouseX, int mouseY) { if(searchMode && textField.getText().length() > 0) { - GuiContainer inv = (GuiContainer) Minecraft.getMinecraft().currentScreen; - int guiLeftI = (int)Utils.getField(GuiContainer.class, inv, "guiLeft", "field_147003_i"); - int guiTopI = (int)Utils.getField(GuiContainer.class, inv, "guiTop", "field_147009_r"); - - GL11.glTranslatef(0, 0, 260); - int overlay = new Color(0, 0, 0, 100).getRGB(); - for(Slot slot : inv.inventorySlots.inventorySlots) { - if(slot.getStack() == null || !manager.doesStackMatchSearch(slot.getStack(), textField.getText())) { - drawRect(guiLeftI+slot.xDisplayPosition, guiTopI+slot.yDisplayPosition, - guiLeftI+slot.xDisplayPosition+16, guiTopI+slot.yDisplayPosition+16, - overlay); + if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) { + GuiContainer inv = (GuiContainer) Minecraft.getMinecraft().currentScreen; + int guiLeftI = (int)Utils.getField(GuiContainer.class, inv, "guiLeft", "field_147003_i"); + int guiTopI = (int)Utils.getField(GuiContainer.class, inv, "guiTop", "field_147009_r"); + + GL11.glTranslatef(0, 0, 260); + int overlay = new Color(0, 0, 0, 100).getRGB(); + for(Slot slot : inv.inventorySlots.inventorySlots) { + if(slot.getStack() == null || !manager.doesStackMatchSearch(slot.getStack(), textField.getText())) { + drawRect(guiLeftI+slot.xDisplayPosition, guiTopI+slot.yDisplayPosition, + guiLeftI+slot.xDisplayPosition+16, guiTopI+slot.yDisplayPosition+16, + overlay); + } } - } - if(Utils.getSlotUnderMouse(inv) != null) { - ItemStack stack = Utils.getSlotUnderMouse(inv).getStack(); - //Minecraft.getMinecraft().currentScreen.renderToolTip(stack, mouseX, mouseY); - Class[] params = new Class[]{ItemStack.class, int.class, int.class}; - Method renderToolTip = Utils.getMethod(GuiScreen.class, params, "renderToolTip", "func_146285_a"); - if(renderToolTip != null) { - renderToolTip.setAccessible(true); - try { - renderToolTip.invoke(Minecraft.getMinecraft().currentScreen, stack, mouseX, mouseY); - } catch(Exception e) {} + if(Utils.getSlotUnderMouse(inv) != null) { + ItemStack stack = Utils.getSlotUnderMouse(inv).getStack(); + //Minecraft.getMinecraft().currentScreen.renderToolTip(stack, mouseX, mouseY); + Class[] params = new Class[]{ItemStack.class, int.class, int.class}; + Method renderToolTip = Utils.getMethod(GuiScreen.class, params, "renderToolTip", "func_146285_a"); + if(renderToolTip != null) { + renderToolTip.setAccessible(true); + try { + renderToolTip.invoke(Minecraft.getMinecraft().currentScreen, stack, mouseX, mouseY); + } catch(Exception e) {} + } } + GL11.glTranslatef(0, 0, -260); } - GL11.glTranslatef(0, 0, -260); } } @@ -1205,6 +1222,11 @@ public class NEUOverlay extends Gui { redrawItems = true; } + if(oldWidthMult != getWidthMult()) { + oldWidthMult = getWidthMult(); + redrawItems = true; + } + blurBackground(); yaw++; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 2946f930..32cd5980 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -73,6 +73,7 @@ public class NotEnoughUpdates { private static final long CHAT_MSG_COOLDOWN = 200; private long lastChatMessage = 0; + private long secondLastChatMessage = 0; private String currChatMessage = null; private boolean hoverInv = false; @@ -107,10 +108,18 @@ public class NotEnoughUpdates { SimpleCommand neuAhCommand = new SimpleCommand("neuah", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { - openGui = new CustomAHGui(); - manager.auctionManager.customAH.lastOpen = System.currentTimeMillis(); - manager.auctionManager.customAH.clearSearch(); - manager.auctionManager.customAH.updateSearch(); + if(!hasSkyblockScoreboard()) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+ + "You must be on Skyblock to use this feature.")); + } else if(manager.config.apiKey.value == null || manager.config.apiKey.value.isEmpty()) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+ + "Can't open NeuAH, Api Key is not set. Run /api new and put the result in settings.")); + } else { + openGui = new CustomAHGui(); + manager.auctionManager.customAH.lastOpen = System.currentTimeMillis(); + manager.auctionManager.customAH.clearSearch(); + manager.auctionManager.customAH.updateSearch(); + } } }); @@ -189,7 +198,8 @@ public class NotEnoughUpdates { * If the last chat message was sent <200 ago, will cache the message for #onTick to handle. */ public void sendChatMessage(String message) { - if (System.currentTimeMillis() - lastChatMessage > CHAT_MSG_COOLDOWN) { + if(System.currentTimeMillis() - lastChatMessage > CHAT_MSG_COOLDOWN) { + secondLastChatMessage = lastChatMessage; lastChatMessage = System.currentTimeMillis(); Minecraft.getMinecraft().thePlayer.sendChatMessage(message); currChatMessage = null; @@ -239,6 +249,17 @@ public class NotEnoughUpdates { usableContainer = false; break; } + if(!usableContainer) { + if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest container = (ContainerChest) chest.inventorySlots; + String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText(); + + if(containerName.equals("Accessory Bag")) { + usableContainer = true; + } + } + } if(usableContainer) { for(ItemStack stack : Minecraft.getMinecraft().thePlayer.openContainer.getInventory()) { processUniqueStack(stack, newItem); @@ -271,7 +292,7 @@ public class NotEnoughUpdates { @SubscribeEvent public void onRenderGameOverlay(RenderGameOverlayEvent event) { - if(event.type.equals(RenderGameOverlayEvent.ElementType.BOSSHEALTH) && + if(event.type != null && event.type.equals(RenderGameOverlayEvent.ElementType.BOSSHEALTH) && Minecraft.getMinecraft().currentScreen instanceof GuiContainer && overlay.isUsingMobsFilter()) { event.setCanceled(true); } @@ -301,7 +322,7 @@ public class NotEnoughUpdates { String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText(); manager.auctionManager.customAH.setRenderOverAuctionView(containerName.trim().equals("Auction View") || - containerName.trim().equals("BIN Auction View")); + containerName.trim().equals("BIN Auction View") || containerName.trim().equals("Confirm Bid")); } //OPEN @@ -468,36 +489,38 @@ public class NotEnoughUpdates { */ @SubscribeEvent public void onGuiBackgroundDraw(GuiScreenEvent.BackgroundDrawnEvent event) { - if(event.gui instanceof GuiContainer && isOnSkyblock()) { + if((event.gui instanceof GuiContainer || event.gui instanceof CustomAHGui) && isOnSkyblock()) { ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); int width = scaledresolution.getScaledWidth(); boolean hoverPane = event.getMouseX() < width*overlay.getInfoPaneOffsetFactor() || event.getMouseX() > width*overlay.getItemPaneOffsetFactor(); - try { - int xSize = (int) Utils.getField(GuiContainer.class, event.gui, "xSize", "field_146999_f"); - int ySize = (int) Utils.getField(GuiContainer.class, event.gui, "ySize", "field_147000_g"); - int guiLeft = (int) Utils.getField(GuiContainer.class, event.gui, "guiLeft", "field_147003_i"); - int guiTop = (int) Utils.getField(GuiContainer.class, event.gui, "guiTop", "field_147009_r"); - - hoverInv = event.getMouseX() > guiLeft && event.getMouseX() < guiLeft + xSize && - event.getMouseY() > guiTop && event.getMouseY() < guiTop + ySize; - - if(hoverPane) { - if(!hoverInv) focusInv = false; - } else { - focusInv = true; - } - } catch(NullPointerException npe) { - npe.printStackTrace(); - focusInv = !hoverPane; - } - if(focusInv) { + if(event.gui instanceof GuiContainer) { try { - overlay.render(event.getMouseX(), event.getMouseY(), hoverInv && focusInv); - } catch(ConcurrentModificationException e) {e.printStackTrace();} - GL11.glTranslatef(0, 0, 10); + int xSize = (int) Utils.getField(GuiContainer.class, event.gui, "xSize", "field_146999_f"); + int ySize = (int) Utils.getField(GuiContainer.class, event.gui, "ySize", "field_147000_g"); + int guiLeft = (int) Utils.getField(GuiContainer.class, event.gui, "guiLeft", "field_147003_i"); + int guiTop = (int) Utils.getField(GuiContainer.class, event.gui, "guiTop", "field_147009_r"); + + hoverInv = event.getMouseX() > guiLeft && event.getMouseX() < guiLeft + xSize && + event.getMouseY() > guiTop && event.getMouseY() < guiTop + ySize; + + if(hoverPane) { + if(!hoverInv) focusInv = false; + } else { + focusInv = true; + } + } catch(NullPointerException npe) { + npe.printStackTrace(); + focusInv = !hoverPane; + } + if(focusInv) { + try { + overlay.render(event.getMouseX(), event.getMouseY(), hoverInv && focusInv); + } catch(ConcurrentModificationException e) {e.printStackTrace();} + GL11.glTranslatef(0, 0, 10); + } } } } @@ -506,7 +529,22 @@ public class NotEnoughUpdates { public void onGuiScreenDrawPre(GuiScreenEvent.DrawScreenEvent.Pre event) { if(event.gui instanceof CustomAHGui || manager.auctionManager.customAH.isRenderOverAuctionView()) { event.setCanceled(true); - manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY); + + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + + //Dark background + Utils.drawGradientRect(0, 0, width, height, -1072689136, -804253680); + + if(event.mouseX < width*overlay.getWidthMult()/3 || event.mouseX > width-width*overlay.getWidthMult()/3) { + manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY); + overlay.render(event.mouseX, event.mouseY, false); + } else { + overlay.render(event.mouseX, event.mouseY, false); + manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY); + } + } } @@ -517,13 +555,15 @@ public class NotEnoughUpdates { */ @SubscribeEvent public void onGuiScreenDrawPost(GuiScreenEvent.DrawScreenEvent.Post event) { - if(event.gui instanceof GuiContainer && isOnSkyblock()) { - if(!focusInv) { - GL11.glTranslatef(0, 0, 300); - overlay.render(event.mouseX, event.mouseY, hoverInv && focusInv); - GL11.glTranslatef(0, 0, -300); + if(!(event.gui instanceof CustomAHGui || manager.auctionManager.customAH.isRenderOverAuctionView())) { + if(event.gui instanceof GuiContainer && isOnSkyblock()) { + if(!focusInv) { + GL11.glTranslatef(0, 0, 300); + overlay.render(event.mouseX, event.mouseY, hoverInv && focusInv); + GL11.glTranslatef(0, 0, -300); + } + overlay.renderOverlay(event.mouseX, event.mouseY); } - overlay.renderOverlay(event.mouseX, event.mouseY); } } @@ -537,7 +577,7 @@ public class NotEnoughUpdates { if(event.gui instanceof CustomAHGui || manager.auctionManager.customAH.isRenderOverAuctionView()) { event.setCanceled(true); manager.auctionManager.customAH.handleMouseInput(); - //overlay.mouseInput(); + overlay.mouseInput(); return; } if(event.gui instanceof GuiContainer && !(hoverInv && focusInv) && isOnSkyblock()) { @@ -553,13 +593,14 @@ public class NotEnoughUpdates { * Sends a kbd event to NEUOverlay, cancelling if NEUOverlay#keyboardInput returns true. * Also includes a dev function used for creating custom named json files with recipes. */ - boolean started = false; @SubscribeEvent public void onGuiScreenKeyboard(GuiScreenEvent.KeyboardInputEvent.Pre event) { if(event.gui instanceof CustomAHGui || manager.auctionManager.customAH.isRenderOverAuctionView()) { if(manager.auctionManager.customAH.keyboardInput()) { event.setCanceled(true); Minecraft.getMinecraft().dispatchKeypresses(); + } else if(overlay.keyboardInput(focusInv)) { + event.setCanceled(true); } return; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/AuctionManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/AuctionManager.java index 3d636f8a..543b4c8e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/AuctionManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/AuctionManager.java @@ -4,9 +4,15 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; +import java.io.ByteArrayInputStream; +import java.io.IOException; import java.util.*; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -22,14 +28,24 @@ public class AuctionManager { private int totalPages = 0; private int lastApiUpdate; private LinkedList needUpdate = new LinkedList<>(); + private TreeMap auctionMap = new TreeMap<>(); + public HashMap> internalnameToAucIdMap = new HashMap<>(); + private HashSet playerBids = new HashSet<>(); - public TreeMap>> extrasToAucIdMap = new TreeMap<>(); + public TreeMap> extrasToAucIdMap = new TreeMap<>(); private long lastPageUpdate = 0; private long lastCustomAHSearch = 0; private long lastCleanup = 0; + public int activeAuctions = 0; + public int uniqueItems = 0; + public int totalTags = 0; + public int internalnameTaggedAuctions = 0; + public int taggedAuctions = 0; + public int processMillis = 0; + public AuctionManager(NEUManager manager) { this.manager = manager; customAH = new CustomAH(manager); @@ -39,6 +55,14 @@ public class AuctionManager { return auctionMap; } + public HashSet getPlayerBids() { + return playerBids; + } + + public HashSet getAuctionsForInternalname(String internalname) { + return internalnameToAucIdMap.computeIfAbsent(internalname, k -> new HashSet<>()); + } + public class Auction { public String auctioneerUuid; public long end; @@ -48,11 +72,15 @@ public class AuctionManager { public boolean bin; public String category; public String rarity; - public String item_bytes; + public NBTTagCompound item_tag; private ItemStack stack; + public long lastUpdate = 0; + + public int enchLevel = 0; //0 = clean, 1 = ench, 2 = ench/hpb + public Auction(String auctioneerUuid, long end, int starting_bid, int highest_bid_amount, int bid_count, - boolean bin, String category, String rarity, String item_bytes) { + boolean bin, String category, String rarity, NBTTagCompound item_tag) { this.auctioneerUuid = auctioneerUuid; this.end = end; this.starting_bid = starting_bid; @@ -61,14 +89,14 @@ public class AuctionManager { this.bin = bin; this.category = category; this.rarity = rarity; - this.item_bytes = item_bytes; + this.item_tag = item_tag; } public ItemStack getStack() { if(stack != null) { return stack; } else { - JsonObject item = manager.getJsonFromItemBytes(item_bytes); + JsonObject item = manager.getJsonFromNBT(item_tag); ItemStack stack = manager.jsonToStack(item, false); this.stack = stack; return stack; @@ -77,6 +105,7 @@ public class AuctionManager { } public void tick() { + customAH.tick(); if(System.currentTimeMillis() - lastPageUpdate > 5*1000) { lastPageUpdate = System.currentTimeMillis(); updatePageTick(); @@ -87,23 +116,38 @@ public class AuctionManager { } if(System.currentTimeMillis() - lastCustomAHSearch > 60*1000) { lastCustomAHSearch = System.currentTimeMillis(); - customAH.updateSearch(); + if(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || customAH.isRenderOverAuctionView()) { + customAH.updateSearch(); + calculateStats(); + } } } private void cleanup() { try { + long currTime = System.currentTimeMillis(); Set toRemove = new HashSet<>(); for(Map.Entry entry : auctionMap.entrySet()) { - long timeToEnd = entry.getValue().end - System.currentTimeMillis(); + long timeToEnd = entry.getValue().end - currTime; if(timeToEnd < -60) { toRemove.add(entry.getKey()); + } else if(currTime - entry.getValue().lastUpdate > 5*60*1000) { + toRemove.add(entry.getKey()); } } + toRemove.removeAll(playerBids); for(String aucid : toRemove) { auctionMap.remove(aucid); - extrasToAucIdMap.remove(aucid); } + for(HashSet aucids : extrasToAucIdMap.values()) { + for(String aucid : toRemove) { + aucids.remove(aucid); + } + } + for(HashSet aucids : internalnameToAucIdMap.values()) { + aucids.removeAll(toRemove); + } + playerBids.removeAll(toRemove); } catch(ConcurrentModificationException e) { cleanup(); } @@ -115,14 +159,32 @@ public class AuctionManager { } else { if(needUpdate.isEmpty()) resetNeedUpdate(); - int pageToUpdate; - for(pageToUpdate = needUpdate.pop(); pageToUpdate >= totalPages && !needUpdate.isEmpty(); - pageToUpdate = needUpdate.pop()) {} + int pageToUpdate = needUpdate.pop(); + while (pageToUpdate >= totalPages && !needUpdate.isEmpty()) { + pageToUpdate = needUpdate.pop(); + } getPageFromAPI(pageToUpdate); } } + public void calculateStats() { + try { + uniqueItems = internalnameToAucIdMap.size(); + Set aucs = new HashSet<>(); + for(HashSet aucids : internalnameToAucIdMap.values()) { + aucs.addAll(aucids); + } + internalnameTaggedAuctions = aucs.size(); + totalTags = extrasToAucIdMap.size(); + aucs = new HashSet<>(); + for(HashSet aucids : extrasToAucIdMap.values()) { + aucs.addAll(aucids); + } + taggedAuctions = aucs.size(); + } catch(Exception e) {} + } + String[] rarityArr = new String[] { "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", }; @@ -149,8 +211,8 @@ public class AuctionManager { manager.hypixelApi.getHypixelApiAsync(manager.config.apiKey.value, "skyblock/auctions", args, jsonObject -> { if (jsonObject.get("success").getAsBoolean()) { - //pages.put(page, jsonObject); totalPages = jsonObject.get("totalPages").getAsInt(); + activeAuctions = jsonObject.get("totalAuctions").getAsInt(); int lastUpdated = jsonObject.get("lastUpdated").getAsInt(); @@ -162,7 +224,9 @@ public class AuctionManager { String[] categoryItemType = new String[]{"sword","fishingrod","pickaxe","axe", "shovel","petitem","travelscroll","reforgestone","bow"}; + String playerUUID = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replaceAll("-",""); + long startProcess = System.currentTimeMillis(); JsonArray auctions = jsonObject.get("auctions").getAsJsonArray(); for (int i = 0; i < auctions.size(); i++) { JsonObject auction = auctions.get(i).getAsJsonObject(); @@ -179,27 +243,38 @@ public class AuctionManager { } String sbCategory = auction.get("category").getAsString(); String extras = auction.get("extra").getAsString(); + String item_name = auction.get("item_name").getAsString(); String item_lore = auction.get("item_lore").getAsString(); String item_bytes = auction.get("item_bytes").getAsString(); String rarity = auction.get("tier").getAsString(); + JsonArray bids = auction.get("bids").getAsJsonArray(); + + NBTTagCompound item_tag; + try { + item_tag = CompressedStreamTools.readCompressed( + new ByteArrayInputStream(Base64.getDecoder().decode(item_bytes))); + } catch(IOException e) { continue; } - String tag = extras + " " + Utils.cleanColour(item_lore).replaceAll("\n", " "); + NBTTagCompound tag = item_tag.getTagList("i", 10).getCompoundTagAt(0).getCompoundTag("tag"); + String internalname = manager.getInternalnameFromNBT(tag); - int wordIndex=0; - for(String str : tag.split(" ")) { + for(String str : extras.substring(item_name.length()).split(" ")) { str = Utils.cleanColour(str).toLowerCase(); - if(!extrasToAucIdMap.containsKey(str)) { - extrasToAucIdMap.put(str, new HashMap<>()); + if(str.length() > 0) { + HashSet aucids = extrasToAucIdMap.computeIfAbsent(str, k -> new HashSet<>()); + aucids.add(auctionUuid); } - if(!extrasToAucIdMap.get(str).containsKey(auctionUuid)) { - extrasToAucIdMap.get(str).put(auctionUuid, new ArrayList<>()); + } + + for(int j=0; j= 0 && itemType < categoryItemType.length) { @@ -208,13 +283,31 @@ public class AuctionManager { if(extras.startsWith("Enchanted Book")) category = "ebook"; if(extras.endsWith("Potion")) category = "potion"; if(extras.contains("Rune")) category = "rune"; - if(item_lore.substring(2).startsWith("Furniture")) category = "furniture"; + if(item_lore.split("\n")[0].endsWith("Furniture")) category = "furniture"; if(item_lore.split("\n")[0].endsWith("Pet") || item_lore.split("\n")[0].endsWith("Mount")) category = "pet"; - auctionMap.put(auctionUuid, new Auction(auctioneerUuid, end, starting_bid, highest_bid_amount, - bid_count, bin, category, rarity, item_bytes)); + Auction auction1 = new Auction(auctioneerUuid, end, starting_bid, highest_bid_amount, + bid_count, bin, category, rarity, item_tag); + + if(tag.hasKey("ench")) { + auction1.enchLevel = 1; + if(tag.hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); + + int hotpotatocount = ea.getInteger("hot_potato_count"); + if(hotpotatocount == 10) { + auction1.enchLevel = 2; + } + } + } + + auction1.lastUpdate = System.currentTimeMillis(); + + auctionMap.put(auctionUuid, auction1); + internalnameToAucIdMap.computeIfAbsent(internalname, k -> new HashSet<>()).add(auctionUuid); } + processMillis = (int)(System.currentTimeMillis() - startProcess); } } ); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java index 0cc17afe..aad82b9f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java @@ -17,6 +17,7 @@ import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.init.Blocks; import net.minecraft.init.Items; +import net.minecraft.inventory.ContainerChest; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -31,9 +32,12 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; import java.awt.*; +import java.awt.datatransfer.StringSelection; import java.text.NumberFormat; import java.util.*; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import static io.github.moulberry.notenoughupdates.GuiTextures.*; @@ -44,11 +48,18 @@ public class CustomAH extends Gui { private static final ResourceLocation creativeInventoryTabs = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); - private List auctionIds = new ArrayList<>(); + private HashSet auctionIds = new HashSet<>(); + private List sortedAuctionIds = new ArrayList<>(); private boolean scrollClicked = false; + private long lastUpdateSearch; + private long lastSearchFieldUpdate; + private boolean shouldUpdateSearch = false; + private boolean shouldSortItems = false; + private int startingBid = 0; + private String currentAucId = null; private int clickedMainCategory = -1; private int clickedSubCategory = -1; @@ -59,6 +70,9 @@ public class CustomAH extends Gui { private boolean renderOverAuctionView = false; private long lastRenderDisable = 0; + private long currAucIdSetTimer = 0; + private long resetCurrAucIdTimer = 0; + private int eventButton; private long lastMouseEvent; public long lastOpen; @@ -96,7 +110,7 @@ public class CustomAH extends Gui { private Category CATEGORY_COMBAT = new Category("weapon", "Combat", "golden_sword", CATEGORY_SWORD, CATEGORY_BOWS, CATEGORY_ARMOR, CATEGORY_ACCESSORIES); - private Category CATEGORY_TOOL = new Category("", "Tools", "iron_pickaxe", CATEGORY_FISHING_ROD, CATEGORY_PICKAXE, + private Category CATEGORY_TOOL = new Category("", "Tools", "diamond_pickaxe", CATEGORY_FISHING_ROD, CATEGORY_PICKAXE, CATEGORY_AXE, CATEGORY_SHOVEL); private Category CATEGORY_PET = new Category("pet", "Pets", "bone", CATEGORY_PET_ITEM); private Category CATEGORY_CONSUMABLES = new Category("consumables", "Consumables", "apple", CATEGORY_EBOOKS, CATEGORY_POTIONS, @@ -114,15 +128,25 @@ public class CustomAH extends Gui { private static final String[] rarities = { "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL" }; + private static final String[] rarityColours = { ""+EnumChatFormatting.WHITE, + ""+EnumChatFormatting.GREEN, ""+EnumChatFormatting.BLUE, ""+EnumChatFormatting.DARK_PURPLE, + ""+EnumChatFormatting.GOLD, ""+EnumChatFormatting.LIGHT_PURPLE, ""+EnumChatFormatting.RED, + ""+EnumChatFormatting.RED }; private static final int BIN_FILTER_ALL = 0; private static final int BIN_FILTER_BIN = 1; private static final int BIN_FILTER_AUC = 2; + private static final int ENCH_FILTER_ALL = 0; + private static final int ENCH_FILTER_CLEAN = 1; + private static final int ENCH_FILTER_ENCH = 2; + private static final int ENCH_FILTER_ENCHHPB = 3; + private int sortMode = SORT_MODE_HIGH; private int rarityFilter = -1; private boolean filterMyAuctions = false; private int binFilter = BIN_FILTER_ALL; + private int enchFilter = ENCH_FILTER_ALL; private static ItemStack CONTROL_SORT = Utils.createItemStack(Item.getItemFromBlock(Blocks.hopper), EnumChatFormatting.GREEN+"Sort"); @@ -132,7 +156,11 @@ public class CustomAH extends Gui { EnumChatFormatting.GREEN+"My Auctions"); private static ItemStack CONTROL_BIN = Utils.createItemStack(Item.getItemFromBlock(Blocks.golden_rail), EnumChatFormatting.GREEN+"BIN Filter"); - private ItemStack[] controls = {null,CONTROL_SORT,CONTROL_TIER,null,CONTROL_MYAUC,null,CONTROL_BIN,null,null}; + private static ItemStack CONTROL_ENCH = Utils.createItemStack(Items.enchanted_book, + EnumChatFormatting.GREEN+"Enchant Filter"); + private static ItemStack CONTROL_STATS = Utils.createItemStack(Item.getItemFromBlock(Blocks.command_block), + EnumChatFormatting.GREEN+"Stats for nerds"); + private ItemStack[] controls = {null,CONTROL_SORT,CONTROL_TIER,null,CONTROL_MYAUC,null,CONTROL_BIN,CONTROL_ENCH,CONTROL_STATS}; private NEUManager manager; @@ -141,17 +169,28 @@ public class CustomAH extends Gui { } public void clearSearch() { + if(searchField == null || priceField == null) init(); if(System.currentTimeMillis() - lastOpen < 1000) Mouse.setGrabbed(false); - sortMode = SORT_MODE_HIGH; + //sortMode = SORT_MODE_HIGH; rarityFilter = -1; filterMyAuctions = false; - binFilter = BIN_FILTER_ALL; + //binFilter = BIN_FILTER_ALL; + enchFilter = ENCH_FILTER_ALL; searchField.setText(""); + searchField.setFocused(true); priceField.setText(""); } + public void tick() { + if(shouldUpdateSearch) updateSearch(); + if(shouldSortItems) { + sortItems(); + shouldSortItems = false; + } + } + public class Category { public String categoryMatch; public Category[] subcategories; @@ -179,15 +218,15 @@ public class CustomAH extends Gui { private void init() { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; this.searchField = new GuiTextField(0, fr, this.guiLeft + 82, this.guiTop + 6, - 89, fr.FONT_HEIGHT); + 84, fr.FONT_HEIGHT); this.priceField = new GuiTextField(1, fr, this.guiLeft + 82, this.guiTop + 6, - 89, fr.FONT_HEIGHT); + 84, fr.FONT_HEIGHT); - this.searchField.setMaxStringLength(15); + this.searchField.setMaxStringLength(30); this.searchField.setEnableBackgroundDrawing(false); this.searchField.setTextColor(16777215); this.searchField.setVisible(true); - this.searchField.setCanLoseFocus(false); + this.searchField.setCanLoseFocus(true); this.searchField.setFocused(true); this.searchField.setText(""); @@ -195,7 +234,7 @@ public class CustomAH extends Gui { this.priceField.setEnableBackgroundDrawing(false); this.priceField.setTextColor(16777215); this.priceField.setVisible(true); - this.priceField.setCanLoseFocus(false); + this.priceField.setCanLoseFocus(true); this.priceField.setFocused(false); this.priceField.setText(""); } @@ -217,26 +256,14 @@ public class CustomAH extends Gui { return 136 + ySplitSize*splits; } - private TexLoc tl = new TexLoc(0, 0, Keyboard.KEY_M); - - public List getTooltipForAucId(String aucId) { - AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucId); - - List tooltip = new ArrayList<>(); - - for(String line : auc.getStack().getTooltip(Minecraft.getMinecraft().thePlayer, false)) { - tooltip.add(EnumChatFormatting.GRAY+line); - } + private String prettyTime(long millis) { + long seconds = millis / 1000 % 60; + long minutes = (millis / 1000 / 60) % 60; + long hours = (millis / 1000 / 60 / 60) % 24; + long days = (millis / 1000 / 60 / 60 / 24); - long timeUntilEnd = auc.end - System.currentTimeMillis(); - - long seconds = timeUntilEnd / 1000 % 60; - long minutes = (timeUntilEnd / 1000 / 60) % 60; - long hours = (timeUntilEnd / 1000 / 60 / 60) % 24; - long days = (timeUntilEnd / 1000 / 60 / 60 / 24); - - String endsIn = EnumChatFormatting.YELLOW+""; - if(timeUntilEnd < 0) { + String endsIn = ""; + if(millis < 0) { endsIn += "Ended!"; } else if(minutes == 0 && hours == 0 && days == 0) { endsIn += seconds + "s"; @@ -252,6 +279,21 @@ public class CustomAH extends Gui { endsIn += days + "d" + hours + "h"; } + return endsIn; + } + + public List getTooltipForAucId(String aucId) { + AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucId); + + List tooltip = new ArrayList<>(); + + for(String line : auc.getStack().getTooltip(Minecraft.getMinecraft().thePlayer, false)) { + tooltip.add(EnumChatFormatting.GRAY+line); + } + + long timeUntilEnd = auc.end - System.currentTimeMillis(); + String endsIn = EnumChatFormatting.YELLOW+prettyTime(timeUntilEnd); + NumberFormat format = NumberFormat.getInstance(Locale.US); tooltip.add(EnumChatFormatting.DARK_GRAY+""+EnumChatFormatting.STRIKETHROUGH+"-----------------"); @@ -293,7 +335,7 @@ public class CustomAH extends Gui { boolean clicked = i == clickedSubCategory; int x = guiLeft-28; - int y = guiTop+17+28*i; + int y = guiTop+17+28*(i+1); float uMin = 28/256f; float uMax = 56/256f; float vMin = 0+(clicked?32/256f:0); @@ -328,6 +370,53 @@ public class CustomAH extends Gui { GlStateManager.disableBlend(); } + private HashMap timeParseMap = new HashMap<>(); + public long prettyTimeToMillis(String endsInStr) { + if(timeParseMap.isEmpty()) { + Pattern dayPattern = Pattern.compile("([0-9]+)d"); + Pattern hourPattern = Pattern.compile("([0-9]+)h"); + Pattern minutePattern = Pattern.compile("([0-9]+)m"); + Pattern secondPattern = Pattern.compile("([0-9]+)s"); + + timeParseMap.put(dayPattern, 24*60*60*1000L); + timeParseMap.put(hourPattern, 60*60*1000L); + timeParseMap.put(minutePattern, 60*1000L); + timeParseMap.put(secondPattern, 1000L); + } + + if(endsInStr != null) { + long timeUntilEnd = 0; + + String timeStr = Utils.cleanColour(endsInStr); + + for(Map.Entry timeEntry : timeParseMap.entrySet()) { + Matcher matcher = timeEntry.getKey().matcher(timeStr); + if(matcher.find()) { + String days = matcher.group(1); + timeUntilEnd += Long.parseLong(days) * timeEntry.getValue(); + } + } + + return timeUntilEnd; + } + + return -1; + } + + public String findEndsInStr(ItemStack stack) { + if(stack.hasTagCompound()) { + //§7Ends in: + String endsIn = EnumChatFormatting.GRAY+"Ends in: "; + for(String line : manager.getLoreFromNBT(stack.getTagCompound())) { + if(line.trim().startsWith(endsIn)) { + return line.substring(endsIn.length()); + } + } + } + + return null; + } + public void drawScreen(int mouseX, int mouseY) { if(System.currentTimeMillis() - lastOpen < 1000) Mouse.setGrabbed(false); @@ -335,96 +424,158 @@ public class CustomAH extends Gui { int width = scaledResolution.getScaledWidth(); int height = scaledResolution.getScaledHeight(); - //Dark background - drawGradientRect(0, 0, width, height, -1072689136, -804253680); - if(searchField == null || priceField == null) init(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - tl.handleKeyboardInput(); - guiLeft = (width - getXSize())/2; guiTop = (height - getYSize())/2; this.searchField.xPosition = guiLeft + 82; this.searchField.yPosition = guiTop + 6; - this.searchField.setFocused(true); - this.priceField.setFocused(false); - if(!isEditingPrice()) priceField.setText("IAUSHDIUAH"); + if((Minecraft.getMinecraft().currentScreen instanceof GuiChest || + Minecraft.getMinecraft().currentScreen instanceof GuiEditSign) && currentAucId == null) { + Minecraft.getMinecraft().displayGuiScreen(null); + } + List tooltipToRender = null; if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + resetCurrAucIdTimer = System.currentTimeMillis(); GuiChest auctionView = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest container = (ContainerChest) auctionView.inventorySlots; + String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText(); float slideAmount = 1-Math.max(0, Math.min(1, (System.currentTimeMillis() - lastGuiScreenSwitch)/200f)); int auctionViewLeft = guiLeft+getXSize()+4 - (int)(slideAmount*(78+4)); - Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view); - this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172); + if(containerName.trim().equals("Auction View") || containerName.trim().equals("BIN Auction View")) { + Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view); + this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172); - if(auctionViewLeft+31 > guiLeft+getXSize()) { - try { - ItemStack topStack = auctionView.inventorySlots.getSlot(13).getStack(); - ItemStack leftStack = auctionView.inventorySlots.getSlot(29).getStack(); - ItemStack middleStack = auctionView.inventorySlots.getSlot(31).getStack(); - ItemStack rightStack = auctionView.inventorySlots.getSlot(33).getStack(); + if(auctionViewLeft+31 > guiLeft+getXSize()) { + try { + ItemStack topStack = auctionView.inventorySlots.getSlot(13).getStack(); + ItemStack leftStack = auctionView.inventorySlots.getSlot(29).getStack(); + ItemStack middleStack = auctionView.inventorySlots.getSlot(31).getStack(); + ItemStack rightStack = auctionView.inventorySlots.getSlot(33).getStack(); - boolean isBin = isGuiFiller(leftStack) || isGuiFiller(leftStack); + boolean isBin = isGuiFiller(leftStack) || isGuiFiller(leftStack); - if(isBin) { - leftStack = middleStack; - middleStack = null; - } - Utils.drawItemStack(leftStack, auctionViewLeft+31, guiTop+100); - - if(!isGuiFiller(leftStack)) { - NBTTagCompound tag = leftStack.getTagCompound(); - NBTTagCompound display = tag.getCompoundTag("display"); - if (display.hasKey("Lore", 9)) { - NBTTagList list = display.getTagList("Lore", 8); - String line2 = list.getStringTagAt(1); - line2 = Utils.cleanColour(line2); - StringBuilder priceNumbers = new StringBuilder(); - for(int i=0; i= 48 && (int)c <= 57) { - priceNumbers.append(c); + if(isBin) { + leftStack = middleStack; + middleStack = null; + } + + String endsInStr = findEndsInStr(topStack); + if(endsInStr != null) { + long auctionViewEndsIn = prettyTimeToMillis(endsInStr); + if(auctionViewEndsIn > 0) { + if(System.currentTimeMillis() - currAucIdSetTimer > 1000) { + AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(currentAucId); + if(auc != null) { +