diff options
author | BuildTools <james.jenour@protonmail.com> | 2020-07-08 16:28:49 +1000 |
---|---|---|
committer | BuildTools <james.jenour@protonmail.com> | 2020-07-08 16:28:49 +1000 |
commit | 7bdf7f256fe3968fe7129928c0a7100c30628bf9 (patch) | |
tree | 222deed2be57223e3b1703a638843fbf21a254e7 | |
parent | f39c28236bc47a9e5395b041b494fdd7f332734e (diff) | |
download | NotEnoughUpdates-7bdf7f256fe3968fe7129928c0a7100c30628bf9.tar.gz NotEnoughUpdates-7bdf7f256fe3968fe7129928c0a7100c30628bf9.tar.bz2 NotEnoughUpdates-7bdf7f256fe3968fe7129928c0a7100c30628bf9.zip |
1.9.7
14 files changed, 1042 insertions, 372 deletions
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<Math.min(craftMatrix.length, 9); i++) { if(craftMatrix[i] == null) continue; @@ -35,6 +41,8 @@ public class GuiItemRecipe extends GuiCrafting { } protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + setContents(); + String t = text.equals("") ? I18n.format("container.crafting", new Object[0]) : text; Utils.drawStringScaledMaxWidth(t, fontRendererObj, 28, 6, t.contains("\u00a7"), xSize-38, 4210752); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiItemUsages.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiItemUsages.java index 06fc3d71..a56293e9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/GuiItemUsages.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiItemUsages.java @@ -66,6 +66,8 @@ public class GuiItemUsages extends GuiCrafting { protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { String t = "Crafting Usages"; + setIndex(currentIndex); + int guiX = mouseX - guiLeft; int guiY = mouseY - guiTop; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java index ec44474e..573e20cf 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java @@ -24,6 +24,7 @@ public class GuiTextures { public static final ResourceLocation item_mask = new ResourceLocation("notenoughupdates:item_mask.png"); public static final ResourceLocation auction_view = new ResourceLocation("notenoughupdates:auction_view.png"); + public static final ResourceLocation auction_accept = new ResourceLocation("notenoughupdates:auction_accept.png"); public static final ResourceLocation auction_price = new ResourceLocation("notenoughupdates:auction_price.png"); public static final ResourceLocation auction_view_buttons = new ResourceLocation("notenoughupdates:auction_view_buttons.png"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index c1056108..f3263e0f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -7,6 +7,7 @@ import io.github.moulberry.notenoughupdates.options.Options; import io.github.moulberry.notenoughupdates.util.HypixelApi; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; +import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -323,10 +324,12 @@ public class NEUManager { * Parses a file in to a JsonObject. */ public JsonObject getJsonFromFile(File file) throws IOException { - InputStream in = new FileInputStream(file); - BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)); - JsonObject json = gson.fromJson(reader, JsonObject.class); - return json; + try { + InputStream in = new FileInputStream(file); + BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)); + JsonObject json = gson.fromJson(reader, JsonObject.class); + return json; + } catch(Exception e) { return null; } } /** @@ -433,7 +436,12 @@ public class NEUManager { currentlyInstalledItems.add(f.getName().substring(0, f.getName().length()-5)); } - Set<String> removedItems = neuio.getRemovedItems(currentlyInstalledItems); + Set<String> 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<list.tagCount(); k++) { - lore[k] = list.getStringTagAt(k); - } + if(ea.hasKey("id", 8)) { + internalname = ea.getString("id"); } + } + return internalname; + } + + public String[] getLoreFromNBT(NBTTagCompound tag) { + String[] lore = new String[0]; + NBTTagCompound display = tag.getCompoundTag("display"); - Item itemMc = Item.getItemById(id); - String itemid = "null"; - if(itemMc != null) { - itemid = itemMc.getRegistryName(); + if(display.hasKey("Lore", 9)) { + NBTTagList list = display.getTagList("Lore", 8); + lore = new String[list.tagCount()]; + for(int k=0; k<list.tagCount(); k++) { + lore[k] = list.getStringTagAt(k); } - String displayname = display.getString("Name"); - String[] info = new String[0]; - String clickcommand = ""; + } + return lore; + } + public JsonObject getJsonFromNBT(NBTTagCompound tag) { + 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"); - //public JsonObject createItemJson(String internalname, String itemid, String displayname, String[] lore, - // String crafttext, String infoType, String[] info, - // String clickcommand, int damage, NBTTagCompound nbttag) { + if(id == 141) id = 391; //for some reason hypixel thinks carrots have id 141 - JsonObject item = new JsonObject(); - item.addProperty("internalname", internalname); - item.addProperty("itemid", itemid); - item.addProperty("displayname", displayname); + String internalname = getInternalnameFromNBT(tag); - if(lore != null && lore.length > 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<String> internalname = new AtomicReference<>(null); AtomicReference<ItemStack> 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<Integer> needUpdate = new LinkedList<>(); + private TreeMap<String, Auction> auctionMap = new TreeMap<>(); + public HashMap<String, HashSet<String>> internalnameToAucIdMap = new HashMap<>(); + private HashSet<String> playerBids = new HashSet<>(); - public TreeMap<String, HashMap<String, List<Integer>>> extrasToAucIdMap = new TreeMap<>(); + public TreeMap<String, HashSet<String>> 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<String> getPlayerBids() { + return playerBids; + } + + public HashSet<String> 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<String> toRemove = new HashSet<>(); for(Map.Entry<String, Auction> 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<String> aucids : extrasToAucIdMap.values()) { + for(String aucid : toRemove) { + aucids.remove(aucid); + } + } + for(HashSet<String> 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<String> aucs = new HashSet<>(); + for(HashSet<String> aucids : internalnameToAucIdMap.values()) { + aucs.addAll(aucids); + } + internalnameTaggedAuctions = aucs.size(); + totalTags = extrasToAucIdMap.size(); + aucs = new HashSet<>(); + for(HashSet<String> 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<String> 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<bids.size(); j++) { + JsonObject bid = bids.get(j).getAsJsonObject(); + if(bid.get("bidder").getAsString().equalsIgnoreCase(playerUUID)) { + playerBids.add(auctionUuid); } - extrasToAucIdMap.get(str).get(auctionUuid).add(wordIndex); - wordIndex++; } //Categories - String category = sbCategory; //§6§lLEGENDARY FISHING ROD + String category = sbCategory; int itemType = checkItemType(item_lore, "SWORD", "FISHING ROD", "PICKAXE", "AXE", "SHOVEL", "PET ITEM", "TRAVEL SCROLL", "REFORGE STONE", "BOW"); if(itemType >= 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<String> auctionIds = new ArrayList<>(); + private HashSet<String> auctionIds = new HashSet<>(); + private List<String> 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<String> getTooltipForAucId(String aucId) { - AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucId); - - List<String> 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<String> getTooltipForAucId(String aucId) { + AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucId); + + List<String> 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<Pattern, Long> 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<Pattern, Long> 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<String> 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<line2.length(); i++) { - char c = line2.charAt(i); - if((int)c >= 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) { + auc.end = auctionViewEndsIn + lastGuiScreenSwitch; + } } + endsInStr = EnumChatFormatting.DARK_PURPLE+prettyTime( + auctionViewEndsIn + lastGuiScreenSwitch - System.currentTimeMillis()); } - if(priceNumbers.length() > 0) { - startingBid = Integer.parseInt(priceNumbers.toString()); + Utils.drawStringCenteredScaledMaxWidth(endsInStr, Minecraft.getMinecraft().fontRendererObj, + auctionViewLeft+39, guiTop+20, false, 70, 4210752); + } + + 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<line2.length(); i++) { + char c = line2.charAt(i); + if((int)c >= 48 && (int)c <= 57) { + priceNumbers.append(c); + } + } + if(priceNumbers.length() > 0) { + startingBid = Integer.parseInt(priceNumbers.toString()); + } } } - } - Utils.drawItemStack(topStack, auctionViewLeft+31, guiTop+35); + Utils.drawItemStack(topStack, auctionViewLeft+31, guiTop+35); - if(!isGuiFiller(middleStack)) { - Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons); - boolean hover = mouseX > auctionViewLeft+31 && mouseX <auctionViewLeft+31+16 && - mouseY > guiTop+126 && mouseY < guiTop+126+16; - this.drawTexturedModalRect(auctionViewLeft+31, guiTop+126, hover?16:0, 0, 16, 16); - } else { - middleStack = null; + if(!isGuiFiller(middleStack)) { + Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons); + boolean hover = mouseX > auctionViewLeft+31 && mouseX <auctionViewLeft+31+16 && + mouseY > guiTop+126 && mouseY < guiTop+126+16; + this.drawTexturedModalRect(auctionViewLeft+31, guiTop+126, hover?16:0, 0, 16, 16); + } else { + middleStack = null; + } + + if(mouseX > auctionViewLeft+31 && mouseX <auctionViewLeft+31+16) { + if(mouseY > guiTop+35 && mouseY < guiTop+35+16) { + if(topStack != null) tooltipToRender = topStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + } else if(mouseY > guiTop+100 && mouseY < guiTop+100+16) { + if(leftStack != null) tooltipToRender = leftStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + } else if(mouseY > guiTop+61 && mouseY < guiTop+61+16) { + if(rightStack != null) tooltipToRender = rightStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + } else if(mouseY > guiTop+126 && mouseY < guiTop+126+16) { + if(middleStack != null) tooltipToRender = middleStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + } + } + } catch(NullPointerException e) { //i cant be bothered } + } + } else if(containerName.trim().equals("Confirm Bid")) { + + Minecraft.getMinecraft().getTextureManager().bindTexture(auction_accept); + this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172); - if(mouseX > auctionViewLeft+31 && mouseX <auctionViewLeft+31+16) { - if(mouseY > guiTop+35 && mouseY < guiTop+35+16) { - if(topStack != null) tooltipToRender = topStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); - } else if(mouseY > guiTop+100 && mouseY < guiTop+100+16) { - if(leftStack != null) tooltipToRender = leftStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); - } else if(mouseY > guiTop+61 && mouseY < guiTop+61+16) { - if(rightStack != null) tooltipToRender = rightStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); - } else if(mouseY > guiTop+126 && mouseY < guiTop+126+16) { - if(middleStack != null) tooltipToRender = middleStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + if(auctionViewLeft+31 > guiLeft+getXSize()) { + try { + ItemStack leftStack = auctionView.inventorySlots.getSlot(11).getStack(); + ItemStack middleStack = auctionView.inventorySlots.getSlot(13).getStack(); + ItemStack rightStack = auctionView.inventorySlots.getSlot(15).getStack(); + + Utils.drawItemStack(middleStack, auctionViewLeft+31, guiTop+78); + + boolean topHovered = false; + boolean bottomHovered = false; + + if(mouseX > auctionViewLeft+31 && mouseX <auctionViewLeft+31+16) { + if(mouseY > guiTop+31 && mouseY < guiTop+31+16) { + if(leftStack != null) { + topHovered = true; + tooltipToRender = leftStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + } + } else if(mouseY > guiTop+125 && mouseY < guiTop+125+16) { + if(rightStack != null) { + bottomHovered = true; + tooltipToRender = rightStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + } + } else if(mouseY > guiTop+78 && mouseY < guiTop+78+16) { + if(middleStack != null) tooltipToRender = middleStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + } } + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons); + this.drawTexturedModalRect(auctionViewLeft+31, guiTop+31, topHovered?16:0, 48, 16, 16); + this.drawTexturedModalRect(auctionViewLeft+31, guiTop+125, bottomHovered?16:0, 64, 16, 16); + } catch(NullPointerException blah) { //i cant be bothered } - } catch(NullPointerException e) { //i cant be bothered } } + + Utils.drawStringCenteredScaledMaxWidth(containerName, Minecraft.getMinecraft().fontRendererObj, + auctionViewLeft+39, guiTop+10, false, 70, 4210752); } else if(isEditingPrice()) { + resetCurrAucIdTimer = System.currentTimeMillis(); float slideAmount = 1-Math.max(0, Math.min(1, (System.currentTimeMillis() - lastGuiScreenSwitch)/200f)); int auctionViewLeft = guiLeft+getXSize()+4 - (int)(slideAmount*(96+4)); @@ -439,6 +590,9 @@ public class CustomAH extends Gui { this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 96, 99); priceField.drawTextBox(); + Utils.drawStringCenteredScaledMaxWidth("Bid Amount", Minecraft.getMinecraft().fontRendererObj, + auctionViewLeft+39, guiTop+10, false, 70, 4210752); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons); this.drawTexturedModalRect(auctionViewLeft+16, guiTop+32, 0, 16, 30, 16); @@ -465,9 +619,25 @@ public class CustomAH extends Gui { "tileSign", "field_146848_f"); tes.lineBeingEdited = 0; tes.signText[0] = new ChatComponentText(priceField.getText()); + } else { + if(System.currentTimeMillis() - resetCurrAucIdTimer > 500 && + System.currentTimeMillis() - currAucIdSetTimer > 500) { + currentAucId = null; + currAucIdSetTimer = System.currentTimeMillis(); + } } Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + if(mouseY > guiTop-28 && mouseY < guiTop+4) { + if(mouseX > guiLeft && mouseX < guiLeft+168) { + int offset = mouseX-guiLeft; + int hoveredCat = offset/28; + if(hoveredCat >= 0 && hoveredCat < mainCategories.length) { + tooltipToRender = Utils.createList(mainCategories[hoveredCat].displayName); + } + } + } if(clickedMainCategory == -1) { this.drawTexturedModalRect(guiLeft, guiTop-28, 0, 0, 168, 32); } else { @@ -475,16 +645,31 @@ public class CustomAH extends Gui { this.drawTexturedModalRect(guiLeft, guiTop-28, 0, 0, selStart, 32); this.drawTexturedModalRect(guiLeft+selStart+28, guiTop-28, selStart+28, 0, 168-selStart-28, 32); + if(clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) { Category mainCategory = mainCategories[clickedMainCategory]; - for(int i=0; i<mainCategory.subcategories.length; i++) { + if(mouseX > guiLeft-28 && mouseX < guiLeft) { + int offset = mouseY-(guiTop+17); + if(offset > 0) { + int hovered = offset/28-1; + if(hovered < 0) { + tooltipToRender = Utils.createList(mainCategory.displayName); + } else if(hovered < mainCategory.subcategories.length) { + tooltipToRender = Utils.createList(mainCategory.subcategories[hovered].displayName); + } + } + } + + for(int i=-1; i<mainCategory.subcategories.length; i++) { if(i != clickedSubCategory) drawCategorySide(i); } } } + //Main GUI Minecraft.getMinecraft().getTextureManager().bindTexture(creativeTabSearch); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, getXSize(), ySplit); int y = guiTop+ySplit; for(int i=0; i<splits; i++) { @@ -493,17 +678,24 @@ public class CustomAH extends Gui { } this.drawTexturedModalRect(guiLeft, y, 0, ySplit, getXSize(), 136-ySplit); + //GUI Name + Utils.drawStringCenteredScaledMaxWidth("Auction House", Minecraft.getMinecraft().fontRendererObj, guiLeft+42, + guiTop+10, false, 68, 4210752); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + //Categories Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); if(clickedMainCategory != -1) { int selStart = clickedMainCategory*28; - this.drawTexturedModalRect(guiLeft+selStart, guiTop-28, 28, 32, 28, 32); + this.drawTexturedModalRect(guiLeft+selStart, guiTop-28, clickedMainCategory==0?0:28, 32, 28, 32); if(clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) { Category mainCategory = mainCategories[clickedMainCategory]; - if(clickedSubCategory >= 0 && clickedSubCategory < mainCategory.subcategories.length) { + if(clickedSubCategory >= -1 && clickedSubCategory < mainCategory.subcategories.length) { drawCategorySide(clickedSubCategory); } } @@ -517,8 +709,9 @@ public class CustomAH extends Gui { if(clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) { Category mainCategory = mainCategories[clickedMainCategory]; + Utils.drawItemStack(mainCategory.displayItem, guiLeft-19, guiTop+23); for(int i=0; i<mainCategory.subcategories.length; i++) { - Utils.drawItemStack(mainCategory.subcategories[i].displayItem, guiLeft-19, guiTop+23+28*i); + Utils.drawItemStack(mainCategory.subcategories[i].displayItem, guiLeft-19, guiTop+23+28*(i+1)); } } @@ -546,7 +739,7 @@ public class CustomAH extends Gui { if(auctionIds.size() <= id) break out; try { - String aucid = auctionIds.get(id); + String aucid = sortedAuctionIds.get(id); GL11.glTranslatef(0,0,100); ItemStack stack = manager.auctionManager.getAuctionItems().get(aucid).getStack(); @@ -568,14 +761,14 @@ public class CustomAH extends Gui { searchField.drawTextBox(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - if(auctionIds.size() == 0 && searchField.getText().length() == 0) { + /*if(auctionIds.size() == 0 && searchField.getText().length() == 0) { drawRect(guiLeft+8, guiTop+17, guiLeft+170, guiTop+107+18*splits, new Color(100, 100, 100, 100).getRGB()); FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; int strWidth = fr.getStringWidth("Loading items..."); fr.drawString("Loading items...", guiLeft+(8+170-strWidth)/2, guiTop+(17+107+18*splits)/2, Color.BLACK.getRGB()); - } + }*/ Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); @@ -594,8 +787,13 @@ public class CustomAH extends Gui { public List<String> getTooltipForControl(int index) { List<String> lore = new ArrayList<>(); + if(index < 0 || index >= controls.length) return lore; + if(controls[index] == null) return lore; + + lore.add(controls[index].getDisplayName()); String arrow = "\u25b6"; - String selPrefix = EnumChatFormatting.DARK_AQUA + " " + arrow + " "; + String selPrefixNC = " " + arrow + " "; + String selPrefix = EnumChatFormatting.DARK_AQUA + selPrefixNC; String unselPrefix = EnumChatFormatting.GRAY.toString(); switch(index) { case 0: break; @@ -616,10 +814,11 @@ public class CustomAH extends Gui { return lore; case 2: lore.add(""); - lore.add(rarityFilter == -1 ? selPrefix : unselPrefix + "No Filter"); + lore.add((rarityFilter == -1 ? EnumChatFormatting.DARK_GRAY+selPrefixNC : unselPrefix) + "No Filter"); for(int i=0; i<rarities.length; i++) { - lore.add(rarityFilter == i ? selPrefix : unselPrefix + "Filter " + rarities[i]); + lore.add((rarityFilter == i ? rarityColours[i]+selPrefixNC : unselPrefix) + + Utils.prettyCase(rarities[i])); } lore.add(""); lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!"); @@ -651,8 +850,40 @@ public class CustomAH extends Gui { lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!"); lore.add(EnumChatFormatting.YELLOW + "Click to switch filter!"); return lore; - case 7: break; - case 8: break; + case 7: + lore.add(""); + String[] linesEnch = {"Show All","Clean Only","Ench Only","Ench/HPB Only"}; + for(int i=0; i<linesEnch.length; i++) { + String line = linesEnch[i]; + if(i == enchFilter) { + line = selPrefix + line; + } else { + line = unselPrefix + line; + } + lore.add(line); + } + lore.add(""); + lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!"); + lore.add(EnumChatFormatting.YELLOW + "Click to switch filter!"); + return lore; + case 8: + lore.add(""); + lore.add("Current aucid: " + currentAucId); + lore.add(" --- Processing"); + lore.add("Page Process Millis: " + manager.auctionManager.processMillis); + lore.add(" --- Auction Stats"); + lore.add("Active Auctions: " + manager.auctionManager.activeAuctions); + lore.add("Tracked Auctions: " + manager.auctionManager.getAuctionItems().size()); + lore.add("Displayed Auctions: " + auctionIds.size()); + lore.add("Tracked Player Auctions: " + manager.auctionManager.getPlayerBids().size()); + lore.add("Unique Items: " + manager.auctionManager.uniqueItems); + lore.add("ID Tagged Auctions: " + manager.auctionManager.internalnameTaggedAuctions); + lore.add("Total Tags: " + manager.auctionManager.totalTags); + lore.add("Tagged Auctions: " + manager.auctionManager.taggedAuctions); + lore.add(""); + lore.add(EnumChatFormatting.AQUA + "Right-Click to copy current aucid to clipboard!"); + lore.add(EnumChatFormatting.YELLOW + "Click to refresh!"); + return lore; } return new ArrayList<>(); } @@ -712,90 +943,226 @@ public class CustomAH extends Gui { return mainCategory.subcategories[clickedSubCategory]; } + private boolean doesAucMatch(AuctionManager.Auction auc) { + if(auc == null) return false; + + Category currentCategory = getCurrentCategory(); + + boolean match = true; + if(currentCategory != null) { + match = false; + String[] categories = currentCategory.getTotalCategories(); + for(String category : categories) { + match |= category.equalsIgnoreCase(auc.category); + } + } + + if(rarityFilter >= 0 && rarityFilter < rarities.length) { + match &= rarities[rarityFilter].equals(auc.rarity); + } + + if(binFilter == BIN_FILTER_BIN) { + match &= auc.bin; + } else if(binFilter == BIN_FILTER_AUC) { + match &= !auc.bin; + } + + if(enchFilter > ENCH_FILTER_ALL) { + switch(enchFilter) { + case ENCH_FILTER_CLEAN: + match &= auc.enchLevel == 0; break; + case ENCH_FILTER_ENCH: + match &= auc.enchLevel >= 1; break; + case ENCH_FILTER_ENCHHPB: + match &= auc.enchLevel == 2; break; + } + } + + return match; + } + + private HashSet<String> search(String query, Set<String> dontMatch) { + query = query.trim(); + HashSet<String> matches = new HashSet<>(); + + Set<String> itemMatches = manager.search(query); + for(String internalname : itemMatches) { + for(String aucid : manager.auctionManager.getAuctionsForInternalname(internalname)) { + AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid); + if(doesAucMatch(auc)) { + matches.add(aucid); + } else { + dontMatch.add(aucid); + } + } + } + + if(!query.contains(" ")) { + for(HashSet<String> aucids : manager.subMapWithKeysThatAreSuffixes(query, + manager.auctionManager.extrasToAucIdMap).values()) { + for(String aucid : aucids) { + AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid); + if(!dontMatch.contains(aucid) && doesAucMatch(auc)) { + matches.add(aucid); + } else { + dontMatch.add(aucid); + } + } + } + } + + return matches; + } + public void updateSearch() { if(searchField == null || priceField == null) init(); + /*if(searchField.getText().length() > 0 && searchField.getText().length() <= 2 && + System.currentTimeMillis() - lastSearchFieldUpdate < 200) { + shouldUpdateSearch = true; + return; + }*/ + + if(System.currentTimeMillis() - lastUpdateSearch < 500) { + shouldUpdateSearch = true; + return; + } + + System.out.println("Updating search:"+searchField.getText()); + + lastUpdateSearch = System.currentTimeMillis(); + shouldUpdateSearch = false; + scrollAmount = 0; - auctionIds.clear(); try { - if(searchField.getText().length() == 0) { - auctionIds.clear(); - auctionIds.addAll(manager.auctionManager.getAuctionItems().keySet()); - } else { - auctionIds.clear(); - auctionIds.addAll(manager.search(searchField.getText(), manager.auctionManager.extrasToAucIdMap)); - - if(!searchField.getText().trim().contains(" ")) { - StringBuilder sb = new StringBuilder(); - for(char c : searchField.getText().toCharArray()) { - sb.append(c).append(" "); + auctionIds.clear(); + if(filterMyAuctions) { + for(String aucid : manager.auctionManager.getPlayerBids()) { + AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid); + if(doesAucMatch(auc)) { + auctionIds.add(aucid); } - for(String aucid : manager.search(sb.toString(), manager.auctionManager.extrasToAucIdMap)) { - if(!auctionIds.contains(aucid)) { - auctionIds.add(aucid); - } + } + } else if(searchField.getText().length() == 0) { + for(Map.Entry<String, AuctionManager.Auction> entry : manager.auctionManager.getAuctionItems().entrySet()) { + if(doesAucMatch(entry.getValue())) { + auctionIds.add(entry.getKey()); } } - } - Category currentCategory = getCurrentCategory(); - Set<String> toRemove = new HashSet<>(); - String[] categories = new String[0]; - if(currentCategory != null) categories = currentCategory.getTotalCategories(); - for(String aucid : auctionIds) { - AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid); - if(auc != null) { - boolean match = categories.length == 0; - for(String category : categories) { - if (category.equalsIgnoreCase(auc.category)) { - match = true; - break; + } else { + String query = searchField.getText(); + Set<String> dontMatch = new HashSet<>(); + + HashSet<String> allMatch = new HashSet<>(); + if(query.contains("!")) { //only used for inverted queries, so dont need to populate unless ! in query + for(Map.Entry<String, AuctionManager.Auction> entry : manager.auctionManager.getAuctionItems().entrySet()) { + if(doesAucMatch(entry.getValue())) { + allMatch.add(entry.getKey()); + } else { + dontMatch.add(entry.getKey()); } } - if(rarityFilter > 0 && rarityFilter < rarities.length) { - if(!rarities[rarityFilter].equals(auc.rarity)) { - match = false; + } + + boolean invert = false; + + StringBuilder query2 = new StringBuilder(); + char lastOp = '|'; + for(char c : query.toCharArray()) { + if(query2.toString().trim().isEmpty() && c == '!') { + invert = true; + } else if(c == '|' || c == '&') { + if(lastOp == '|') { + HashSet<String> result = search(query2.toString(), dontMatch); + if(!invert) { + auctionIds.addAll(result); + } else { + HashSet<String> allClone = (HashSet<String>) allMatch.clone(); + allClone.removeAll(result); + auctionIds.addAll(allClone); + } + } else if(lastOp == '&') { + HashSet<String> result = search(query2.toString(), dontMatch); + if(!invert) { + auctionIds.retainAll(result); + } else { + auctionIds.removeAll(result); + } } + + query2 = new StringBuilder(); + invert = false; + lastOp = c; + } else { + query2.append(c); } - if(binFilter == BIN_FILTER_BIN) { - match &= auc.bin; - } else if(binFilter == BIN_FILTER_AUC) { - match &= !auc.bin; + } + if(lastOp == '|') { + HashSet<String> result = search(query2.toString(), dontMatch); + if(!invert) { + auctionIds.addAll(result); + } else { + HashSet<String> allClone = (HashSet<String>) allMatch.clone(); + allClone.removeAll(result); + auctionIds.addAll(allClone); } - - if(!match) { - toRemove.add(aucid); + } else if(lastOp == '&') { + HashSet<String> result = search(query2.toString(), dontMatch); + if(!invert) { + auctionIds.retainAll(result); + } else { + auctionIds.removeAll(result); } - } else { - toRemove.add(aucid); } } - auctionIds.removeAll(toRemove); sortItems(); - } catch(ConcurrentModificationException e) { - updateSearch(); + } catch(Exception e) { + shouldUpdateSearch = true; } } public void sortItems() throws ConcurrentModificationException { - auctionIds.sort((o1, o2) -> { - AuctionManager.Auction auc1 = manager.auctionManager.getAuctionItems().get(o1); - AuctionManager.Auction auc2 = manager.auctionManager.getAuctionItems().get(o2); - - if(auc1 == null) return 1; - if(auc2 == null) return -1; - - if(sortMode == SORT_MODE_HIGH) { - int price1 = Math.max(auc1.highest_bid_amount, auc1.starting_bid); - int price2 = Math.max(auc2.highest_bid_amount, auc2.starting_bid); - return price2 - price1; - } else if(sortMode == SORT_MODE_LOW) { - int price1 = Math.max(auc1.highest_bid_amount, auc1.starting_bid); - int price2 = Math.max(auc2.highest_bid_amount, auc2.starting_bid); - return price1 - price2; - } else { - return (int)(auc1.end - auc2.end); - } - }); + try { + sortedAuctionIds.clear(); + sortedAuctionIds.addAll(auctionIds); + sortedAuctionIds.sort((o1, o2) -> { + AuctionManager.Auction auc1 = manager.auctionManager.getAuctionItems().get(o1); + AuctionManager.Auction auc2 = manager.auctionManager.getAuctionItems().get(o2); + + if(auc1 == null) return 1; + if(auc2 == null) return -1; + + if(sortMode == SORT_MODE_HIGH) { + int price1 = Math.max(auc1.highest_bid_amount, auc1.starting_bid); + int price2 = Math.max(auc2.highest_bid_amount, auc2.starting_bid); + int diff = price2 - price1; + if(diff != 0) { + return diff; + } + } else if(sortMode == SORT_MODE_LOW) { + int price1 = Math.max(auc1.highest_bid_amount, auc1.starting_bid); + int price2 = Math.max(auc2.highest_bid_amount, auc2.starting_bid); + int diff = price1 - price2; + if(diff != 0) { + return diff; + } + } else { + long end1 = auc1.end; + long end2 = auc2.end; + + if(end1 < System.currentTimeMillis()) return 999999; + if(end2 < System.currentTimeMillis()) return -999999; + + int diff = (int)(end1 - end2); + if(diff != 0) { + return diff; + } + } + return o1.compareTo(o2); + }); + } catch(Exception e) { + shouldSortItems = true; + } } public boolean keyboardInput() { @@ -803,22 +1170,34 @@ public class CustomAH extends Gui { if(isEditingPrice() && Keyboard.getEventKey() == Keyboard.KEY_RETURN) { Minecraft.getMinecraft().displayGuiScreen(null); } else if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { + if(Minecraft.getMinecraft().currentScreen instanceof GuiEditSign) { + priceField.setText(""); + GuiEditSign editSign = (GuiEditSign) Minecraft.getMinecraft().currentScreen; + TileEntitySign tes = (TileEntitySign)Utils.getField(GuiEditSign.class, editSign, + "tileSign", "field_146848_f"); + tes.lineBeingEdited = 0; + tes.signText[0] = new ChatComponentText(priceField.getText()); + } return false; } - if(Keyboard.getEventKeyState()) keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); + if(Keyboard.getEventKeyState()) return keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); return true; } - public void keyTyped(char typedChar, int keyCode) { + public boolean keyTyped(char typedChar, int keyCode) { if(searchField == null || priceField == null) init(); if(!isEditingPrice()) { if(this.searchField.textboxKeyTyped(typedChar, keyCode)) { + lastSearchFieldUpdate = System.currentTimeMillis(); this.updateSearch(); + return true; } } else { - priceField.textboxKeyTyped(typedChar, keyCode); + if(!priceField.isFocused()) priceField.setFocused(searchField.isFocused()); + return priceField.textboxKeyTyped(typedChar, keyCode); } + return false; } private void increasePriceByFactor(float factor) { @@ -842,6 +1221,7 @@ public class CustomAH extends Gui { protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { searchField.mouseClicked(mouseX, mouseY, mouseButton); + priceField.mouseClicked(mouseX, mouseY, mouseButton); int totalItems = auctionIds.size(); int itemsScroll = (int)Math.floor((totalItems*scrollAmount)/9f)*9; @@ -861,6 +1241,7 @@ public class CustomAH extends Gui { } clickedSubCategory = -1; updateSearch(); + Utils.playPressSound(); return; } } @@ -871,14 +1252,11 @@ public class CustomAH extends Gui { if(mouseX > guiLeft-28 && mouseX < guiLeft) { int offset = mouseY-(guiTop+17); if(offset > 0) { - int clicked = offset/28; - if(clicked == clickedSubCategory) { - clickedSubCategory = -1; - updateSearch(); - return; - } else if(clicked < mainCategory.subcategories.length) { + int clicked = offset/28-1; + if(clicked != clickedSubCategory && clicked < mainCategory.subcategories.length) { clickedSubCategory = clicked; updateSearch(); + Utils.playPressSound(); return; } } @@ -923,39 +1301,78 @@ public class CustomAH extends Gui { binFilter++; if(binFilter > BIN_FILTER_AUC) binFilter = BIN_FILTER_ALL; } - case 7: break; - case 8: break; + break; + case 7: + if(rightClicked) { + enchFilter--; + if(enchFilter < ENCH_FILTER_ALL) enchFilter = ENCH_FILTER_ENCHHPB; + } else { + enchFilter++; + if(enchFilter > ENCH_FILTER_ENCHHPB) enchFilter = ENCH_FILTER_ALL; + } + break; + case 8: + if(rightClicked) { + StringSelection selection = new StringSelection(niceAucId(currentAucId)); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); + } else { + manager.auctionManager.calculateStats(); + } } - sortItems(); - } - } - - for(int i=0; i<controls.length; i++) { - Utils.drawItemStack(controls[i], guiLeft+9+18*i, guiTop+112+18*splits); - } - - if(clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) { - Category mainCategory = mainCategories[clickedMainCategory]; - - for(int i=0; i<mainCategory.subcategories.length; i++) { - boolean clicked = i == clickedSubCategory; - Utils.drawTexturedRect(guiLeft-28, guiTop+17*28*i, 32, 28, - 0, 28/256f, 0+(clicked?32/256f:0), 32/256f+(clicked?32/256f:0)); + updateSearch(); + Utils.playPressSound(); } } if(mouseButton == 0 && Minecraft.getMinecraft().currentScreen instanceof GuiChest) { GuiChest auctionView = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest container = (ContainerChest) auctionView.inventorySlots; + String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText(); + + if(containerName.trim().equals("Auction View") || containerName.trim().equals("BIN Auction View")) { + if(mouseX > guiLeft+getXSize()+4+31 && mouseX < guiLeft+getXSize()+4+31+16) { + boolean leftFiller = isGuiFiller(auctionView.inventorySlots.getSlot(29).getStack());//isBin + if(mouseY > guiTop+100 && mouseY < guiTop+100+16) { + int slotClick = leftFiller ? 31 : 29; + Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId, + slotClick, 2, 3, Minecraft.getMinecraft().thePlayer); + + if(!leftFiller) { + if(auctionView.inventorySlots.getSlot(29).getStack() + .getDisplayName().trim().equals(EnumChatFormatting.GOLD+"Collect Auction")) { + manager.auctionManager.getPlayerBids().remove(currentAucId); + auctionIds.remove(currentAucId); + } + } - if(mouseX > guiLeft+getXSize()+4+31 && mouseX < guiLeft+getXSize()+4+31+16) { - boolean leftFiller = isGuiFiller(auctionView.inventorySlots.getSlot(29).getStack()); - if(mouseY > guiTop+100 && mouseY < guiTop+100+16) { - int slotClick = leftFiller ? 31 : 29; - Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId, - slotClick, 2, 3, Minecraft.getMinecraft().thePlayer); - } else if(mouseY > guiTop+126 && mouseY < guiTop+126+16 && !leftFiller) { - Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId, - 31, 2, 3, Minecraft.getMinecraft().thePlayer); + System.out.println(); + Utils.playPressSound(); + } else if(mouseY > guiTop+126 && mouseY < guiTop+126+16 && !leftFiller) { + priceField.setFocused(true); + Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId, + 31, 2, 3, Minecraft.getMinecraft().thePlayer); + Utils.playPressSound(); + } + } + } else if(containerName.trim().equals("Confirm Bid")) { + if(mouseX > guiLeft+getXSize()+4+31 && mouseX < guiLeft+getXSize()+4+31+16) { + if(mouseY > guiTop+31 && mouseY < guiTop+31+16) { + if(currentAucId != null) { + manager.auctionManager.getPlayerBids().add(currentAucId); + //reset timer to 2m if below + if(manager.auctionManager.getAuctionItems().get(currentAucId).end - + System.currentTimeMillis() < 2*60*1000) { + manager.auctionManager.getAuctionItems().get(currentAucId).end = + System.currentTimeMillis() + 2*60*1000; + } + } + Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId, + 11, 2, 3, Minecraft.getMinecraft().thePlayer); + } else if(mouseY > guiTop+125 && mouseY < guiTop+125+16) { + Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId, + 15, 2, 3, Minecraft.getMinecraft().thePlayer); + } + Utils.playPressSound(); } } } @@ -967,20 +1384,25 @@ public class CustomAH extends Gui { if(mouseX < auctionViewLeft+16+32) { //top left increasePriceByFactor(2); + Utils.playPressSound(); } else { //top right increasePriceByFactor(1.5f); + Utils.playPressSound(); } } else if(mouseY > guiTop+50 && mouseY < guiTop+50+16) { if(mouseX < auctionViewLeft+16+32) { //mid left increasePriceByFactor(1.25f); + Utils.playPressSound(); } else { //mid right increasePriceByFactor(1.1f); + Utils.playPressSound(); } } else if(mouseY > guiTop+68 && mouseY < guiTop+68+16) { //bottom + Utils.playPressSound(); Minecraft.getMinecraft().displayGuiScreen(null); } } @@ -1002,27 +1424,27 @@ public class CustomAH extends Gui { String aucid; try { - aucid = auctionIds.get(id); + aucid = sortedAuctionIds.get(id); } catch (IndexOutOfBoundsException e) { break out; } AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid); if(auc != null) { - long timeUntilEnd = auc.end - System.currentTimeMillis(); - - if(timeUntilEnd > 0) { - if(mouseX > itemX && mouseX < itemX+16) { - if(mouseY > itemY && mouseY < itemY+16) { - if(Minecraft.getMinecraft().currentScreen instanceof GuiEditSign) { - priceField.setText("cancel"); - GuiEditSign editSign = (GuiEditSign) Minecraft.getMinecraft().currentScreen; - TileEntitySign tes = (TileEntitySign)Utils.getField(GuiEditSign.class, editSign, - "tileSign", "field_146848_f"); - tes.lineBeingEdited = 0; - tes.signText[0] = new ChatComponentText(priceField.getText()); - } - startingBid = Math.max(auc.starting_bid, auc.highest_bid_amount); - NotEnoughUpdates.INSTANCE.sendChatMessage("/viewauction "+niceAucId(aucid)); + if(mouseX > itemX && mouseX < itemX+16) { + if(mouseY > itemY && mouseY < itemY+16) { + if(Minecraft.getMinecraft().currentScreen instanceof GuiEditSign) { + priceField.setText(""); + GuiEditSign editSign = (GuiEditSign) Minecraft.getMinecraft().currentScreen; + TileEntitySign tes = (TileEntitySign)Utils.getField(GuiEditSign.class, editSign, + "tileSign", "field_146848_f"); + tes.lineBeingEdited = 0; + tes.signText[0] = new ChatComponentText(priceField.getText()); } + startingBid = Math.max(auc.starting_bid, auc.highest_bid_amount); + currAucIdSetTimer = System.currentTimeMillis(); + currentAucId = aucid; + + Minecraft.getMinecraft().thePlayer.sendChatMessage("/viewauction "+niceAucId(aucid)); + Utils.playPressSound(); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java index 707e392b..8d53a152 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java @@ -37,6 +37,8 @@ public class CollectionLogInfoPane extends ScrollableInfoPane { private int previousAcquiredCount = 0; private int previousScroll = 0; + private int previousX = 0; + private int previousFilter = 0; private static final int FILTER_ALL = 0; private static final int FILTER_WEAPON = 1; @@ -270,12 +272,14 @@ public class CollectionLogInfoPane extends ScrollableInfoPane { scaledresolution.getScaleFactor()); if(!manager.config.cacheRenderedItempane.value || previousAcquiredCount != getCurrentAcquiredCount() || - previousScroll != scrollHeight.getValue()) { + previousScroll != scrollHeight.getValue() || previousX != left || previousFilter != filterMode) { renderItemsToImage(itemFramebuffer, fg, left+5, right, top+1, bottom); renderItemBGToImage(itemBGFramebuffer, fg, left+5, right, top+1, bottom); } previousAcquiredCount = getCurrentAcquiredCount(); previousScroll = scrollHeight.getValue(); + previousX = left; + previousFilter = filterMode; Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); renderFromImage(itemBGFramebuffer, width, height, left, right, top, bottom); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java index f28dae0b..ec5f8209 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java @@ -32,11 +32,11 @@ public class DevInfoPane extends TextInfoPane { text += item.getKey() + "\n"; } }*/ - for(String s : manager.neuio.getRemovedItems(manager.getItemInformation().keySet())) { + /*for(String s : manager.neuio.getRemovedItems(manager.getItemInformation().keySet())) { text += s + "\n"; } - if(true) return text; + if(true) return text;*/ /*for(Map.Entry<String, JsonObject> item : manager.getItemInformation().entrySet()) { if(!item.getValue().has("infoType") || item.getValue().get("infoType").getAsString().isEmpty()) { @@ -45,7 +45,13 @@ public class DevInfoPane extends TextInfoPane { }*/ //if(true) return text; - for(Map.Entry<String, JsonElement> entry : manager.getAuctionPricesJson().get("prices").getAsJsonObject().entrySet()) { + for(String internalname : manager.auctionManager.internalnameToAucIdMap.keySet()) { + if(!manager.getItemInformation().containsKey(internalname)) { + text += internalname + "\n"; + } + } + + /*for(Map.Entry<String, JsonElement> entry : manager.getAuctionPricesJson().get("prices").getAsJsonObject().entrySet()) { if(!manager.getItemInformation().keySet().contains(entry.getKey())) { if(entry.getKey().contains("-")) { continue; @@ -56,7 +62,7 @@ public class DevInfoPane extends TextInfoPane { } text += entry.getKey() + "\n"; } - } + }*/ return text; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java index 14cb2b26..9fad4e99 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java @@ -156,6 +156,7 @@ public class Options { arr.add("/enderchest:Ender Chest:ENDER_CHEST"); arr.add("/wardrobe:Wardrobe:LEATHER_CHESTPLATE"); arr.add("neucl:Collection Log:MAP"); + arr.add("neuah:NEU Auction House:GOLD_BLOCK"); return arr; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 0beee610..2084c609 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -5,6 +5,8 @@ import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; import io.github.moulberry.notenoughupdates.util.TexLoc; import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.audio.SoundHandler; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; @@ -19,6 +21,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.Session; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; @@ -123,6 +126,15 @@ public class Utils { return in.replaceAll("(?i)\\u00A7.", ""); } + public static String prettyCase(String str) { + return str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase(); + } + + public static void playPressSound() { + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create( + new ResourceLocation("gui.button.press"), 1.0F)); + } + public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) { GlStateManager.enableTexture2D(); GlStateManager.enableBlend(); @@ -293,6 +305,34 @@ public class Utils { return trim; } + public static void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor) { + float f = (float)(startColor >> 24 & 255) / 255.0F; + float f1 = (float)(startColor >> 16 & 255) / 255.0F; + float f2 = (float)(startColor >> 8 & 255) / 255.0F; + float f3 = (float)(startColor & 255) / 255.0F; + float f4 = (float)(endColor >> 24 & 255) / 255.0F; + float f5 = (float)(endColor >> 16 & 255) / 255.0F; + float f6 = (float)(endColor >> 8 & 255) / 255.0F; + float f7 = (float)(endColor & 255) / 255.0F; + GlStateManager.disableTexture2D(); + GlStateManager.enableBlend(); + GlStateManager.disableAlpha(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.shadeModel(7425); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + worldrenderer.pos((double)right, (double)top, 0).color(f1, f2, f3, f).endVertex(); + worldrenderer.pos((double)left, (double)top, 0).color(f1, f2, f3, f).endVertex(); + worldrenderer.pos((double)left, (double)bottom, 0).color(f5, f6, f7, f4).endVertex(); + worldrenderer.pos((double)right, (double)bottom, 0).color(f5, f6, f7, f4).endVertex(); + tessellator.draw(); + GlStateManager.shadeModel(7424); + GlStateManager.disableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + } + public static void drawHoveringText(List<String> textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font) { if (!textLines.isEmpty()) { diff --git a/src/main/resources/assets/notenoughupdates/auction_accept.png b/src/main/resources/assets/notenoughupdates/auction_accept.png Binary files differnew file mode 100644 index 00000000..fe5b1907 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/auction_accept.png diff --git a/src/main/resources/assets/notenoughupdates/auction_view_buttons.png b/src/main/resources/assets/notenoughupdates/auction_view_buttons.png Binary files differindex a76c02fa..408aacaf 100644 --- a/src/main/resources/assets/notenoughupdates/auction_view_buttons.png +++ b/src/main/resources/assets/notenoughupdates/auction_view_buttons.png |