aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-27 11:53:57 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-27 11:53:57 -0500
commitb09f774d422263ce15b97d6d0804beddf856176d (patch)
treee542258481d7496b15679f3c329ef9e087c7d8fc /src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
parent22cb02adbeb24b7ec98f843bcaba99cebe3e4f03 (diff)
downloadnotenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.tar.gz
notenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.tar.bz2
notenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.zip
feat: improve formating :)
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java3814
1 files changed, 1951 insertions, 1863 deletions
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 449fff1e..123da60a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
@@ -45,857 +45,921 @@ import java.util.regex.Pattern;
import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
public class CustomAH extends Gui {
- private enum PriceFilter {
- Greater,
- Less,
- Equal
- }
-
- 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 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;
-
- private GuiTextField searchField = null;
- private GuiTextField priceField = null;
- private GuiTextField priceFilterField = null;
- private GuiTextField binPriceFilterField = null;
-
- private final int binPriceFilterYOffset = 86;
-
- 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;
- public long lastGuiScreenSwitch;
- private PriceFilter currentPriceFilterType = PriceFilter.Greater;
- private PriceFilter currentBinPriceFilterType = PriceFilter.Greater;
-
- private final int splits = 2;
-
- public String latestBid;
- public long latestBidMillis;
-
- private final int ySplit = 35;
- private final int ySplitSize = 18;
-
- private float scrollAmount;
-
- public int guiLeft = -1;
- public int guiTop = -1;
-
- private final Category CATEGORY_SWORD = new Category("sword", "Swords", "diamond_sword");
- private final Category CATEGORY_ARMOR = new Category("armor", "Armor", "diamond_chestplate");
- private final Category CATEGORY_BOWS = new Category("bow", "Bows", "bow");
- private final Category CATEGORY_ACCESSORIES = new Category("accessories", "Accessories", "diamond");
-
- private final Category CATEGORY_FISHING_ROD = new Category("fishingrod", "Fishing Rods", "fishing_rod");
- private final Category CATEGORY_PICKAXE = new Category("pickaxe", "Pickaxes", "iron_pickaxe");
- private final Category CATEGORY_AXE = new Category("axe", "Axes", "iron_axe");
- private final Category CATEGORY_SHOVEL = new Category("shovel", "Shovels", "iron_shovel");
-
- private final Category CATEGORY_PET_ITEM = new Category("petitem", "Pet Items", "lead");
-
- private final Category CATEGORY_EBOOKS = new Category("ebook", "Enchanted Books", "enchanted_book");
- private final Category CATEGORY_POTIONS = new Category("potion", "Potions", "potion");
- private final Category CATEGORY_TRAVEL_SCROLLS = new Category("travelscroll", "Travel Scrolls", "map");
-
- private final Category CATEGORY_REFORGE_STONES = new Category("reforgestone", "Reforge Stones", "anvil");
- private final Category CATEGORY_RUNES = new Category("rune", "Runes", "magma_cream");
- private final Category CATEGORY_FURNITURE = new Category("furniture", "Furniture", "armor_stand");
-
- private final Category CATEGORY_COMBAT = new Category("weapon", "Combat", "golden_sword", CATEGORY_SWORD,
- CATEGORY_BOWS, CATEGORY_ARMOR, CATEGORY_ACCESSORIES);
- private final Category CATEGORY_TOOL = new Category("", "Tools", "diamond_pickaxe", CATEGORY_FISHING_ROD, CATEGORY_PICKAXE,
- CATEGORY_AXE, CATEGORY_SHOVEL);
- private final Category CATEGORY_PET = new Category("pet", "Pets", "bone", CATEGORY_PET_ITEM);
- private final Category CATEGORY_CONSUMABLES = new Category("consumables", "Consumables", "apple", CATEGORY_EBOOKS, CATEGORY_POTIONS,
- CATEGORY_TRAVEL_SCROLLS);
- private final Category CATEGORY_BLOCKS = new Category("blocks", "Blocks", "cobblestone");
- private final Category CATEGORY_MISC = new Category("misc", "Misc", "stick", CATEGORY_REFORGE_STONES, CATEGORY_RUNES,
- CATEGORY_FURNITURE);
-
- private final 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",
+ private enum PriceFilter {
+ Greater,
+ Less,
+ Equal
+ }
+
+ 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 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;
+
+ private GuiTextField searchField = null;
+ private GuiTextField priceField = null;
+ private GuiTextField priceFilterField = null;
+ private GuiTextField binPriceFilterField = null;
+
+ private final int binPriceFilterYOffset = 86;
+
+ 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;
+ public long lastGuiScreenSwitch;
+ private PriceFilter currentPriceFilterType = PriceFilter.Greater;
+ private PriceFilter currentBinPriceFilterType = PriceFilter.Greater;
+
+ private final int splits = 2;
+
+ public String latestBid;
+ public long latestBidMillis;
+
+ private final int ySplit = 35;
+ private final int ySplitSize = 18;
+
+ private float scrollAmount;
+
+ public int guiLeft = -1;
+ public int guiTop = -1;
+
+ private final Category CATEGORY_SWORD = new Category("sword", "Swords", "diamond_sword");
+ private final Category CATEGORY_ARMOR = new Category("armor", "Armor", "diamond_chestplate");
+ private final Category CATEGORY_BOWS = new Category("bow", "Bows", "bow");
+ private final Category CATEGORY_ACCESSORIES = new Category("accessories", "Accessories", "diamond");
+
+ private final Category CATEGORY_FISHING_ROD = new Category("fishingrod", "Fishing Rods", "fishing_rod");
+ private final Category CATEGORY_PICKAXE = new Category("pickaxe", "Pickaxes", "iron_pickaxe");
+ private final Category CATEGORY_AXE = new Category("axe", "Axes", "iron_axe");
+ private final Category CATEGORY_SHOVEL = new Category("shovel", "Shovels", "iron_shovel");
+
+ private final Category CATEGORY_PET_ITEM = new Category("petitem", "Pet Items", "lead");
+
+ private final Category CATEGORY_EBOOKS = new Category("ebook", "Enchanted Books", "enchanted_book");
+ private final Category CATEGORY_POTIONS = new Category("potion", "Potions", "potion");
+ private final Category CATEGORY_TRAVEL_SCROLLS = new Category("travelscroll", "Travel Scrolls", "map");
+
+ private final Category CATEGORY_REFORGE_STONES = new Category("reforgestone", "Reforge Stones", "anvil");
+ private final Category CATEGORY_RUNES = new Category("rune", "Runes", "magma_cream");
+ private final Category CATEGORY_FURNITURE = new Category("furniture", "Furniture", "armor_stand");
+
+ private final Category CATEGORY_COMBAT = new Category("weapon", "Combat", "golden_sword", CATEGORY_SWORD,
+ CATEGORY_BOWS, CATEGORY_ARMOR, CATEGORY_ACCESSORIES
+ );
+ private final Category CATEGORY_TOOL = new Category(
+ "",
+ "Tools",
+ "diamond_pickaxe",
+ CATEGORY_FISHING_ROD,
+ CATEGORY_PICKAXE,
+ CATEGORY_AXE,
+ CATEGORY_SHOVEL
+ );
+ private final Category CATEGORY_PET = new Category("pet", "Pets", "bone", CATEGORY_PET_ITEM);
+ private final Category CATEGORY_CONSUMABLES = new Category(
+ "consumables",
+ "Consumables",
+ "apple",
+ CATEGORY_EBOOKS,
+ CATEGORY_POTIONS,
+ CATEGORY_TRAVEL_SCROLLS
+ );
+ private final Category CATEGORY_BLOCKS = new Category("blocks", "Blocks", "cobblestone");
+ private final Category CATEGORY_MISC = new Category("misc", "Misc", "stick", CATEGORY_REFORGE_STONES, CATEGORY_RUNES,
+ CATEGORY_FURNITURE
+ );
+
+ private final 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", "SUPREME", "DIVINE"};
- private static final String[] rarityColours = {"" + EnumChatFormatting.WHITE,
- "" + EnumChatFormatting.GREEN, "" + EnumChatFormatting.BLUE, "" + EnumChatFormatting.DARK_PURPLE,
- "" + EnumChatFormatting.GOLD, "" + EnumChatFormatting.LIGHT_PURPLE, "" + EnumChatFormatting.RED,
- "" + EnumChatFormatting.RED,"" + EnumChatFormatting.AQUA, "" + EnumChatFormatting.AQUA};
-
- 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 static final int DUNGEON_FILTER_ALL = 0;
- private static final int DUNGEON_FILTER_DUNGEON = 1;
- private static final int DUNGEON_FILTER_1 = 2;
- private static final int DUNGEON_FILTER_2 = 3;
- private static final int DUNGEON_FILTER_3 = 4;
- private static final int DUNGEON_FILTER_4 = 5;
- private static final int DUNGEON_FILTER_5 = 6;
-
- private int dungeonFilter = DUNGEON_FILTER_ALL;
- 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 final ItemStack DUNGEON_SORT = Utils.createItemStack(Item.getItemFromBlock(Blocks.deadbush),
- EnumChatFormatting.GREEN + "Dungeon Sorting");
- private static final ItemStack CONTROL_SORT = Utils.createItemStack(Item.getItemFromBlock(Blocks.hopper),
- EnumChatFormatting.GREEN + "Sort");
- private static final ItemStack CONTROL_TIER = Utils.createItemStack(Items.ender_eye,
- EnumChatFormatting.GREEN + "Item Tier");
- private static final ItemStack CONTROL_MYAUC = Utils.createItemStack(Items.gold_ingot,
- EnumChatFormatting.GREEN + "My Auctions");
- private static final ItemStack CONTROL_BIN = Utils.createItemStack(Item.getItemFromBlock(Blocks.golden_rail),
- EnumChatFormatting.GREEN + "BIN Filter");
- private static final ItemStack CONTROL_ENCH = Utils.createItemStack(Items.enchanted_book,
- EnumChatFormatting.GREEN + "Enchant Filter");
- private static final ItemStack CONTROL_STATS = Utils.createItemStack(Item.getItemFromBlock(Blocks.command_block),
- EnumChatFormatting.GREEN + "Stats for nerds");
- private final ItemStack[] controls = {DUNGEON_SORT, CONTROL_SORT, CONTROL_TIER, null, CONTROL_MYAUC, null, CONTROL_BIN, CONTROL_ENCH, CONTROL_STATS};
-
- private final NEUManager manager;
-
- public CustomAH(NEUManager manager) {
- this.manager = manager;
- }
-
- public void clearSearch() {
- if (searchField == null || priceField == null) init();
- if (System.currentTimeMillis() - lastOpen < 1000) Mouse.setGrabbed(false);
-
- //sortMode = SORT_MODE_HIGH;
- rarityFilter = -1;
- filterMyAuctions = false;
- //binFilter = BIN_FILTER_ALL;
- enchFilter = ENCH_FILTER_ALL;
- dungeonFilter = DUNGEON_FILTER_ALL;
-
- searchField.setText("");
- searchField.setFocused(true);
- priceField.setText("");
- }
-
- public void setSearch(String search) {
- searchField.setText(search);
- updateSearch();
- }
-
- public void tick() {
- if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) return;
- if (Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || renderOverAuctionView) {
- if (shouldUpdateSearch) updateSearch();
- if (shouldSortItems) {
- sortItems();
- shouldSortItems = false;
- }
- }
- }
-
- public static 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,
- 84, fr.FONT_HEIGHT);
- this.priceField = new GuiTextField(1, fr, this.guiLeft + 82, this.guiTop + 6,
- 84, fr.FONT_HEIGHT);
- this.priceFilterField = new GuiTextField(2, fr, this.guiLeft + 82, this.guiTop + 6,
- 84, fr.FONT_HEIGHT);
- this.binPriceFilterField = new GuiTextField(3, fr, this.guiLeft + 82, this.guiTop - 6, 84, fr.FONT_HEIGHT);
-
- this.searchField.setMaxStringLength(30);
- this.searchField.setEnableBackgroundDrawing(false);
- this.searchField.setTextColor(16777215);
- this.searchField.setVisible(true);
- this.searchField.setCanLoseFocus(true);
- 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(true);
- this.priceField.setFocused(false);
- this.priceField.setText("");
-
- this.priceFilterField.setMaxStringLength(10);
- this.priceFilterField.setEnableBackgroundDrawing(false);
- this.priceFilterField.setTextColor(16777215);
- this.priceFilterField.setVisible(true);
- this.priceFilterField.setCanLoseFocus(true);
- this.priceFilterField.setFocused(false);
- this.priceFilterField.setText("");
-
- this.binPriceFilterField.setMaxStringLength(10);
- this.binPriceFilterField.setEnableBackgroundDrawing(false);
- this.binPriceFilterField.setTextColor(16777215);
- this.binPriceFilterField.setVisible(true);
- this.binPriceFilterField.setCanLoseFocus(true);
- this.binPriceFilterField.setFocused(false);
- this.binPriceFilterField.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;
- }
-
- public int getXSize() {
- return 195;
- }
-
- public int getYSize() {
- return 136 + ySplitSize * splits;
- }
-
- 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);
-
- String endsIn = "";
- if (millis < 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";
- }
-
- return endsIn;
- }
-
- public List<String> getTooltipForAucId(String aucId) {
- APIManager.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 + "-----------------");
- 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));
- }
- }
-
- if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoAucItem) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(auc.getStack());
- if (internalname != null) {
- if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
- tooltip.add("");
- tooltip.add(EnumChatFormatting.GRAY + "[SHIFT for Price Info]");
- } else {
- ItemPriceInformation.addToTooltip(tooltip, internalname, auc.getStack());
- }
- }
- }
-
- 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 + 1);
- 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();
- }
-
- private final HashMap<Pattern, Long> timeParseMap = new HashMap<Pattern, Long>() {{
- 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");
-
- put(dayPattern, 24 * 60 * 60 * 1000L);
- put(hourPattern, 60 * 60 * 1000L);
- put(minutePattern, 60 * 1000L);
- put(secondPattern, 1000L);
- }};
-
- public long prettyTimeToMillis(String endsInStr) {
- 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 findStrStart(ItemStack stack, String toFind) {
- if (stack.hasTagCompound()) {
- //ยง7Ends in:
- for (String line : manager.getLoreFromNBT(stack.getTagCompound())) {
- if (line.trim().startsWith(toFind)) {
- return line.substring(toFind.length());
- }
- }
- }
-
- return null;
- }
-
- public String findEndsInStr(ItemStack stack) {
- return findStrStart(stack, EnumChatFormatting.GRAY + "Ends in: ");
- }
-
- 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();
-
- boolean hasPopup = false;
-
- if (searchField == null || priceField == null || priceFilterField == null) init();
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
-
- guiLeft = (width - getXSize()) / 2;
- guiTop = (height - getYSize()) / 2;
- this.searchField.xPosition = guiLeft + 82;
- this.searchField.yPosition = guiTop + 6;
-
- 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));
- if (containerName.trim().equals("Auction View") || containerName.trim().equals("BIN Auction View")) {
- hasPopup = true;
- 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;
- }
-
- String endsInStr = findEndsInStr(topStack);
- if (endsInStr != null) {
- long auctionViewEndsIn = prettyTimeToMillis(endsInStr);
- if (auctionViewEndsIn > 0) {
- if (System.currentTimeMillis() - currAucIdSetTimer > 1000) {
- APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(currentAucId);
- if (auc != null) {
- auc.end = auctionViewEndsIn + lastGuiScreenSwitch;
- }
- }
- endsInStr = EnumChatFormatting.DARK_PURPLE + prettyTime(
- auctionViewEndsIn + lastGuiScreenSwitch - System.currentTimeMillis());
- }
- 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);
-
- 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);
- tooltipToRender.add("");
- tooltipToRender.add(EnumChatFormatting.YELLOW + "Click to copy seller name!");
- }
- } 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) {
- tooltipToRender = new ArrayList<>();
- APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(currentAucId);
- if (auc != null) {
- tooltipToRender.add(EnumChatFormatting.WHITE + "Price Info");
-
- String internalname = manager.getInternalNameForItem(auc.getStack());
- JsonObject auctionInfo = manager.auctionManager.getItemAuctionInfo(internalname);
- JsonObject bazaarInfo = manager.auctionManager.getBazaarInfo(internalname);
-
- boolean hasAuctionPrice = auctionInfo != null;
- boolean hasBazaarPrice = bazaarInfo != null;
-
- int lowestBin = manager.auctionManager.getLowestBin(internalname);
-
- NumberFormat format = NumberFormat.getInstance(Locale.US);
-
- APIManager.CraftInfo craftCost = manager.auctionManager.getCraftCost(internalname);
-
- if (lowestBin > 0) {
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Lowest BIN: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(lowestBin) + " coins");
- }
- if (hasBazaarPrice) {
- int bazaarBuyPrice = (int) bazaarInfo.get("avg_buy").getAsFloat();
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Buy: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(bazaarBuyPrice) + " coins");
- int bazaarSellPrice = (int) bazaarInfo.get("avg_sell").getAsFloat();
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Sell: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(bazaarSellPrice) + " coins");
- int bazaarInstantBuyPrice = (int) bazaarInfo.get("curr_buy").getAsFloat();
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Insta-Buy: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(bazaarInstantBuyPrice) + " coins");
- int bazaarInstantSellPrice = (int) bazaarInfo.get("curr_sell").getAsFloat();
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Insta-Sell: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(bazaarInstantSellPrice) + " coins");
- }
- if (hasAuctionPrice) {
- int auctionPrice = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Price: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(auctionPrice) + " coins");
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Sales: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(auctionInfo.get("sales").getAsFloat()) + " sales/day");
- if (auctionInfo.has("clean_price")) {
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Price (Clean): " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format((int) auctionInfo.get("clean_price").getAsFloat()) + " coins");
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Sales (Clean): " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(auctionInfo.get("clean_sales").getAsFloat()) + " sales/day");
- }
-
- }
- if (craftCost.fromRecipe) {
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Raw Craft Cost: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format((int) craftCost.craftCost) + " coins");
- }
- tooltipToRender.add("");
- }
- if (rightStack != null)
- tooltipToRender.addAll(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") || containerName.trim().equals("Confirm Purchase")) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_accept);
- this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172);
-
- 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