aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscgui
diff options
context:
space:
mode:
authorkr45732 <52721908+kr45732@users.noreply.github.com>2023-06-08 10:00:04 -0400
committerGitHub <noreply@github.com>2023-06-08 16:00:04 +0200
commit8115922b37e375285c2a72dbdbb5d83fd942e27c (patch)
treee0d6cb5228493e8bb032465cbb2dfd95b4946e43 /src/main/java/io/github/moulberry/notenoughupdates/miscgui
parenta6fb7bfb97d313b665085a52a660150f1da26065 (diff)
downloadnotenoughupdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.tar.gz
notenoughupdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.tar.bz2
notenoughupdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.zip
PV Overhaul (#708)
Co-authored-by: Lulonaut <lulonaut@tutanota.de>
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java35
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java19
2 files changed, 21 insertions, 33 deletions
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 6d565bb3..4d88ef07 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java
@@ -23,6 +23,7 @@ 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.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking;
import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer;
import io.github.moulberry.notenoughupdates.util.Utils;
@@ -46,12 +47,10 @@ 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.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -75,10 +74,6 @@ public class TradeWindow {
private static String[] theirTradeOld = new String[16];
private static Long[] theirTradeChangesMillis = new Long[16];
- private static ItemStack lastBackpack;
- private static int lastBackpackX;
- private static int lastBackpackY;
-
public static boolean hypixelTradeWindowActive(String containerName) {
return containerName != null && containerName.trim().startsWith("You ");
}
@@ -129,9 +124,8 @@ public class TradeWindow {
JsonObject info = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalName);
if (info != null && !NotEnoughUpdates.INSTANCE.manager.auctionManager.isVanillaItem(internalName) &&
info.has("price") && info.has("count")) {
- long auctionPricePer = (long) (info.get("price").getAsDouble() / info.get("count").getAsDouble());
- pricePer = auctionPricePer;
+ pricePer = (long) (info.get("price").getAsDouble() / info.get("count").getAsDouble());
}
}
if (pricePer == -1) {
@@ -293,7 +287,9 @@ public class TradeWindow {
for (int k = 0; k < items.tagCount(); k++) {
if (items.getCompoundTagAt(k).getKeySet().size() > 0) {
NBTTagCompound nbt = items.getCompoundTagAt(k).getCompoundTag("tag");
- String internalname2 = NotEnoughUpdates.INSTANCE.manager.getInternalnameFromNBT(nbt);
+ String internalname2 = NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery()
+ .withItemNBT(nbt)
+ .resolveInternalName();
if (internalname2 != null) {
long pricePer2 = getPrice(internalname2);
if (pricePer2 > 0) {
@@ -412,7 +408,7 @@ public class TradeWindow {
if (stack == null) continue;
NBTTagCompound tag = stack.getTagCompound();
- String uuid = null;
+ String uuid;
if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
@@ -533,7 +529,7 @@ public class TradeWindow {
if (stack == null) continue;
NBTTagCompound tag = stack.getTagCompound();
- String uuid = null;
+ String uuid;
if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
@@ -820,8 +816,6 @@ public class TradeWindow {
theirPrice += processTopItems(stack, theirTopItems, theirTopItemsStack, theirTopItemsCount);
}
- NumberFormat format = NumberFormat.getInstance(Locale.US);
-
GlStateManager.disableLighting();
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(location);
@@ -831,7 +825,7 @@ public class TradeWindow {
drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + "Total Value",
guiLeft - 40 - 3, guiTop + 11, 72
);
- drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(ourPrice),
+ drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + StringUtils.formatNumber(ourPrice),
guiLeft - 40 - 3, guiTop + 21, 72
);
@@ -861,7 +855,7 @@ public class TradeWindow {
GlStateManager.disableBlend();
GlStateManager.color(1, 1, 1, 1);
drawStringShadow(
- EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(entry.getKey()),
+ EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + StringUtils.formatNumber(entry.getKey()),
guiLeft - 29 - 3,
guiTop + 57 + 18 * ourTopIndex,
52
@@ -875,7 +869,7 @@ public class TradeWindow {
72
);
drawStringShadow(
- EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(entry.getKey()),
+ EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + StringUtils.formatNumber(entry.getKey()),
guiLeft - 40 - 3,
guiTop + 56 + 20 * ourTopIndex,
72
@@ -894,7 +888,7 @@ public class TradeWindow {
drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + "Total Value",
guiLeft + xSize + 3 + 40, guiTop + 11, 72
);
- drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(theirPrice),
+ drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + StringUtils.formatNumber(theirPrice),
guiLeft + xSize + 3 + 40, guiTop + 21, 72
);
@@ -924,7 +918,7 @@ public class TradeWindow {
GlStateManager.disableBlend();
GlStateManager.color(1, 1, 1, 1);
drawStringShadow(
- EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(entry.getKey()),
+ EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + StringUtils.formatNumber(entry.getKey()),
guiLeft + xSize + 3 + 51,
guiTop + 57 + 18 * theirTopIndex,
52
@@ -935,7 +929,7 @@ public class TradeWindow {
guiLeft + xSize + 3 + 40, guiTop + 46 + 20 * theirTopIndex, 72
);
drawStringShadow(
- EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(entry.getKey()),
+ EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + StringUtils.formatNumber(entry.getKey()),
guiLeft + xSize + 3 + 40,
guiTop + 56 + 20 * theirTopIndex,
72
@@ -1099,15 +1093,12 @@ public class TradeWindow {
if (mouseY >= guiTop + ySize - 19 && mouseY <= guiTop + ySize - 19 + 17) {
NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade =
!NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade;
- return;
} else if (mouseY >= guiTop + ySize - 38 && mouseY <= guiTop + ySize - 38 + 17) {
NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices =
!NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices;
- return;
} else if (mouseY >= guiTop + ySize - 57 && mouseY <= guiTop + ySize - 57 + 17) {
NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle =
!NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle;
- return;
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java
index deef7bdc..fb936a4d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java
@@ -25,6 +25,7 @@ import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.GlScissorStack;
import io.github.moulberry.notenoughupdates.core.GuiElementTextField;
+import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingFloat;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking;
@@ -63,13 +64,11 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.Project;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
-import java.util.Locale;
import java.util.Objects;
import java.util.Random;
import java.util.regex.Matcher;
@@ -82,14 +81,10 @@ public class GuiCustomHex extends Gui {
"textures/entity/enchanting_table_book.png");
private static final ModelBook MODEL_BOOK = new ModelBook();
- private static final int EXPERIENCE_ORB_COUNT = 30;
-
private static final Pattern XP_COST_PATTERN = Pattern.compile("\\u00a73(\\d+) Exp Levels");
private static final Pattern ENCHANT_LEVEL_PATTERN = Pattern.compile("(.*)_(.*)");
private static final Pattern ENCHANT_NAME_PATTERN = Pattern.compile("([^IVX]*) ([IVX]*)");
- public static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
-
public class Enchantment {
public int slotIndex;
public String enchantName;
@@ -112,8 +107,10 @@ public class GuiCustomHex extends Gui {
this.level = level;
boolean isUlt = false;
for (String lore : displayLore) {
- if (lore.contains("§l")) isUlt = true;
- break;
+ if (lore.contains("§l")) {
+ isUlt = true;
+ break;
+ }
}
JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(
(isUlt ? "ULTIMATE_" : "") + enchId.toUpperCase() + ";" + level);
@@ -502,7 +499,7 @@ public class GuiCustomHex extends Gui {
int index = 0;
for (String lore : enchantment.displayLore) {
if (lore.contains("N/A") && enchantment.price > 0) {
- String price = numberFormat.format(enchantment.price);
+ String price = StringUtils.formatNumber(enchantment.price);
enchantment.displayLore.set(index, "\u00a76" + price + ".0 Coins");
}
if (lore.contains("Loading...")) {
@@ -1532,7 +1529,7 @@ public class GuiCustomHex extends Gui {
fr.drawString(levelStr, left + 8 - levelWidth / 2, top + 4 + 1, 0x2d2102, false);
fr.drawString(levelStr, left + 8 - levelWidth / 2, top + 4, colour, false);
- String priceStr = "" + numberFormat.format(enchanterCurrentEnch.price) + " Coins";
+ String priceStr = StringUtils.formatNumber(enchanterCurrentEnch.price) + " Coins";
if (enchanterCurrentEnch.price < 0) priceStr = "";
int priceWidth = fr.getStringWidth(priceStr);
int priceTop = guiTop + 16;
@@ -2076,7 +2073,7 @@ public class GuiCustomHex extends Gui {
}
}
- String priceStr = "" + numberFormat.format(enchanterCurrentItem.getPrice()) + " Coins";
+ String priceStr = StringUtils.formatNumber(enchanterCurrentItem.getPrice()) + " Coins";
if (enchanterCurrentItem.price < 0) priceStr = "";
int priceWidth = fr.getStringWidth(priceStr);
int priceTop = guiTop + 10;