From 7de14ba5f7914ee9528c7a8efd834f66e2a92db5 Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Sun, 22 May 2022 06:06:42 +0200 Subject: Trade Window price int -> double (#145) --- .../moulberry/notenoughupdates/miscgui/TradeWindow.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java index 1ba155d5..1c5bc2e3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java @@ -26,8 +26,14 @@ import org.lwjgl.opengl.GL11; import java.awt.*; import java.io.ByteArrayInputStream; import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; -import java.util.*; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -799,7 +805,7 @@ public class TradeWindow { TreeMap> ourTopItems = new TreeMap<>(); TreeMap ourTopItemsStack = new TreeMap<>(); TreeMap ourTopItemsCount = new TreeMap<>(); - int ourPrice = 0; + double ourPrice = 0; for (int i = 0; i < 16; i++) { int x = i % 4; int y = i / 4; @@ -813,7 +819,7 @@ public class TradeWindow { TreeMap> theirTopItems = new TreeMap<>(); TreeMap theirTopItemsStack = new TreeMap<>(); TreeMap theirTopItemsCount = new TreeMap<>(); - int theirPrice = 0; + double theirPrice = 0; for (int i = 0; i < 16; i++) { int x = i % 4; int y = i / 4; -- cgit From 73dbbed409a86328144f2c75f460426e7baa6ae1 Mon Sep 17 00:00:00 2001 From: Roman / Nea Date: Thu, 2 Jun 2022 09:59:07 +0200 Subject: Loomerings (#152) --- .../io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java index 1c5bc2e3..1f47e6ee 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java @@ -4,6 +4,7 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.KeybindHelper; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; +import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -559,8 +560,7 @@ public class TradeWindow { int y = 104 + 18 * (index / 9); if (index < 9) y = 180; - chest.drawSlot(new Slot(Minecraft.getMinecraft().thePlayer.inventory, index, guiLeft + x, guiTop + y)); - //Utils.drawItemStack(stack, guiLeft+x, guiTop+y); + ((AccessorGuiContainer)chest).doDrawSlot(new Slot(Minecraft.getMinecraft().thePlayer.inventory, index, guiLeft + x, guiTop + y)); int col = 0x80ffffff; if (SlotLocking.getInstance().isSlotIndexLocked(index)) { -- cgit From 50dc2122462642a0c3a00b3a3ae6389825dc04df Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Thu, 9 Jun 2022 18:04:22 -0400 Subject: Re-license project as LGPL (#157) * add licence files & a few misc chores * add license notices & run auto formatter --- .../notenoughupdates/miscgui/TradeWindow.java | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java index 1f47e6ee..086b6e06 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see . + */ + package io.github.moulberry.notenoughupdates.miscgui; import com.google.gson.JsonObject; @@ -560,7 +579,12 @@ public class TradeWindow { int y = 104 + 18 * (index / 9); if (index < 9) y = 180; - ((AccessorGuiContainer)chest).doDrawSlot(new Slot(Minecraft.getMinecraft().thePlayer.inventory, index, guiLeft + x, guiTop + y)); + ((AccessorGuiContainer) chest).doDrawSlot(new Slot( + Minecraft.getMinecraft().thePlayer.inventory, + index, + guiLeft + x, + guiTop + y + )); int col = 0x80ffffff; if (SlotLocking.getInstance().isSlotIndexLocked(index)) { -- cgit From e548f8974f402025692baa60c22a06c38a99c4a3 Mon Sep 17 00:00:00 2001 From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com> Date: Tue, 12 Jul 2022 13:13:09 -0400 Subject: Add Craft Cost to Trade Window (#185) * Add Craft Cost to Trade Window * Allow Vanilla items whoops --- .../io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java index 086b6e06..6107985c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java @@ -21,6 +21,7 @@ package io.github.moulberry.notenoughupdates.miscgui; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.auction.APIManager; import io.github.moulberry.notenoughupdates.core.config.KeybindHelper; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; @@ -138,6 +139,12 @@ public class TradeWindow { pricePer = auctionPricePer; } } + if (pricePer == -1) { + APIManager.CraftInfo craftCost = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(internalname); + if (craftCost != null) { + pricePer = (int) craftCost.craftCost; + } + } return pricePer; } -- cgit From bd1c17841e40a0bc3b666796431cbe84d2cd203d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 29 Jul 2022 10:41:49 +0200 Subject: changed int to long and float to double in item price logic (#197) --- .../notenoughupdates/miscgui/TradeWindow.java | 60 +++++++++++----------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java index 6107985c..8a0353d3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java @@ -122,25 +122,25 @@ public class TradeWindow { ); } - private static int getPrice(String internalname) { - int pricePer = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname); + private static long getPrice(String internalName) { + long pricePer = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalName); if (pricePer == -1) { - JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname); + JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalName); if (bazaarInfo != null && bazaarInfo.has("avg_buy")) { - pricePer = (int) bazaarInfo.get("avg_buy").getAsFloat(); + pricePer = (long) bazaarInfo.get("avg_buy").getAsDouble(); } } if (pricePer == -1) { - JsonObject info = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname); - if (info != null && !NotEnoughUpdates.INSTANCE.manager.auctionManager.isVanillaItem(internalname) && + JsonObject info = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalName); + if (info != null && !NotEnoughUpdates.INSTANCE.manager.auctionManager.isVanillaItem(internalName) && info.has("price") && info.has("count")) { - int auctionPricePer = (int) (info.get("price").getAsFloat() / info.get("count").getAsFloat()); + long auctionPricePer = (long) (info.get("price").getAsDouble() / info.get("count").getAsDouble()); pricePer = auctionPricePer; } } if (pricePer == -1) { - APIManager.CraftInfo craftCost = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(internalname); + APIManager.CraftInfo craftCost = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(internalName); if (craftCost != null) { pricePer = (int) craftCost.craftCost; } @@ -148,8 +148,8 @@ public class TradeWindow { return pricePer; } - private static int processTopItems( - ItemStack stack, Map> topItems, + private static long processTopItems( + ItemStack stack, Map> topItems, Map topItemsStack, Map topItemsCount ) { String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack); @@ -188,9 +188,9 @@ public class TradeWindow { topItemsStack.putIfAbsent("TRADE_COINS", stack); - int existingPrice = coins; - Set toRemove = new HashSet<>(); - for (Map.Entry> entry : topItems.entrySet()) { + long existingPrice = coins; + Set toRemove = new HashSet<>(); + for (Map.Entry> entry : topItems.entrySet()) { if (entry.getValue().contains("TRADE_COINS")) { entry.getValue().remove("TRADE_COINS"); existingPrice += entry.getKey(); @@ -208,12 +208,12 @@ public class TradeWindow { } } } else { - int pricePer = getPrice(internalname); + long pricePer = getPrice(internalname); if (pricePer > 0) { topItemsStack.putIfAbsent(internalname, stack); - int price = pricePer * stack.stackSize; - int priceInclBackpack = price; + long price = pricePer * stack.stackSize; + long priceInclBackpack = price; NBTTagCompound tag = stack.getTagCompound(); if (tag != null && tag.hasKey("ExtraAttributes", 10)) { @@ -254,9 +254,9 @@ public class TradeWindow { } } - int existingPrice = price; - Set toRemove = new HashSet<>(); - for (Map.Entry> entry : topItems.entrySet()) { + long existingPrice = price; + Set toRemove = new HashSet<>(); + for (Map.Entry> entry : topItems.entrySet()) { if (entry.getValue().contains(internalname)) { entry.getValue().remove(internalname); existingPrice += entry.getKey(); @@ -300,7 +300,7 @@ public class TradeWindow { NBTTagCompound nbt = items.getCompoundTagAt(k).getCompoundTag("tag"); String internalname2 = NotEnoughUpdates.INSTANCE.manager.getInternalnameFromNBT(nbt); if (internalname2 != null) { - int pricePer2 = getPrice(internalname2); + long pricePer2 = getPrice(internalname2); if (pricePer2 > 0) { int count2 = items.getCompoundTagAt(k).getByte("Count"); price += pricePer2 * count2; @@ -333,7 +333,7 @@ public class TradeWindow { //Set index mappings //Our slots - TreeMap> ourTradeMap = new TreeMap<>(); + TreeMap> ourTradeMap = new TreeMap<>(); for (int i = 0; i < 16; i++) { ourTradeIndexes[i] = -1; @@ -378,19 +378,19 @@ public class TradeWindow { try { int coins = (int) (Float.parseFloat(sb.toString()) * mult); - List list = ourTradeMap.computeIfAbsent(coins, k -> new ArrayList<>()); + List list = ourTradeMap.computeIfAbsent((long) coins, k -> new ArrayList<>()); list.add(containerIndex); } catch (Exception ignored) { - List list = ourTradeMap.computeIfAbsent(-1, k -> new ArrayList<>()); + List list = ourTradeMap.computeIfAbsent(-1L, k -> new ArrayList<>()); list.add(containerIndex); } } else { - List list = ourTradeMap.computeIfAbsent(-1, k -> new ArrayList<>()); + List list = ourTradeMap.computeIfAbsent(-1L, k -> new ArrayList<>()); list.add(containerIndex); } } else { - int price = getPrice(internalname); + long price = getPrice(internalname); if (price == -1) price = 0; price += getBackpackValue(stack); @@ -501,7 +501,7 @@ public class TradeWindow { } } int ourTradeIndex = 0; - for (Map.Entry> entry : ourTradeMap.descendingMap().entrySet()) { + for (Map.Entry> entry : ourTradeMap.descendingMap().entrySet()) { for (Integer index : entry.getValue()) { ourTradeIndexes[ourTradeIndex++] = index; } @@ -833,7 +833,7 @@ public class TradeWindow { } if (NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices) { - TreeMap> ourTopItems = new TreeMap<>(); + TreeMap> ourTopItems = new TreeMap<>(); TreeMap ourTopItemsStack = new TreeMap<>(); TreeMap ourTopItemsCount = new TreeMap<>(); double ourPrice = 0; @@ -847,7 +847,7 @@ public class TradeWindow { ourPrice += processTopItems(stack, ourTopItems, ourTopItemsStack, ourTopItemsCount); } - TreeMap> theirTopItems = new TreeMap<>(); + TreeMap> theirTopItems = new TreeMap<>(); TreeMap theirTopItemsStack = new TreeMap<>(); TreeMap theirTopItemsCount = new TreeMap<>(); double theirPrice = 0; @@ -879,7 +879,7 @@ public class TradeWindow { int ourTopIndex = Math.max(0, 3 - ourTopItemsStack.size()); out: - for (Map.Entry> entry : ourTopItems.descendingMap().entrySet()) { + for (Map.Entry> entry : ourTopItems.descendingMap().entrySet()) { for (String ourTopItemInternal : entry.getValue()) { ItemStack stack = ourTopItemsStack.get(ourTopItemInternal); if (stack == null) continue; @@ -942,7 +942,7 @@ public class TradeWindow { int theirTopIndex = Math.max(0, 3 - theirTopItemsStack.size()); out: - for (Map.Entry> entry : theirTopItems.descendingMap().entrySet()) { + for (Map.Entry> entry : theirTopItems.descendingMap().entrySet()) { for (String theirTopItemInternal : entry.getValue()) { ItemStack stack = theirTopItemsStack.get(theirTopItemInternal); if (stack == null) continue; -- cgit From d823d2ab08cbc41fac67f06a7d38009627d4497e Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Fri, 7 Oct 2022 06:06:27 +1100 Subject: Fix custom trade menu (#345) * i love the hypixel network * println("$slot.slotNumber ${slot.stack.displayName}" --- .../java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java index 8a0353d3..16b5015b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java @@ -1078,7 +1078,7 @@ public class TradeWindow { !SlotLocking.getInstance().isSlotLocked(slot)) { Minecraft.getMinecraft().playerController.windowClick( chest.inventorySlots.windowId, - slot.slotNumber, 2, 3, Minecraft.getMinecraft().thePlayer + slot.slotNumber, 0, 0, Minecraft.getMinecraft().thePlayer ); } return; -- cgit