summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorBuildTools <james.jenour@protonmail.com>2020-07-07 02:48:49 +1000
committerBuildTools <james.jenour@protonmail.com>2020-07-07 02:48:49 +1000
commitf39c28236bc47a9e5395b041b494fdd7f332734e (patch)
tree84c1c9b18577a0a18be1c08c514b4b7dae87dc20 /src/main
parent009ed0ef14d3a5fd75be17ed2c90688202e69c85 (diff)
downloadNotEnoughUpdates-f39c28236bc47a9e5395b041b494fdd7f332734e.tar.gz
NotEnoughUpdates-f39c28236bc47a9e5395b041b494fdd7f332734e.tar.bz2
NotEnoughUpdates-f39c28236bc47a9e5395b041b494fdd7f332734e.zip
ah nearly done
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/CustomAH.java553
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java144
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java15
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java49
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/StreamerMode.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/AuctionManager.java315
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java1055
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAHGui.java (renamed from src/main/java/io/github/moulberry/notenoughupdates/CustomAHGui.java)2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java25
9 files changed, 1447 insertions, 713 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomAH.java
deleted file mode 100644
index f0e3437f..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/CustomAH.java
+++ /dev/null
@@ -1,553 +0,0 @@
-package io.github.moulberry.notenoughupdates;
-
-import io.github.moulberry.notenoughupdates.util.TexLoc;
-import io.github.moulberry.notenoughupdates.util.Utils;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.Gui;
-import net.minecraft.client.gui.GuiTextField;
-import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.gui.inventory.GuiChest;
-import net.minecraft.client.gui.inventory.GuiEditSign;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntitySign;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.ResourceLocation;
-import org.lwjgl.input.Keyboard;
-import org.lwjgl.input.Mouse;
-import org.lwjgl.opengl.GL11;
-
-import java.awt.*;
-import java.text.NumberFormat;
-import java.util.*;
-import java.util.List;
-
-import static io.github.moulberry.notenoughupdates.GuiTextures.*;
-
-public class CustomAH extends Gui {
-
- private static final ResourceLocation creativeTabSearch = new ResourceLocation("textures/gui/container/creative_inventory/tab_item_search.png");
- private static final ResourceLocation creativeInventoryTabs = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png");
-
- private List<String> auctionIds = new ArrayList<>();
-
- private boolean scrollClicked = false;
-
- private int startingBid = 0;
-
- private GuiTextField searchField = null;
- private GuiTextField priceField = null;
-
- private boolean renderOverAuctionView = false;
- private long lastRenderDisable = 0;
-
- private int eventButton;
- private long lastMouseEvent;
-
- private int splits = 2;
-
- private int ySplit = 35;
- private int ySplitSize = 18;
-
- private float scrollAmount;
-
- private int guiLeft = 0;
- private int guiTop = 0;
-
- private NEUManager manager;
-
- public CustomAH(NEUManager manager) {
- this.manager = manager;
- }
-
- private void init() {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- this.searchField = new GuiTextField(0, fr, this.guiLeft + 82, this.guiTop + 6,
- 89, fr.FONT_HEIGHT);
- this.priceField = new GuiTextField(1, fr, this.guiLeft + 82, this.guiTop + 6,
- 89, fr.FONT_HEIGHT);
-
- this.searchField.setMaxStringLength(15);
- this.searchField.setEnableBackgroundDrawing(false);
- this.searchField.setTextColor(16777215);
- this.searchField.setVisible(true);
- this.searchField.setCanLoseFocus(false);
- this.searchField.setFocused(true);
- this.searchField.setText("");
-
- this.priceField.setMaxStringLength(10);
- this.priceField.setEnableBackgroundDrawing(false);
- this.priceField.setTextColor(16777215);
- this.priceField.setVisible(true);
- this.priceField.setCanLoseFocus(false);
- this.priceField.setFocused(false);
- this.priceField.setText("");
- }
-
- public boolean isRenderOverAuctionView() {
- return renderOverAuctionView || (System.currentTimeMillis() - lastRenderDisable) < 500;
- }
-
- public void setRenderOverAuctionView(boolean renderOverAuctionView) {
- if(this.renderOverAuctionView && !renderOverAuctionView) lastRenderDisable = System.currentTimeMillis();
- this.renderOverAuctionView = renderOverAuctionView;
- }
-
- private int getXSize() {
- return 195;
- }
-
- private int getYSize() {
- return 136 + ySplitSize*splits;
- }
-
- private TexLoc tl = new TexLoc(0, 0, Keyboard.KEY_M);
-
- public List<String> getTooltipForAucId(String aucId) {
- NEUManager.Auction auc = manager.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();
-
- 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) {
- endsIn += "Ended!";
- } else if(minutes == 0 && hours == 0 && days == 0) {
- endsIn += seconds + "s";
- } else if(hours==0 && days==0) {
- endsIn += minutes + "m" + seconds + "s";
- } else if(days==0) {
- if(hours <= 6) {
- endsIn += hours + "h" + minutes + "m" + seconds + "s";
- } else {
- endsIn += hours + "h";
- }
- } else {
- endsIn += days + "d" + hours + "h";
- }
-
- NumberFormat format = NumberFormat.getInstance(Locale.US);
-
- tooltip.add(EnumChatFormatting.DARK_GRAY+""+EnumChatFormatting.STRIKETHROUGH+"-----------------");
- tooltip.add(EnumChatFormatting.GRAY+"Seller: [CLICK TO SEE]");
-
- if(auc.bin) {
- tooltip.add(EnumChatFormatting.GRAY+"Buy it now: "+
- EnumChatFormatting.GOLD+format.format(auc.starting_bid));
- } else {
- if(auc.bid_count > 0) {
- tooltip.add(EnumChatFormatting.GRAY+"Bids: "+EnumChatFormatting.GREEN+auc.bid_count+" bids");
- tooltip.add("");
- tooltip.add(EnumChatFormatting.GRAY+"Top bid: "+
- EnumChatFormatting.GOLD+format.format(auc.highest_bid_amount));
- tooltip.add(EnumChatFormatting.GRAY+"Bidder: [CLICK TO SEE]");
- } else {
- tooltip.add(EnumChatFormatting.GRAY+"Starting bid: "+
- EnumChatFormatting.GOLD+format.format(auc.starting_bid));
- }
- }
-
- tooltip.add("");
- tooltip.add(EnumChatFormatting.GRAY+"Ends in: "+endsIn);
- tooltip.add("");
- tooltip.add(EnumChatFormatting.YELLOW+"Click to inspect!");
-
- return tooltip;
- }
-
- public boolean isEditingPrice() {
- return Minecraft.getMinecraft().currentScreen instanceof GuiEditSign;
- }
-
- public void drawScreen(int mouseX, int mouseY) {
- Mouse.setGrabbed(false);
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- 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");
-
- List<String> tooltipToRender = null;
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest auctionView = (GuiChest) Minecraft.getMinecraft().currentScreen;
-
- int auctionViewLeft = guiLeft+getXSize()+4;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view);
- this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172);
-
- try {
- ItemStack itemStack = auctionView.inventorySlots.getSlot(13).getStack();
- Utils.drawItemStack(itemStack, auctionViewLeft+31, guiTop+35);
-
- ItemStack bidStack = auctionView.inventorySlots.getSlot(29).getStack();
- Utils.drawItemStack(bidStack, auctionViewLeft+31, guiTop+100);
-
- ItemStack historyStack = auctionView.inventorySlots.getSlot(33).getStack();
-
- ItemStack changeBidStack = auctionView.inventorySlots.getSlot(31).getStack();
-
- if(changeBidStack != null && changeBidStack.getTagCompound().hasKey("AttributeModifiers")) {
- 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 {
- changeBidStack = null;
- }
-
- if(mouseX > auctionViewLeft+31 && mouseX <auctionViewLeft+31+16) {
- if(mouseY > guiTop+35 && mouseY < guiTop+35+16) {
- if(itemStack != null) tooltipToRender = itemStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- } else if(mouseY > guiTop+100 && mouseY < guiTop+100+16) {
- if(bidStack != null) tooltipToRender = bidStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- } else if(mouseY > guiTop+61 && mouseY < guiTop+61+16) {
- if(historyStack != null) tooltipToRender = historyStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- } else if(mouseY > guiTop+126 && mouseY < guiTop+126+16) {
- if(changeBidStack != null) tooltipToRender = changeBidStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- }
- } catch(NullPointerException e) { //i cant be bothered
- }
- } else if(isEditingPrice()) {
- int auctionViewLeft = guiLeft+getXSize()+4;
-
- if(priceField.getText().equals("IAUSHDIUAH")) priceField.setText(""+startingBid);
-
- searchField.setFocused(false);
- priceField.setFocused(true);
- priceField.xPosition = auctionViewLeft+18;
- priceField.yPosition = guiTop+18;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_price);
- this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 96, 99);
- priceField.drawTextBox();
-
- 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);
- this.drawTexturedModalRect(auctionViewLeft+16+34, guiTop+32, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft+16, guiTop+50, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft+16+34, guiTop+50, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft+16, guiTop+68, 0, 32, 64, 16);
-
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- Utils.drawStringCentered("x2", fr, auctionViewLeft+16+15, guiTop+32+8, false,
- Color.BLACK.getRGB());
- Utils.drawStringCentered("+50%", fr, auctionViewLeft+16+34+15, guiTop+32+8, false,
- Color.BLACK.getRGB());
- Utils.drawStringCentered("+25%", fr, auctionViewLeft+16+15, guiTop+50+8, false,
- Color.BLACK.getRGB());
- Utils.drawStringCentered("+10%", fr, auctionViewLeft+16+34+15, guiTop+50+8, false,
- Color.BLACK.getRGB());
- Utils.drawStringCentered("Set Amount", fr, auctionViewLeft+16+32, guiTop+68+8, false,
- Color.BLACK.getRGB());
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
-
- 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());
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(creativeTabSearch);
- this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, getXSize(), ySplit);
- int y = guiTop+ySplit;
- for(int i=0; i<splits; i++) {
- this.drawTexturedModalRect(guiLeft, y, 0, ySplit, getXSize(), ySplit+ySplitSize);
- y += ySplitSize;
- }
- this.drawTexturedModalRect(guiLeft, y, 0, ySplit, getXSize(), 136-ySplit);
-
- int totalItems = auctionIds.size();
- int itemsScroll = (int)Math.floor((totalItems*scrollAmount)/9f)*9;
-
- int maxItemScroll = Math.max(0, totalItems - (5+splits)*9);
- itemsScroll = Math.min(itemsScroll, maxItemScroll);
-
- out:
- for(int i=0; i<5+splits; i++) {
- int itemY = guiTop + i*18 + 18;
- for(int j=0; j<9; j++) {
- int itemX = guiLeft + j*18 + 9;
- int id = itemsScroll + i*9 + j;
- if(auctionIds.size() <= id) break out;
-
- try {
- String aucid = auctionIds.get(id);
-
- GL11.glTranslatef(0,0,100);
- ItemStack stack = manager.getAuctionItems().get(aucid).getStack();
- Utils.drawItemStack(stack, itemX, itemY);
- GL11.glTranslatef(0,0,-100);
-
- if(mouseX > itemX && mouseX < itemX+16) {
- if(mouseY > itemY && mouseY < itemY+16) {
- tooltipToRender = getTooltipForAucId(aucid);
- }
- }
- } catch(Exception e) {
- break out;
- }
- }
- }
-
- searchField.drawTextBox();
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
-
- 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);
- this.drawTexturedModalRect(guiLeft+175, guiTop+18+(int)((95+ySplitSize*2)*scrollAmount),
- 256-(scrollClicked?12:24), 0, 12, 15);
-
- if(tooltipToRender != null) {
- Utils.drawHoveringText(tooltipToRender, mouseX, mouseY, width,
- height, -1, Minecraft.getMinecraft().fontRendererObj);
- }
- }
-
- public void handleMouseInput() {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- int mouseX = Mouse.getEventX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getEventY() * height / Minecraft.getMinecraft().displayHeight - 1;
- int mouseButton = Mouse.getEventButton();
-
- if (Mouse.getEventButtonState()) {
- this.eventButton = mouseButton;
- this.lastMouseEvent = Minecraft.getSystemTime();
- mouseClicked(mouseX, mouseY, this.eventButton);
- } else if (mouseButton != -1) {
- this.eventButton = -1;
- mouseReleased(mouseX, mouseY, mouseButton);
- } else if (this.eventButton != -1 && this.lastMouseEvent > 0L) {
- long l = Minecraft.getSystemTime() - this.lastMouseEvent;
- mouseClickMove(mouseX, mouseY, this.eventButton, l);
- }
-
- int dWheel = Mouse.getDWheel();
-
- scrollAmount = scrollAmount - dWheel/((float)auctionIds.size()-(5+splits));
- scrollAmount = Math.max(0, Math.min(1, scrollAmount));
- }
-
- private String niceAucId(String aucId) {
- if(aucId.length()!=32) return aucId;
-
- StringBuilder niceAucId = new StringBuilder();
- niceAucId.append(aucId, 0, 8);
- niceAucId.append("-");
- niceAucId.append(aucId, 8, 12);
- niceAucId.append("-");
- niceAucId.append(aucId, 12, 16);
- niceAucId.append("-");
- niceAucId.append(aucId, 16, 20);
- niceAucId.append("-");
- niceAucId.append(aucId, 20, 32);
- return niceAucId.toString();
- }
-
- public void updateSearch() {
- scrollAmount = 0;
- auctionIds.clear();
- try {
- for(Map.Entry<String, NEUManager.Auction> entry : manager.getAuctionItems().entrySet()) {
- if(searchField.getText().length() == 0 ||
- Utils.cleanColour(entry.getValue().extras).toLowerCase().contains(searchField.getText().toLowerCase())) {
- auctionIds.add(entry.getKey());
- }
- }
- } catch(ConcurrentModificationException e) {
- updateSearch();
- }
- }
-
- public boolean keyboardInput() {
- if(isEditingPrice() && Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
- Minecraft.getMinecraft().displayGuiScreen(null);
- } else if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
- return false;
- }
- keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
- return true;
- }
-
- public void keyTyped(char typedChar, int keyCode) {
- if(searchField == null || priceField == null) init();
-
- if(!isEditingPrice()) {
- if(this.searchField.textboxKeyTyped(typedChar, keyCode)) {
- this.updateSearch();
- }
- } else {
- priceField.textboxKeyTyped(typedChar, keyCode);
- }
- }
-
- private void increasePriceByFactor(float factor) {
- String price = priceField.getText().trim();
- StringBuilder priceNumbers = new StringBuilder();
- for(int i=0; i<price.length(); i++) {
- char c = price.charAt(i);
- if((int)c >= 48 && (int)c <= 57) {
- priceNumbers.append(c);
- } else {
- break;
- }
- }
- int priceI = 0;
- if(priceNumbers.length() > 0) {
- priceI = Integer.parseInt(priceNumbers.toString());
- }
- String end = price.substring(priceNumbers.length());
- priceField.setText((int)(priceI*factor) + end);
- }
-
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
- searchField.mouseClicked(mouseX, mouseY, mouseButton);
-
- int totalItems = auctionIds.size();
- int itemsScroll = (int)Math.floor((totalItems*scrollAmount)/9f)*9;
-
- int maxItemScroll = Math.max(0, totalItems - (5+splits)*9);
- itemsScroll = Math.min(itemsScroll, maxItemScroll);
-
- if(mouseButton == 0 && Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest auctionView = (GuiChest) Minecraft.getMinecraft().currentScreen;
-
- if(mouseX > guiLeft+getXSize()+4+31 && mouseX < guiLeft+getXSize()+4+31+16) {
- if(mouseY > guiTop+100 && mouseY < guiTop+100+16) {
- Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId,
- 29, 2, 3, Minecraft.getMinecraft().thePlayer);
- } else if(mouseY > guiTop+126 && mouseY < guiTop+126+16) {
- Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId,
- 31, 0, 4, Minecraft.getMinecraft().thePlayer);
- }
- }
- }
- if(mouseButton == 0 && isEditingPrice()) {
- int auctionViewLeft = guiLeft+getXSize()+4;
- System.out.println("1");
-
- if(mouseX > auctionViewLeft+16 && mouseX < auctionViewLeft+16+64) {
- System.out.println("2");
- if(mouseY > guiTop+32 && mouseY < guiTop+32+16) {
- System.out.println("3");
- if(mouseX < auctionViewLeft+16+32) {
- //top left
- increasePriceByFactor(2);
- } else {
- //top right
- increasePriceByFactor(1.5f);
- }
- } else if(mouseY > guiTop+50 && mouseY < guiTop+50+16) {
- if(mouseX < auctionViewLeft+16+32) {
- //mid left
- increasePriceByFactor(1.25f);
- } else {
- //mid right
- increasePriceByFactor(1.1f);
- }
- } else if(mouseY > guiTop+68 && mouseY < guiTop+68+16) {
- //bottom
- Minecraft.getMinecraft().displayGuiScreen(null);
- }
- }
-
- this.drawTexturedModalRect(auctionViewLeft+16, guiTop+32, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft+16+34, guiTop+32, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft+16, guiTop+50, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft+16+34, guiTop+50, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft+16, guiTop+68, 0, 32, 64, 16);
- }
-
- out:
- for(int i=0; i<5+splits; i++) {
- int itemY = guiTop + i*18 + 18;
- for(int j=0; j<9; j++) {
- int itemX = guiLeft + j*18 + 9;
- int id = itemsScroll + i*9 + j;
- if(auctionIds.size() <= id) break out;
-
- String aucid;
- try {
- aucid = auctionIds.get(id);
- } catch (IndexOutOfBoundsException e) { break out; }
-
- NEUManager.Auction auc = manager.getAuctionItems().get(aucid);
- long timeUntilEnd = auc.end - System.currentTimeMillis();
-
- if(timeUntilEnd > 0) {
- if(mouseX > itemX && mouseX < itemX+16) {
- if(mouseY > itemY && mouseY < itemY+16) {
- startingBid = Math.max(auc.starting_bid, auc.highest_bid_amount);
- NotEnoughUpdates.INSTANCE.sendChatMessage("/viewauction "+niceAucId(aucid));
- }
- }
- }
-
-
- }
- }
-
- int y = guiTop+18+(int)((95+ySplitSize*2)*scrollAmount);
- if(mouseX > guiLeft+175 && mouseX < guiLeft+175+12) {
- if(mouseY > y && mouseY < y+15) {
- scrollClicked = true;
- return;
- }
- }
- scrollClicked = false;
- }
-
- protected void mouseReleased(int mouseX, int mouseY, int state) {
- scrollClicked = false;
- }
-
- protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- if(scrollClicked) {
- int yMin = guiTop+18 + 8;
- int yMax = guiTop+18+(95+ySplitSize*2) + 8;
-
- scrollAmount = (mouseY-yMin)/(float)(yMax-yMin);
- scrollAmount = Math.max(0, Math.min(1, scrollAmount));
- }
- }
-}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index 502cebe9..c1056108 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -1,6 +1,8 @@
package io.github.moulberry.notenoughupdates;
import com.google.gson.*;
+import io.github.moulberry.notenoughupdates.auction.AuctionManager;
+import io.github.moulberry.notenoughupdates.auction.CustomAH;
import io.github.moulberry.notenoughupdates.options.Options;
import io.github.moulberry.notenoughupdates.util.HypixelApi;
import net.minecraft.client.Minecraft;
@@ -32,10 +34,10 @@ public class NEUManager {
private final NotEnoughUpdates neu;
public final NEUIO neuio;
public final Gson gson;
+ public final AuctionManager auctionManager;
private TreeMap<String, JsonObject> itemMap = new TreeMap<>();
- private TreeMap<String, Set<String>> tagWordMap = new TreeMap<>();
private TreeMap<String, HashMap<String, List<Integer>>> titleWordMap = new TreeMap<>();
private TreeMap<String, HashMap<String, List<Integer>>> loreWordMap = new TreeMap<>();
@@ -60,13 +62,7 @@ public class NEUManager {
private JsonObject auctionPricesJson = null;
private long auctionLastUpdate = 0;
- private TreeMap<String, Auction> auctionItems = new TreeMap<>();
- public CustomAH customAH = new CustomAH(this);
-
- private HashMap<String, String> uuidToName = new HashMap<>();
-
private HashMap<String, CraftInfo> craftCost = new HashMap<>();
-
private HashMap<String, Set<String>> usagesMap = new HashMap<>();
public File configLocation;
@@ -80,6 +76,7 @@ public class NEUManager {
this.neu = neu;
this.configLocation = configLocation;
this.neuio = neuio;
+ this.auctionManager = new AuctionManager(this);
GsonBuilder gsonBuilder = new GsonBuilder().setPrettyPrinting();
gsonBuilder.registerTypeAdapter(Options.Option.class, Options.createSerializer());
@@ -108,47 +105,6 @@ public class NEUManager {
}
}
- public class Auction {
- public String auctioneerUuid;
- public long end;
- public int starting_bid;
- public int highest_bid_amount;
- public int bid_count;
- public boolean bin;
- public String category;
- public String extras;
- public String item_bytes;
- private ItemStack stack;
-
- public Auction(String auctioneerUuid, long end, int starting_bid, int highest_bid_amount, int bid_count,
- boolean bin, String category, String extras, String item_bytes) {
- this.auctioneerUuid = auctioneerUuid;
- this.end = end;
- this.starting_bid = starting_bid;
- this.highest_bid_amount = highest_bid_amount;
- this.bid_count = bid_count;
- this.bin = bin;
- this.category = category;
- this.extras = extras;
- this.item_bytes = item_bytes;
- }
-
- public ItemStack getStack() {
- if(stack != null) {
- return stack;
- } else {
- JsonObject item = getJsonFromItemBytes(item_bytes);
- ItemStack stack = jsonToStack(item, false);
- this.stack = stack;
- return stack;
- }
- }
- }
-
- public TreeMap<String, Auction> getAuctionItems() {
- return auctionItems;
- }
-
public class CraftInfo {
public boolean fromRecipe = false;
public boolean vanillaItem = false;
@@ -486,90 +442,6 @@ public class NEUManager {
}
}
- ScheduledExecutorService auctionUpdateSES = Executors.newSingleThreadScheduledExecutor();
- private AtomicInteger auctionUpdateId = new AtomicInteger(0);
- public void updateAuctions() {
- HashMap<Integer, JsonObject> pages = new HashMap<>();
-
- HashMap<String, String> args = new HashMap<>();
- args.put("page", "0");
- AtomicInteger totalPages = new AtomicInteger(1);
- AtomicInteger currentPages = new AtomicInteger(0);
- hypixelApi.getHypixelApiAsync(config.apiKey.value, "skyblock/auctions",
- args, jsonObject -> {
- if (jsonObject.get("success").getAsBoolean()) {
- pages.put(0, jsonObject);
- totalPages.set(jsonObject.get("totalPages").getAsInt());
- currentPages.incrementAndGet();
-
- for (int i = 1; i < totalPages.get(); i++) {
- int j = i;
- HashMap<String, String> args2 = new HashMap<>();
- args2.put("page", "" + i);
- hypixelApi.getHypixelApiAsync(config.apiKey.value, "skyblock/auctions",
- args2, jsonObject2 -> {
- if (jsonObject2.get("success").getAsBoolean()) {
- pages.put(j, jsonObject2);
- currentPages.incrementAndGet();
- } else {
- currentPages.incrementAndGet();
- }
- }
- );
- }
- }
- }
- );
-
- long startTime = System.currentTimeMillis();
-
- int currentAuctionUpdateId = auctionUpdateId.incrementAndGet();
-
- auctionUpdateSES.schedule(new Runnable() {
- public void run() {
- if(auctionUpdateId.get() != currentAuctionUpdateId) return;
- System.out.println(currentPages.get() + "/" + totalPages.get());
- if (System.currentTimeMillis() - startTime > 20000) return;
-
- if (currentPages.get() == totalPages.get()) {
- TreeMap<String, Auction> auctionItemsTemp = new TreeMap<>();
-
- for (int pageNum : pages.keySet()) {
- System.out.println(pageNum + "/" + pages.size());
- JsonObject page = pages.get(pageNum);
- JsonArray auctions = page.get("auctions").getAsJsonArray();
- for (int i = 0; i < auctions.size(); i++) {
- JsonObject auction = auctions.get(i).getAsJsonObject();
-
- String auctionUuid = auction.get("uuid").getAsString();
- String auctioneerUuid = auction.get("auctioneer").getAsString();
- long end = auction.get("end").getAsLong();
- int starting_bid = auction.get("starting_bid").getAsInt();
- int highest_bid_amount = auction.get("highest_bid_amount").getAsInt();
- int bid_count = auction.get("bids").getAsJsonArray().size();
- boolean bin = false;
- if(auction.has("bin")) {
- bin = auction.get("bin").getAsBoolean();
- }
- String category = auction.get("category").getAsString();
- String extras = auction.get("item_lore").getAsString().replaceAll("\n"," ") + " " +
- auction.get("extra").getAsString();
- String item_bytes = auction.get("item_bytes").getAsString();
-
- auctionItemsTemp.put(auctionUuid, new Auction(auctioneerUuid, end, starting_bid, highest_bid_amount,
- bid_count, bin, category, extras, item_bytes));
- }
- }
- auctionItems = auctionItemsTemp;
- customAH.updateSearch();
- return;
- }
-
- auctionUpdateSES.schedule(this, 1000L, TimeUnit.MILLISECONDS);
- }
- }, 3000L, TimeUnit.MILLISECONDS);
- }
-
/**
* Loads the item in to the itemMap and also stores various words associated with this item
* in to titleWordMap and loreWordMap. These maps are used in the searching algorithm.
@@ -836,7 +708,7 @@ public class NEUManager {
* follow a word matching the previous sub query. eg. "ench po" will match "enchanted pork" but will not match
* "pork enchanted".
*/
- private Set<String> search(String query, TreeMap<String, HashMap<String, List<Integer>>> wordMap) {
+ public Set<String> search(String query, TreeMap<String, HashMap<String, List<Integer>>> wordMap) {
HashMap<String, List<Integer>> matches = null;
query = clean(query).toLowerCase();
@@ -898,6 +770,7 @@ public class NEUManager {
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 = "";
@@ -948,6 +821,7 @@ public class NEUManager {
}
item.addProperty("damage", damage);
+ if(count > 1) item.addProperty("count", count);
item.addProperty("nbttag", tag.toString());
return item;
@@ -1390,6 +1264,10 @@ public class NEUManager {
ItemStack stack = new ItemStack(Item.itemRegistry.getObject(
new ResourceLocation(json.get("itemid").getAsString())));
+ if(json.has("count")) {
+ stack.stackSize = json.get("count").getAsInt();
+ }
+
if(stack.getItem() == null) {
stack = new ItemStack(Items.diamond, 1, 10); //Purple broken texture item
} else {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index 97964042..95ceb21f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -183,9 +183,9 @@ public class NEUOverlay extends Gui {
int mouseX = Mouse.getX() / scaledresolution.getScaleFactor();
int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor();
- if(lastMouseX != mouseX || lastMouseY != mouseY) {
- millisLastMouseMove = System.currentTimeMillis();
- }
+ //if(lastMouseX != mouseX || lastMouseY != mouseY) {
+ // millisLastMouseMove = System.currentTimeMillis();
+ //}
lastMouseX = mouseX;
lastMouseY = mouseY;
@@ -461,7 +461,7 @@ public class NEUOverlay extends Gui {
if(Minecraft.getMinecraft().currentScreen == null) return false;
Keyboard.enableRepeatEvents(true);
- int keyPressed = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() : Keyboard.getEventKey();
+ int keyPressed = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter()+256 : Keyboard.getEventKey();
if(disabled) {
if(Keyboard.getEventKeyState() && keyPressed == manager.keybindToggleDisplay.getKeyCode()) {
@@ -1307,6 +1307,7 @@ public class NEUOverlay extends Gui {
int scaledItemPaddedSize = (int)((ITEM_SIZE+ITEM_PADDING)*sortOrderScaleFactor);
int iconTop = height-getBoxPadding()-(ITEM_SIZE+scaledITEM_SIZE)/2-1;
+ boolean hoveredOverControl = false;
for(int i=0; i<orderIcons.length; i++) {
int orderIconX = leftSide+getBoxPadding()+getItemBoxXPadding()+i*scaledItemPaddedSize;
drawRect(orderIconX, iconTop,scaledITEM_SIZE+orderIconX,iconTop+scaledITEM_SIZE, fg.getRGB());
@@ -1322,6 +1323,7 @@ public class NEUOverlay extends Gui {
if(mouseY > iconTop && mouseY < iconTop+scaledITEM_SIZE) {
if(mouseX > orderIconX && mouseX < orderIconX+scaledITEM_SIZE) {
+ hoveredOverControl = true;
if(System.currentTimeMillis() - millisLastMouseMove > 400) {
String text = EnumChatFormatting.GRAY+"Order ";
if(i == COMPARE_MODE_ALPHABETICAL) text += "Alphabetically";
@@ -1344,6 +1346,7 @@ public class NEUOverlay extends Gui {
if(mouseY > iconTop && mouseY < iconTop+scaledITEM_SIZE) {
if(mouseX > sortIconX && mouseX < sortIconX+scaledITEM_SIZE) {
+ hoveredOverControl = true;
if(System.currentTimeMillis() - millisLastMouseMove > 400) {
String text = EnumChatFormatting.GRAY+"Filter ";
if(i == SORT_MODE_ALL) text = EnumChatFormatting.GRAY+"No Filter";
@@ -1359,6 +1362,10 @@ public class NEUOverlay extends Gui {
}
}
+ if(!hoveredOverControl) {
+ millisLastMouseMove = System.currentTimeMillis();
+ }
+
if(!hoverInv) {
iterateItemSlots(new ItemSlotConsumer() {
public void consume(int x, int y, int id) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 6d8e91e7..2946f930 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -6,6 +6,7 @@ import com.mojang.authlib.Agent;
import com.mojang.authlib.exceptions.AuthenticationException;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
+import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
import io.github.moulberry.notenoughupdates.commands.SimpleCommand;
import io.github.moulberry.notenoughupdates.infopanes.CollectionLogInfoPane;
import io.github.moulberry.notenoughupdates.util.Utils;
@@ -91,13 +92,13 @@ public class NotEnoughUpdates {
return s;
}
+ private GuiScreen openGui = null;
+
ScheduledExecutorService guiDelaySES = Executors.newScheduledThreadPool(1);
SimpleCommand collectionLogCommand = new SimpleCommand("neucl", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
- guiDelaySES.schedule(()->{
- Minecraft.getMinecraft().displayGuiScreen(new GuiInventory(Minecraft.getMinecraft().thePlayer));
- }, 20L, TimeUnit.MILLISECONDS);
+ openGui = new GuiInventory(Minecraft.getMinecraft().thePlayer);
}
manager.updatePrices();
overlay.displayInformationPane(new CollectionLogInfoPane(overlay, manager));
@@ -106,13 +107,10 @@ public class NotEnoughUpdates {
SimpleCommand neuAhCommand = new SimpleCommand("neuah", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
- guiDelaySES.schedule(()->{
- Minecraft.getMinecraft().displayGuiScreen(new CustomAHGui());
- Mouse.setGrabbed(false);
- }, 20L, TimeUnit.MILLISECONDS);
- manager.updateAuctions();
- }
+ openGui = new CustomAHGui();
+ manager.auctionManager.customAH.lastOpen = System.currentTimeMillis();
+ manager.auctionManager.customAH.clearSearch();
+ manager.auctionManager.customAH.updateSearch();
}
});
@@ -208,6 +206,13 @@ public class NotEnoughUpdates {
private HashMap<String, Long> newItemAddMap = new HashMap<>();
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
+ if(openGui != null) {
+ Minecraft.getMinecraft().displayGuiScreen(openGui);
+ openGui = null;
+ }
+ if(hasSkyblockScoreboard()) {
+ manager.auctionManager.tick();
+ }
if(currChatMessage != null && System.currentTimeMillis() - lastChatMessage > CHAT_MSG_COOLDOWN) {
lastChatMessage = System.currentTimeMillis();
Minecraft.getMinecraft().thePlayer.sendChatMessage(currChatMessage);
@@ -280,20 +285,22 @@ public class NotEnoughUpdates {
AtomicBoolean missingRecipe = new AtomicBoolean(false);
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event) {
- if(event.gui == null && manager.customAH.isRenderOverAuctionView() &&
+ manager.auctionManager.customAH.lastGuiScreenSwitch = System.currentTimeMillis();
+
+ if(event.gui == null && manager.auctionManager.customAH.isRenderOverAuctionView() &&
!(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui)) {
- //todo
+ event.gui = new CustomAHGui();
}
if(!(event.gui instanceof GuiChest || event.gui instanceof GuiEditSign)) {
- manager.customAH.setRenderOverAuctionView(false);
- } else if(event.gui instanceof GuiChest && (manager.customAH.isRenderOverAuctionView() ||
+ manager.auctionManager.customAH.setRenderOverAuctionView(false);
+ } else if(event.gui instanceof GuiChest && (manager.auctionManager.customAH.isRenderOverAuctionView() ||
Minecraft.getMinecraft().currentScreen instanceof CustomAHGui)){
GuiChest chest = (GuiChest) event.gui;
ContainerChest container = (ContainerChest) chest.inventorySlots;
String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
- manager.customAH.setRenderOverAuctionView(containerName.trim().equals("Auction View") ||
+ manager.auctionManager.customAH.setRenderOverAuctionView(containerName.trim().equals("Auction View") ||
containerName.trim().equals("BIN Auction View"));
}
@@ -497,9 +504,9 @@ public class NotEnoughUpdates {
@SubscribeEvent
public void onGuiScreenDrawPre(GuiScreenEvent.DrawScreenEvent.Pre event) {
- if(event.gui instanceof CustomAHGui || manager.customAH.isRenderOverAuctionView()) {
+ if(event.gui instanceof CustomAHGui || manager.auctionManager.customAH.isRenderOverAuctionView()) {
event.setCanceled(true);
- manager.customAH.drawScreen(event.mouseX, event.mouseY);
+ manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY);
}
}
@@ -527,9 +534,9 @@ public class NotEnoughUpdates {
*/
@SubscribeEvent
public void onGuiScreenMouse(GuiScreenEvent.MouseInputEvent.Pre event) {
- if(event.gui instanceof CustomAHGui || manager.customAH.isRenderOverAuctionView()) {
+ if(event.gui instanceof CustomAHGui || manager.auctionManager.customAH.isRenderOverAuctionView()) {
event.setCanceled(true);
- manager.customAH.handleMouseInput();
+ manager.auctionManager.customAH.handleMouseInput();
//overlay.mouseInput();
return;
}
@@ -549,8 +556,8 @@ public class NotEnoughUpdates {
boolean started = false;
@SubscribeEvent
public void onGuiScreenKeyboard(GuiScreenEvent.KeyboardInputEvent.Pre event) {
- if(event.gui instanceof CustomAHGui || manager.customAH.isRenderOverAuctionView()) {
- if(manager.customAH.keyboardInput()) {
+ if(event.gui instanceof CustomAHGui || manager.auctionManager.customAH.isRenderOverAuctionView()) {
+ if(manager.auctionManager.customAH.keyboardInput()) {
event.setCanceled(true);
Minecraft.getMinecraft().dispatchKeypresses();
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/StreamerMode.java b/src/main/java/io/github/moulberry/notenoughupdates/StreamerMode.java
index 47f2da10..3ad2eba6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/StreamerMode.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/StreamerMode.java
@@ -8,7 +8,7 @@ import java.util.regex.Pattern;
public class StreamerMode {
- private static final Pattern lobbyPattern = Pattern.compile("(mini|mega)([0-9]{1,3}[A-Z])");
+ private static final Pattern lobbyPattern = Pattern.compile("(mini|mega|m|M)([0-9]{1,3}[A-Z])");
public static String filterLobbyNames(String line) {
Matcher matcher = lobbyPattern.matcher(line);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/AuctionManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/AuctionManager.java
new file mode 100644
index 00000000..3d636f8a
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/AuctionManager.java
@@ -0,0 +1,315 @@
+package io.github.moulberry.notenoughupdates.auction;
+
+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.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+
+import java.util.*;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class AuctionManager {
+
+ private NEUManager manager;
+ public final CustomAH customAH;
+
+ private int totalPages = 0;
+ private int lastApiUpdate;
+ private LinkedList<Integer> needUpdate = new LinkedList<>();
+ private TreeMap<String, Auction> auctionMap = new TreeMap<>();
+
+ public TreeMap<String, HashMap<String, List<Integer>>> extrasToAucIdMap = new TreeMap<>();
+
+ private long lastPageUpdate = 0;
+ private long lastCustomAHSearch = 0;
+ private long lastCleanup = 0;
+
+ public AuctionManager(NEUManager manager) {
+ this.manager = manager;
+ customAH = new CustomAH(manager);
+ }
+
+ public TreeMap<String, Auction> getAuctionItems() {
+ return auctionMap;
+ }
+
+ public class Auction {
+ public String auctioneerUuid;
+ public long end;
+ public int starting_bid;
+ public int highest_bid_amount;
+ public int bid_count;
+ public boolean bin;
+ public String category;
+ public String rarity;
+ public String item_bytes;
+ private ItemStack stack;
+
+ 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) {
+ this.auctioneerUuid = auctioneerUuid;
+ this.end = end;
+ this.starting_bid = starting_bid;
+ this.highest_bid_amount = highest_bid_amount;
+ this.bid_count = bid_count;
+ this.bin = bin;
+ this.category = category;
+ this.rarity = rarity;
+ this.item_bytes = item_bytes;
+ }
+
+ public ItemStack getStack() {
+ if(stack != null) {
+ return stack;
+ } else {
+ JsonObject item = manager.getJsonFromItemBytes(item_bytes);
+ ItemStack stack = manager.jsonToStack(item, false);
+ this.stack = stack;
+ return stack;
+ }
+ }
+ }
+
+ public void tick() {
+ if(System.currentTimeMillis() - lastPageUpdate > 5*1000) {
+ lastPageUpdate = System.currentTimeMillis();
+ updatePageTick();
+ }
+ if(System.currentTimeMillis() - lastCleanup > 120*1000) {
+ lastCleanup = System.currentTimeMillis();
+ cleanup();
+ }
+ if(System.currentTimeMillis() - lastCustomAHSearch > 60*1000) {
+ lastCustomAHSearch = System.currentTimeMillis();
+ customAH.updateSearch();
+ }
+ }
+
+ private void cleanup() {
+ try {
+ Set<String> toRemove = new HashSet<>();
+ for(Map.Entry<String, Auction> entry : auctionMap.entrySet()) {
+ long timeToEnd = entry.getValue().end - System.currentTimeMillis();
+ if(timeToEnd < -60) {
+ toRemove.add(entry.getKey());
+ }
+ }
+ for(String aucid : toRemove) {
+ auctionMap.remove(aucid);
+ extrasToAucIdMap.remove(aucid);
+ }
+ } catch(ConcurrentModificationException e) {
+ cleanup();
+ }
+ }
+
+ private void updatePageTick() {
+ if(totalPages == 0) {
+ getPageFromAPI(0);
+ } else {
+ if(needUpdate.isEmpty()) resetNeedUpdate();
+
+ int pageToUpdate;
+ for(pageToUpdate = needUpdate.pop(); pageToUpdate >= totalPages && !needUpdate.isEmpty();
+ pageToUpdate = needUpdate.pop()) {}
+
+ getPageFromAPI(pageToUpdate);
+ }
+ }
+
+ String[] rarityArr = new String[] {
+ "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL",
+ };
+
+ public int checkItemType(String lore, String... typeMatches) {
+ String[] split = lore.split("\n");
+ for(int i=split.length-1; i>=0; i--) {
+ String line = split[i];
+ for(String rarity : rarityArr) {
+ for(int j=0; j<typeMatches.length; j++) {
+ if(line.trim().endsWith(rarity + " " + typeMatches[j])) {
+ return j;
+ }
+ }
+ }
+ }
+ return -1;
+ }
+
+ private void getPageFromAPI(int page) {
+ //System.out.println("Trying to update page: " + page);
+ HashMap<String, String> args = new HashMap<>();
+ args.put("page", ""+page);
+ 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();
+
+ int lastUpdated = jsonObject.get("lastUpdated").getAsInt();
+
+ if(lastApiUpdate != lastUpdated) {
+ resetNeedUpdate();
+ }
+
+ lastApiUpdate = lastUpdated;
+
+ String[] categoryItemType = new String[]{"sword","fishingrod","pickaxe","axe",
+ "shovel","petitem","travelscroll","reforgestone","bow"};
+
+ JsonArray auctions = jsonObject.get("auctions").getAsJsonArray();
+ for (int i = 0; i < auctions.size(); i++) {
+ JsonObject auction = auctions.get(i).getAsJsonObject();
+
+ String auctionUuid = auction.get("uuid").getAsString();
+ String auctioneerUuid = auction.get("auctioneer").getAsString();
+ long end = auction.get("end").getAsLong();
+ int starting_bid = auction.get("starting_bid").getAsInt();
+ int highest_bid_amount = auction.get("highest_bid_amount").getAsInt();
+ int bid_count = auction.get("bids").getAsJsonArray().size();
+ boolean bin = false;
+ if(auction.has("bin")) {
+ bin = auction.get("bin").getAsBoolean();
+ }
+ String sbCategory = auction.get("category").getAsString();
+ String extras = auction.get("extra").getAsString();
+ String item_lore = auction.get("item_lore").getAsString();
+ String item_bytes = auction.get("item_bytes").getAsString();
+ String rarity = auction.get("tier").getAsString();
+
+ String tag = extras + " " + Utils.cleanColour(item_lore).replaceAll("\n", " ");
+
+ int wordIndex=0;
+ for(String str : tag.split(" ")) {
+ str = Utils.cleanColour(str).toLowerCase();
+ if(!extrasToAucIdMap.containsKey(str)) {
+ extrasToAucIdMap.put(str, new HashMap<>());
+ }
+ if(!extrasToAucIdMap.get(str).containsKey(auctionUuid)) {
+ extrasToAucIdMap.get(str).put(auctionUuid, new ArrayList<>());
+ }
+ extrasToAucIdMap.get(str).get(auctionUuid).add(wordIndex);
+ wordIndex++;
+ }
+
+ //Categories
+ String category = sbCategory; //§6§lLEGENDARY FISHING ROD
+ int itemType = checkItemType(item_lore, "SWORD", "FISHING ROD", "PICKAXE",
+ "AXE", "SHOVEL", "PET ITEM", "TRAVEL SCROLL", "REFORGE STONE", "BOW");
+ if(itemType >= 0 && itemType < categoryItemType.length) {
+ category = categoryItemType[itemType];
+ }
+ 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("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));
+ }
+ }
+ }
+ );
+ }
+
+ private void resetNeedUpdate() {
+ for(Integer page=0; page<totalPages; page++) {
+ if(!needUpdate.contains(page)) {
+ needUpdate.addLast(page);
+ }
+ }
+ }
+
+ /*ScheduledExecutorService auctionUpdateSES = Executors.newSingleThreadScheduledExecutor();
+ private AtomicInteger auctionUpdateId = new AtomicInteger(0);
+ public void updateAuctions() {
+ HashMap<Integer, JsonObject> pages = new HashMap<>();
+
+ HashMap<String, String> args = new HashMap<>();
+ args.put("page", "0");
+ AtomicInteger totalPages = new AtomicInteger(1);
+ AtomicInteger currentPages = new AtomicInteger(0);
+ manager.hypixelApi.getHypixelApiAsync(manager.config.apiKey.value, "skyblock/auctions",
+ args, jsonObject -> {
+ if (jsonObject.get("success").getAsBoolean()) {
+ pages.put(0, jsonObject);
+ totalPages.set(jsonObject.get("totalPages").getAsInt());
+ currentPages.incrementAndGet();
+
+ for (int i = 1; i < totalPages.get(); i++) {
+ int j = i;
+ HashMap<String, String> args2 = new HashMap<>();
+ args2.put("page", "" + i);
+ manager.hypixelApi.getHypixelApiAsync(manager.config.apiKey.value, "skyblock/auctions",
+ args2, jsonObject2 -> {
+ if (jsonObject2.get("success").getAsBoolean()) {
+ pages.put(j, jsonObject2);
+ currentPages.incrementAndGet();
+ } else {
+ currentPages.incrementAndGet();
+ }
+ }
+ );
+ }
+ }
+ }
+ );
+
+ long startTime = System.currentTimeMillis();
+
+ int currentAuctionUpdateId = auctionUpdateId.incrementAndGet();
+
+ auctionUpdateSES.schedule(new Runnable() {
+ public void run() {
+ if(auctionUpdateId.get() != currentAuctionUpdateId) return;
+ System.out.println(currentPages.get() + "/" + totalPages.get());
+ if (System.currentTimeMillis() - startTime > 20000) return;
+
+ if (currentPages.get() == totalPages.get()) {
+ TreeMap<String, Auction> auctionItemsTemp = new TreeMap<>();
+
+ for (int pageNum : pages.keySet()) {
+ System.out.println(pageNum + "/" + pages.size());
+ JsonObject page = pages.get(pageNum);
+ JsonArray auctions = page.get("auctions").getAsJsonArray();
+ for (int i = 0; i < auctions.size(); i++) {
+ JsonObject auction = auctions.get(i).getAsJsonObject();
+
+ String auctionUuid = auction.get("uuid").getAsString();
+ String auctioneerUuid = auction.get("auctioneer").getAsString();
+ long end = auction.get("end").getAsLong();
+ int starting_bid = auction.get("starting_bid").getAsInt();
+ int highest_bid_amount = auction.get("highest_bid_amount").getAsInt();
+ int bid_count = auction.get("bids").getAsJsonArray().size();
+ boolean bin = false;
+ if(auction.has("bin")) {
+ bin = auction.get("bin").getAsBoolean();
+ }
+ String category = auction.get("category").getAsString();
+ String extras = auction.get("item_lore").getAsString().replaceAll("\n"," ") + " " +
+ auction.get("extra").getAsString();
+ String item_bytes = auction.get("item_bytes").getAsString();
+
+ auctionItemsTemp.put(auctionUuid, new Auction(auctioneerUuid, end, starting_bid, highest_bid_amount,
+ bid_count, bin, category, extras, item_bytes));
+ }
+ }
+ auctionItems = auctionItemsTemp;
+ customAH.updateSearch();
+ return;
+ }
+
+ auctionUpdateSES.schedule(this, 1000L, TimeUnit.MILLISECONDS);
+ }
+ }, 3000L, TimeUnit.MILLISECONDS);
+ }*/
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
new file mode 100644
index 00000000..0cc17afe
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
@@ -0,0 +1,1055 @@
+package io.github.moulberry.notenoughupdates.auction;
+
+import io.github.moulberry.notenoughupdates.NEUManager;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.util.TexLoc;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiTextField;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.client.gui.inventory.GuiEditSign;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.Tessellator;
+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.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.tileentity.TileEntitySign;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL14;
+
+import java.awt.*;
+import java.text.NumberFormat;
+import java.util.*;
+import java.util.List;
+
+import static io.github.moulberry.notenoughupdates.GuiTextures.*;
+
+public class CustomAH extends Gui {
+
+ private static final ResourceLocation creativeTabSearch =
+ new ResourceLocation("textures/gui/container/creative_inventory/tab_item_search.png");
+ private static final ResourceLocation creativeInventoryTabs =
+ new ResourceLocation("textures/gui/container/creative_inventory/tabs.png");
+
+ private List<String> auctionIds = new ArrayList<>();
+
+ private boolean scrollClicked = false;
+
+ private int startingBid = 0;
+
+ private int clickedMainCategory = -1;
+ private int clickedSubCategory = -1;
+
+ private GuiTextField searchField = null;
+ private GuiTextField priceField = null;
+
+ private boolean renderOverAuctionView = false;
+ private long lastRenderDisable = 0;
+
+ private int eventButton;
+ private long lastMouseEvent;
+ public long lastOpen;
+ public long lastGuiScreenSwitch;
+
+ private int splits = 2;
+
+ private int ySplit = 35;
+ private int ySplitSize = 18;
+
+ private float scrollAmount;
+
+ private int guiLeft = 0;
+ private int guiTop = 0;
+
+ private Category CATEGORY_SWORD = new Category("sword", "Swords", "diamond_sword");
+ private Category CATEGORY_ARMOR = new Category("armor", "Armor", "diamond_chestplate");
+ private Category CATEGORY_BOWS = new Category("bow", "Bows", "bow");
+ private Category CATEGORY_ACCESSORIES = new Category("accessories", "Accessories", "diamond");
+
+ private Category CATEGORY_FISHING_ROD = new Category("fishingrod", "Fishing Rods", "fishing_rod");
+ private Category CATEGORY_PICKAXE = new Category("pickaxe", "Pickaxes", "iron_pickaxe");
+ private Category CATEGORY_AXE = new Category("axe", "Axes", "iron_axe");
+ private Category CATEGORY_SHOVEL = new Category("shovel", "Shovels", "iron_shovel");
+
+ private Category CATEGORY_PET_ITEM = new Category("petitem", "Pet Items", "lead");
+
+ private Category CATEGORY_EBOOKS = new Category("ebook", "Enchanted Books", "enchanted_book");
+ private Category CATEGORY_POTIONS = new Category("potion", "Potions", "potion");
+ private Category CATEGORY_TRAVEL_SCROLLS = new Category("travelscroll", "Travel Scrolls", "map");
+
+ private Category CATEGORY_REFORGE_STONES = new Category("reforgestone", "Reforge Stones", "anvil");
+ private Category CATEGORY_RUNES = new Category("rune", "Runes", "end_portal_frame");
+ private Category CATEGORY_FURNITURE = new Category("furniture", "Furniture", "armor_stand");
+
+ 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,
+ 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,
+ CATEGORY_TRAVEL_SCROLLS);
+ private Category CATEGORY_BLOCKS = new Category("blocks", "Blocks", "cobblestone");
+ private Category CATEGORY_MISC = new Category("misc", "Misc", "stick", CATEGORY_REFORGE_STONES, CATEGORY_RUNES,
+ CATEGORY_FURNITURE);
+
+ private Category[] mainCategories = new Category[]{CATEGORY_COMBAT, CATEGORY_TOOL, CATEGORY_PET,
+ CATEGORY_CONSUMABLES, CATEGORY_BLOCKS, CATEGORY_MISC};
+
+ private static final int SORT_MODE_HIGH = 0;
+ private static final int SORT_MODE_LOW = 1;
+ private static final int SORT_MODE_SOON = 2;
+
+ private static final String[] rarities = { "COMMON", "UNCOMMON", "RARE", "EPIC",
+ "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL" };
+
+ 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 int sortMode = SORT_MODE_HIGH;
+ private int rarityFilter = -1;
+ private boolean filterMyAuctions = false;
+ private int binFilter = BIN_FILTER_ALL;
+
+ private static ItemStack CONTROL_SORT = Utils.createItemStack(Item.getItemFromBlock(Blocks.hopper),
+ EnumChatFormatting.GREEN+"Sort");
+ private static ItemStack CONTROL_TIER = Utils.createItemStack(Items.ender_eye,
+ EnumChatFormatting.GREEN+"Item Tier");
+ private static ItemStack CONTROL_MYAUC = Utils.createItemStack(Items.gold_ingot,
+ 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 NEUManager manager;
+
+ public CustomAH(NEUManager manager) {
+ this.manager = manager;
+ }
+
+ public void clearSearch() {
+ if(System.currentTimeMillis() - lastOpen < 1000) Mouse.setGrabbed(false);
+
+ sortMode = SORT_MODE_HIGH;
+ rarityFilter = -1;
+ filterMyAuctions = false;
+ binFilter = BIN_FILTER_ALL;
+
+ searchField.setText("");
+ priceField.setText("");
+ }
+
+ public class Category {
+ public String categoryMatch;
+ public Category[] subcategories;
+ public String displayName;
+ public ItemStack displayItem;
+
+ public Category(String categoryMatch, String displayName, String displayItem, Category... subcategories) {
+ this.categoryMatch = categoryMatch;
+ this.subcategories = subcategories;
+ this.displayName = displayName;
+ this.displayItem = new ItemStack(Item.getByNameOrId(displayItem));
+ }
+
+ public String[] getTotalCategories() {
+ String[] categories = new String[1+subcategories.length];
+ categories[0] = categoryMatch;
+
+ for(int i=0; i<subcategories.length; i++) {
+ categories[i+1] = subcategories[i].categoryMatch;
+ }
+ return categories;
+ }
+ }
+
+ private void init() {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ this.searchField = new GuiTextField(0, fr, this.guiLeft + 82, this.guiTop + 6,
+ 89, fr.FONT_HEIGHT);
+ this.priceField = new GuiTextField(1, fr, this.guiLeft + 82, this.guiTop + 6,
+ 89, fr.FONT_HEIGHT);
+
+ this.searchField.setMaxStringLength(15);
+ this.searchField.setEnableBackgroundDrawing(false);
+ this.searchField.setTextColor(16777215);
+ this.searchField.setVisible(true);
+ this.searchField.setCanLoseFocus(false);
+ this.searchField.setFocused(true);
+ this.searchField.setText("");
+
+ this.priceField.setMaxStringLength(10);
+ this.priceField.setEnableBackgroundDrawing(false);
+ this.priceField.setTextColor(16777215);
+ this.priceField.setVisible(true);
+ this.priceField.setCanLoseFocus(false);
+ this.priceField.setFocused(false);
+ this.priceField.setText("");
+ }
+
+ public boolean isRenderOverAuctionView() {
+ return renderOverAuctionView || (System.currentTimeMillis() - lastRenderDisable) < 500;
+ }
+
+ public void setRenderOverAuctionView(boolean renderOverAuctionView) {
+ if(this.renderOverAuctionView && !renderOverAuctionView) lastRenderDisable = System.currentTimeMillis();
+ this.renderOverAuctionView = renderOverAuctionView;
+ }
+
+ private int getXSize() {
+ return 195;
+ }
+
+ private int getYSize() {
+ 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);
+ }
+
+ 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) {
+ endsIn += "Ended!";
+ } else if(minutes == 0 && hours == 0 && days == 0) {
+ endsIn += seconds + "s";
+ } else if(hours==0 && days==0) {
+ endsIn += minutes + "m" + seconds + "s";
+ } else if(days==0) {
+ if(hours <= 6) {
+ endsIn += hours + "h" + minutes + "m" + seconds + "s";
+ } else {
+ endsIn += hours + "h";
+ }
+ } else {
+ endsIn += days + "d" + hours + "h";
+ }
+
+ NumberFormat format = NumberFormat.getInstance(Locale.US);
+
+ tooltip.add(EnumChatFormatting.DARK_GRAY+""+EnumChatFormatting.STRIKETHROUGH+"-----------------");
+ tooltip.add(EnumChatFormatting.GRAY+"Seller: [CLICK TO SEE]");
+
+ if(auc.bin) {
+ tooltip.add(EnumChatFormatting.GRAY+"Buy it now: "+
+ EnumChatFormatting.GOLD+format.format(auc.starting_bid));
+ } else {
+ if(auc.bid_count > 0) {
+ tooltip.add(EnumChatFormatting.GRAY+"Bids: "+EnumChatFormatting.GREEN+auc.bid_count+" bids");
+ tooltip.add("");
+ tooltip.add(EnumChatFormatting.GRAY+"Top bid: "+
+ EnumChatFormatting.GOLD+format.format(auc.highest_bid_amount));
+ tooltip.add(EnumChatFormatting.GRAY+"Bidder: [CLICK TO SEE]");
+ } else {
+ tooltip.add(EnumChatFormatting.GRAY+"Starting bid: "+
+ EnumChatFormatting.GOLD+format.format(auc.starting_bid));
+ }
+ }
+
+ tooltip.add("");
+ tooltip.add(EnumChatFormatting.GRAY+"Ends in: "+endsIn);
+ tooltip.add("");
+ tooltip.add(EnumChatFormatting.YELLOW+"Click to inspect!");
+
+ return tooltip;
+ }
+
+ public boolean isEditingPrice() {
+ return Minecraft.getMinecraft().currentScreen instanceof GuiEditSign;
+ }
+
+ private boolean isGuiFiller(ItemStack stack) {
+ return stack == null || !stack.hasTagCompound() || !stack.getTagCompound().hasKey("AttributeModifiers");
+ }
+
+ private void drawCategorySide(int i) {
+ boolean clicked = i == clickedSubCategory;
+
+ int x = guiLeft-28;
+ int y = guiTop+17+28*i;
+ float uMin = 28/256f;
+ float uMax = 56/256f;
+ float vMin = 0+(clicked?32/256f:0);
+ float vMax = 32/256f+(clicked?32/256f:0);
+ float catWidth = 32;
+ float catHeight = 28;
+
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer
+ .pos(x, y+catHeight, 0.0D)
+ .tex(uMax, vMin).endVertex();
+ worldrenderer
+ .pos(x+catWidth, y+catHeight, 0.0D)
+ .tex(uMax, vMax).endVertex();
+ worldrenderer
+ .pos(x+catWidth, y, 0.0D)
+ .tex(uMin, vMax).endVertex();
+ worldrenderer
+ .pos(x, y, 0.0D)
+ .tex(uMin, vMin).endVertex();
+ tessellator.draw();
+
+ GlStateManager.disableBlend();
+ }
+
+ public void drawScreen(int mouseX, int mouseY) {
+ if(System.currentTimeMillis() - lastOpen < 1000) Mouse.setGrabbed(false);
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ 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");
+
+ List<String> tooltipToRender = null;
+ if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest auctionView = (GuiChest) Minecraft.getMinecraft().currentScreen;
+
+ 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(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);
+
+ 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(priceNumbers.length() > 0) {
+ startingBid = Integer.parseInt(priceNumbers.toString());
+ }
+ }
+ }
+
+ 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(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(isEditingPrice()) {
+ float slideAmount = 1-Math.max(0, Math.min(1, (System.currentTimeMillis() - lastGuiScreenSwitch)/200f));
+ int auctionViewLeft = guiLeft+getXSize()+4 - (int)(slideAmount*(96+4));
+
+ if(priceField.getText().equals("IAUSHDIUAH")) priceField.setText(""+startingBid);
+
+ searchField.setFocused(false);
+ priceField.setFocused(true);
+ priceField.xPosition = auctionViewLeft+18;
+ priceField.yPosition = guiTop+18;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_price);
+ this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 96, 99);
+ priceField.drawTextBox();
+
+ 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);
+ this.drawTexturedModalRect(auctionViewLeft+16+34, guiTop+32, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft+16, guiTop+50, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft+16+34, guiTop+50, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft+16, guiTop+68, 0, 32, 64, 16);
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ Utils.drawStringCentered("x2", fr, auctionViewLeft+16+15, guiTop+32+8, false,
+ Color.BLACK.getRGB());
+ Utils.drawStringCentered("+50%", fr, auctionViewLeft+16+34+15, guiTop+32+8, false,
+ Color.BLACK.getRGB());
+ Utils.drawStringCentered("+25%", fr, auctionViewLeft+16+15, guiTop+50+8, false,
+ Color.BLACK.getRGB());
+ Utils.drawStringCentered("+10%", fr, auctionViewLeft+16+34+15, guiTop+50+8, false,
+ Color.BLACK.getRGB());
+ Utils.drawStringCentered("Set Amount", fr, auctionViewLeft+16+32, guiTop+68+8, false,
+ Color.BLACK.getRGB());
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+
+ 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());
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs);
+ if(clickedMainCategory == -1) {
+ this.drawTexturedModalRect(guiLeft, guiTop-28, 0, 0, 168, 32);
+ } else {
+ int selStart = clickedMainCategory*28;
+ 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(i != clickedSubCategory) drawCategorySide(i);
+ }
+ }
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(creativeTabSearch);
+ this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, getXSize(), ySplit);
+ int y = guiTop+ySplit;
+ for(int i=0; i<splits; i++) {
+ this.drawTexturedModalRect(guiLeft, y, 0, ySplit, getXSize(), ySplit+ySplitSize);
+ y += ySplitSize;
+ }
+ this.drawTexturedModalRect(guiLeft, y, 0, ySplit, getXSize(), 136-ySplit);
+
+ //Categories
+ Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs);
+ if(clickedMainCategory != -1) {
+ int selStart = clickedMainCategory*28;
+
+ this.drawTexturedModalRect(guiLeft+selStart, guiTop-28, 28, 32, 28, 32);
+
+ if(clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
+ Category mainCategory = mainCategories[clickedMainCategory];
+
+ if(clickedSubCategory >= 0 && clickedSubCategory < mainCategory.subcategories.length) {
+ drawCategorySide(clickedSubCategory);
+ }
+ }
+ }
+
+ //Category icons
+ for(int i=0; i<mainCategories.length; i++) {
+ Category category = mainCategories[i];
+ Utils.drawItemStack(category.displayItem, guiLeft+28*i+6, guiTop-28+9);
+ }
+ if(clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
+ Category mainCategory = mainCategories[clickedMainCategory];
+
+ for(int i=0; i<mainCategory.subcategories.length; i++) {
+ Utils.drawItemStack(mainCategory.subcategories[i].displayItem, guiLeft-19, guiTop+23+28*i);
+ }
+ }
+
+ for(int i=0; i<controls.length; i++) {
+ Utils.drawItemStack(controls[i], guiLeft+9+18*i, guiTop+112+18*splits);
+ if(mouseX > guiLeft+9+18*i && mouseX < guiLeft+9+18*i+16) {
+ if(mouseY > guiTop+112+18*splits && mouseY < guiTop+112+18*splits+16) {
+ tooltipToRender = getTooltipForControl(i);
+ }
+ }
+ }
+
+ int totalItems = auctionIds.size();
+ int itemsScroll = (int)Math.floor((totalItems*scrollAmount)/9f)*9;
+
+ int maxItemScroll = Math.max(0, totalItems - (5+splits)*9);
+ itemsScroll = Math.min(itemsScroll, maxItemScroll);
+
+ out:
+ for(int i=0; i<5+splits; i++) {
+ int itemY = guiTop + i*18 + 18;
+ for(int j=0; j<9; j++) {
+ int itemX = guiLeft + j*18 + 9;
+ int id = itemsScroll + i*9 + j;
+ if(auctionIds.size() <= id) break out;
+
+ try {
+ String aucid = auctionIds.get(id);
+
+ GL11.glTranslatef(0,0,100);
+ ItemStack stack = manager.auctionManager.getAuctionItems().get(aucid).getStack();
+ Utils.drawItemStack(stack, itemX, itemY);
+ GL11.glTranslatef(0,0,-100);
+
+ if(mouseX > itemX && mouseX < itemX+16) {
+ if(mouseY > itemY && mouseY < itemY+16) {
+ tooltipToRender = getTooltipForAucId(aucid);
+ }
+ }
+ } catch(Exception e) {
+ break out;
+ }
+ }
+ }
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ searchField.drawTextBox();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+
+ 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);
+ this.drawTexturedModalRect(guiLeft+175, guiTop+18+(int)((95+ySplitSize*2)*scrollAmount),
+ 256-(scrollClicked?12:24), 0, 12, 15);
+
+ if(tooltipToRender != null) {
+ List<String> tooltipGray = new ArrayList<>();
+ for(String line : tooltipToRender) {
+ tooltipGray.add(EnumChatFormatting.GRAY + line);
+ }
+ Utils.drawHoveringText(tooltipGray, mouseX, mouseY, width,
+ height, -1, Minecraft.getMinecraft().fontRendererObj);
+ }
+ }
+
+ public List<String> getTooltipForControl(int index) {
+ List<String> lore = new ArrayList<>();
+ String arrow = "\u25b6";
+ String selPrefix = EnumChatFormatting.DARK_AQUA + " " + arrow + " ";
+ String unselPrefix = EnumChatFormatting.GRAY.toString();
+ switch(index) {
+ case 0: break;
+ case 1:
+ lore.add("");
+ String[] linesSort = {"Highest Bid","Lowest Bid","Ending soon"};
+ for(int i=0; i<linesSort.length; i++) {
+ String line = linesSort[i];
+ if(i == sortMode) {
+ line = selPrefix + line;
+ } else {
+ line = unselPrefix + line;
+ }
+ lore.add(line);
+ }
+ lore.add("");
+ lore.add(EnumChatFormatting.YELLOW + "Click to switch sort!");
+ return lore;
+ case 2:
+ lore.add("");
+ lore.add(rarityFilter == -1 ? selPrefix : unselPrefix + "No Filter");
+
+ for(int i=0; i<rarities.length; i++) {
+ lore.add(rarityFilter == i ? selPrefix : unselPrefix + "Filter " + rarities[i]);
+ }
+ lore.add("");
+ lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!");
+ lore.add(EnumChatFormatting.YELLOW + "Click to switch filter!");
+ return lore;
+ case 3: break;
+ case 4:
+ lore.add("");
+ String off = EnumChatFormatting.RED + "OFF";
+ String on = EnumChatFormatting.GREEN + "ON";
+ lore.add(unselPrefix+"Filter Own Auctions: " + (filterMyAuctions ? on : off));
+ lore.add("");
+ lore.add(EnumChatFormatting.YELLOW + "Click to toggle!");
+ return lore;
+ case 5: break;
+ case 6:
+ lore.add("");
+ String[] linesBin = {"Show All","BIN Only","Auctions Only"};
+ for(int i=0; i<linesBin.length; i++) {
+ String line = linesBin[i];
+ if(i == binFilter) {
+ 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 7: break;
+ case 8: break;
+ }
+ return new ArrayList<>();
+ }
+
+ public void handleMouseInput() {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ int mouseX = Mouse.getEventX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getEventY() * height / Minecraft.getMinecraft().displayHeight - 1;
+ int mouseButton = Mouse.getEventButton();
+
+ if (Mouse.getEventButtonState()) {
+ this.eventButton = mouseButton;
+ this.lastMouseEvent = Minecraft.getSystemTime();
+ mouseClicked(mouseX, mouseY, this.eventButton);
+ } else if (mouseButton != -1) {
+ this.eventButton = -1;
+ mouseReleased(mouseX, mouseY, mouseButton);
+ } else if (this.eventButton != -1 && this.lastMouseEvent > 0L) {
+ long l = Minecraft.getSystemTime() - this.lastMouseEvent;
+ mouseClickMove(mouseX, mouseY, this.eventButton, l);
+ }
+
+ int dWheel = Mouse.getEventDWheel();
+ dWheel = Math.max(-1, Math.min(1, dWheel));
+
+ scrollAmount = scrollAmount - dWheel/(float)(auctionIds.size()/9-(5+splits));
+ scrollAmount = Math.max(0, Math.min(1, scrollAmount));
+ }
+
+ private String niceAucId(String aucId) {
+ if(aucId.length()!=32) return aucId;
+
+ StringBuilder niceAucId = new StringBuilder();
+ niceAucId.append(aucId, 0, 8);
+ niceAucId.append("-");
+ niceAucId.append(aucId, 8, 12);
+ niceAucId.append("-");
+ niceAucId.append(aucId, 12, 16);
+ niceAucId.append("-");
+ niceAucId.append(aucId, 16, 20);
+ niceAucId.append("-");
+ niceAucId.append(aucId, 20, 32);
+ return niceAucId.toString();
+ }
+
+ public Category getCurrentCategory() {
+ if(clickedMainCategory < 0 || clickedMainCategory >= mainCategories.length) {
+ return null;
+ }
+ Category mainCategory = mainCategories[clickedMainCategory];
+ if(clickedSubCategory < 0 || clickedSubCategory >= mainCategory.subcategories.length) {
+ return mainCategory;
+ }
+ return mainCategory.subcategories[clickedSubCategory];
+ }
+
+ public void updateSearch() {
+ if(searchField == null || priceField == null) init();
+
+ 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(" ");
+ }
+ for(String aucid : manager.search(sb.toString(), manager.auctionManager.extrasToAucIdMap)) {
+ if(!auctionIds.contains(aucid)) {
+ auctionIds.add(aucid);
+ }
+ }
+ }
+ }
+ 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;
+ }
+ }
+ if(rarityFilter > 0 && rarityFilter < rarities.length) {
+ if(!rarities[rarityFilter].equals(auc.rarity)) {
+ match = false;
+ }
+ }
+ if(binFilter == BIN_FILTER_BIN) {
+ match &= auc.bin;
+ } else if(binFilter == BIN_FILTER_AUC) {
+ match &= !auc.bin;
+ }
+
+ if(!match) {
+ toRemove.add(aucid);
+ }
+ } else {
+ toRemove.add(aucid);
+ }
+ }
+ auctionIds.removeAll(toRemove);
+ sortItems();
+ } catch(ConcurrentModificationException e) {
+ updateSearch();
+ }
+ }
+
+ 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);
+ }
+ });
+ }
+
+ public boolean keyboardInput() {
+ Keyboard.enableRepeatEvents(true);
+ if(isEditingPrice() && Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ } else if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ return false;
+ }
+ if(Keyboard.getEventKeyState()) keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+ return true;
+ }
+
+ public void keyTyped(char typedChar, int keyCode) {
+ if(searchField == null || priceField == null) init();
+
+ if(!isEditingPrice()) {
+ if(this.searchField.textboxKeyTyped(typedChar, keyCode)) {
+ this.updateSearch();
+ }
+ } else {
+ priceField.textboxKeyTyped(typedChar, keyCode);
+ }
+ }
+
+ private void increasePriceByFactor(float factor) {
+ String price = priceField.getText().trim();
+ StringBuilder priceNumbers = new StringBuilder();
+ for(int i=0; i<price.length(); i++) {
+ char c = price.charAt(i);
+ if((int)c >= 48 && (int)c <= 57) {
+ priceNumbers.append(c);
+ } else {
+ break;
+ }
+ }
+ int priceI = 0;
+ if(priceNumbers.length() > 0) {
+ priceI = Integer.parseInt(priceNumbers.toString());
+ }
+ String end = price.substring(priceNumbers.length());
+ priceField.setText((int)(priceI*factor) + end);
+ }
+
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ searchField.mouseClicked(mouseX, mouseY, mouseButton);
+
+ int totalItems = auctionIds.size();
+ int itemsScroll = (int)Math.floor((totalItems*scrollAmount)/9f)*9;
+
+ int maxItemScroll = Math.max(0, totalItems - (5+splits)*9);
+ itemsScroll = Math.min(itemsScroll, maxItemScroll);
+
+ //Categories
+ if(mouseY > guiTop-28 && mouseY < guiTop+4) {
+ if(mouseX > guiLeft && mouseX < guiLeft+168) {
+ int offset = mouseX-guiLeft;
+ int clickedCat = offset/28;
+ if(clickedMainCategory == clickedCat) {
+ clickedMainCategory = -1;
+ } else {
+ clickedMainCategory = clickedCat;
+ }
+ clickedSubCategory = -1;
+ updateSearch();
+ return;
+ }
+ }
+
+ if(clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
+ Category mainCategory = mainCategories[clickedMainCategory];
+
+ 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) {
+ clickedSubCategory = clicked;
+ updateSearch();
+ return;
+ }
+ }
+ }
+ }
+
+ if(mouseY > guiTop+112+18*splits && mouseY < guiTop+112+18*splits+16) {
+ if(mouseX > guiLeft+9 && mouseX < guiLeft+9+controls.length*18-2) {
+ int offset = mouseX - (guiLeft+9);
+ int index = offset/18;
+ boolean rightClicked = Mouse.getEventButton() == 1;
+ switch(index) {
+ case 0: break;
+ case 1:
+ if(rightClicked) {
+ sortMode--;
+ if(sortMode < SORT_MODE_HIGH) sortMode = SORT_MODE_SOON;
+ } else {
+ sortMode++;
+ if(sortMode > SORT_MODE_SOON) sortMode = SORT_MODE_HIGH;
+ }
+ break;
+ case 2:
+ if(rightClicked) {
+ rarityFilter--;
+ if(rarityFilter < -1) rarityFilter = rarities.length-1;
+ } else {
+ rarityFilter++;
+ if(rarityFilter >= rarities.length) rarityFilter = -1;
+ }
+ break;
+ case 3: break;
+ case 4:
+ filterMyAuctions = !filterMyAuctions;
+ break;
+ case 5: break;
+ case 6:
+ if(rightClicked) {
+ binFilter--;
+ if(binFilter < BIN_FILTER_ALL) binFilter = BIN_FILTER_AUC;
+ } else {
+ binFilter++;
+ if(binFilter > BIN_FILTER_AUC) binFilter = BIN_FILTER_ALL;
+ }
+ case 7: break;
+ case 8: break;
+ }
+ 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));
+ }
+ }
+
+ if(mouseButton == 0 && Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest auctionView = (GuiChest) Minecraft.getMinecraft().currentScreen;
+
+ 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);
+ }
+ }
+ }
+ if(mouseButton == 0 && isEditingPrice()) {
+ int auctionViewLeft = guiLeft+getXSize()+4;
+
+ if(mouseX > auctionViewLeft+16 && mouseX < auctionViewLeft+16+64) {
+ if(mouseY > guiTop+32 && mouseY < guiTop+32+16) {
+ if(mouseX < auctionViewLeft+16+32) {
+ //top left
+ increasePriceByFactor(2);
+ } else {
+ //top right
+ increasePriceByFactor(1.5f);
+ }
+ } else if(mouseY > guiTop+50 && mouseY < guiTop+50+16) {
+ if(mouseX < auctionViewLeft+16+32) {
+ //mid left
+ increasePriceByFactor(1.25f);
+ } else {
+ //mid right
+ increasePriceByFactor(1.1f);
+ }
+ } else if(mouseY > guiTop+68 && mouseY < guiTop+68+16) {
+ //bottom
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ }
+ }
+
+ this.drawTexturedModalRect(auctionViewLeft+16, guiTop+32, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft+16+34, guiTop+32, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft+16, guiTop+50, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft+16+34, guiTop+50, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft+16, guiTop+68, 0, 32, 64, 16);
+ }
+
+ out:
+ for(int i=0; i<5+splits; i++) {
+ int itemY = guiTop + i*18 + 18;
+ for(int j=0; j<9; j++) {
+ int itemX = guiLeft + j*18 + 9;
+ int id = itemsScroll + i*9 + j;
+ if(auctionIds.size() <= id) break out;
+
+ String aucid;
+ try {
+ aucid = auctionIds.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));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ int y = guiTop+18+(int)((95+ySplitSize*2)*scrollAmount);
+ if(mouseX > guiLeft+175 && mouseX < guiLeft+175+12) {
+ if(mouseY > y && mouseY < y+15) {
+ scrollClicked = true;
+ return;
+ }
+ }
+ scrollClicked = false;
+ }
+
+ protected void mouseReleased(int mouseX, int mouseY, int state) {
+ scrollClicked = false;
+ }
+
+ protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ if(scrollClicked) {
+ int yMin = guiTop+18 + 8;
+ int yMax = guiTop+18+(95+ySplitSize*2) + 8;
+
+ scrollAmount = (mouseY-yMin)/(float)(yMax-yMin);
+ scrollAmount = Math.max(0, Math.min(1, scrollAmount));
+ }
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomAHGui.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAHGui.java
index af7486a0..bb36d363 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/CustomAHGui.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAHGui.java
@@ -1,4 +1,4 @@
-package io.github.moulberry.notenoughupdates;
+package io.github.moulberry.notenoughupdates.auction;
import net.minecraft.client.gui.GuiScreen;
import org.lwjgl.input.Mouse;
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 0247c01e..0beee610 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -14,7 +14,11 @@ import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.Session;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
@@ -67,6 +71,7 @@ public class Utils {
RenderHelper.enableGUIStandardItemLighting();
itemRender.zLevel = -145; //Negates the z-offset of the below method.
itemRender.renderItemAndEffectIntoGUI(stack, x, y);
+ itemRender.renderItemOverlays(Minecraft.getMinecraft().fontRendererObj, stack, x, y);
itemRender.zLevel = 0;
RenderHelper.disableStandardItemLighting();
}
@@ -149,6 +154,26 @@ public class Utils {
GlStateManager.disableBlend();
}
+ public static ItemStack createItemStack(Item item, String displayname, String... lore) {
+ ItemStack stack = new ItemStack(item);
+ NBTTagCompound tag = new NBTTagCompound();
+ NBTTagCompound display = new NBTTagCompound();
+ NBTTagList Lore = new NBTTagList();
+
+ for(String line : lore) {
+ Lore.appendTag(new NBTTagString(line));
+ }
+
+ display.setString("Name", displayname);
+ display.setTag("Lore", Lore);
+
+ tag.setTag("display", display);
+
+ stack.setTagCompound(tag);
+
+ return stack;
+ }
+
public static void drawStringScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) {
int strLen = fr.getStringWidth(str);
float factor = len/(float)strLen;