From 5bcf7cc19df3ff59385b1de06cc3e2e827f5e2b6 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 26 Jul 2022 14:00:45 +0200 Subject: Added power stone feature (#194) Co-authored-by: Lorenz --- .../notenoughupdates/NotEnoughUpdates.java | 2 + .../notenoughupdates/core/util/StringUtils.java | 10 ++ .../miscfeatures/PowerStoneStatsDisplay.java | 168 +++++++++++++++++++++ .../notenoughupdates/options/NEUConfig.java | 2 + .../options/seperateSections/TooltipTweaks.java | 8 + 5 files changed, 190 insertions(+) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 8c23aa60..6bf6d86b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -49,6 +49,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.NPCRetexturing; import io.github.moulberry.notenoughupdates.miscfeatures.Navigation; import io.github.moulberry.notenoughupdates.miscfeatures.NullzeeSphere; import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay; +import io.github.moulberry.notenoughupdates.miscfeatures.PowerStoneStatsDisplay; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; import io.github.moulberry.notenoughupdates.miscfeatures.SunTzu; @@ -287,6 +288,7 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(new OldAnimationChecker()); MinecraftForge.EVENT_BUS.register(new SignCalculator()); MinecraftForge.EVENT_BUS.register(TrophyRewardOverlay.getInstance()); + MinecraftForge.EVENT_BUS.register(PowerStoneStatsDisplay.getInstance()); MinecraftForge.EVENT_BUS.register(navigation); if (Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java index 41f2742f..d52f9ba1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java @@ -53,4 +53,14 @@ public class StringUtils { return trim; } + + public static String substringBetween(String str, String open, String close) { + return org.apache.commons.lang3.StringUtils.substringBetween(str, open, close); + } + + public static int cleanAndParseInt(String str) { + str = cleanColour(str); + str = str.replace(",", ""); + return Integer.parseInt(str); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java new file mode 100644 index 00000000..e62e572d --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java @@ -0,0 +1,168 @@ +/* + * 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.miscfeatures; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import io.github.moulberry.notenoughupdates.options.NEUConfig; +import io.github.moulberry.notenoughupdates.util.ItemUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import java.text.NumberFormat; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; + +public class PowerStoneStatsDisplay { + private static PowerStoneStatsDisplay instance = null; + NumberFormat format = NumberFormat.getInstance(Locale.US); + + public static PowerStoneStatsDisplay getInstance() { + if (instance == null) { + instance = new PowerStoneStatsDisplay(); + } + return instance; + } + + @SubscribeEvent + public void onTick(TickEvent event) { + GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen; + if (currentScreen == null) return; + if (!(currentScreen instanceof GuiChest)) return; + ContainerChest container = (ContainerChest) ((GuiChest) currentScreen).inventorySlots; + IInventory menu = container.getLowerChestInventory(); + String title = menu.getDisplayName().getUnformattedText(); + + if (!title.equals("SkyBlock Menu")) return; + + EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; + Container openContainer = p.openContainer; + for (Slot slot : openContainer.inventorySlots) { + ItemStack stack = slot.getStack(); + if (stack == null) continue; + + String displayName = stack.getDisplayName(); + if (!"§aAccessory Bag".equals(displayName)) continue; + + for (String line : ItemUtils.getLore(stack)) { + if (line.startsWith("§7Magical Power: ")) { + String rawNumber = line.split("§6")[1].replace(",", ""); + NEUConfig.HiddenProfileSpecific configProfileSpecific = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); + if (configProfileSpecific == null) return; + configProfileSpecific.magicalPower = Integer.parseInt(rawNumber); + } + } + } + } + + @SubscribeEvent + public void onItemTooltipLow(ItemTooltipEvent event) { + if (!NotEnoughUpdates.INSTANCE.config.tooltipTweaks.powerStoneStats) return; + + ItemStack itemStack = event.itemStack; + if (itemStack == null) return; + List lore = ItemUtils.getLore(itemStack); + + boolean isPowerStone = false; + for (String line : lore) { + if (line.equals("§8Power Stone")) { + isPowerStone = true; + break; + } + } + + if (!isPowerStone) return; + + NEUConfig.HiddenProfileSpecific configProfileSpecific = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); + if (configProfileSpecific == null) return; + + int magicalPower = configProfileSpecific.magicalPower; + if (magicalPower < 1) return; + + double scaledMagicalPower = scalePower(magicalPower); + double scaledCurrentPower = 0.0; + + int index = 0; + boolean foundMagicalPower = false; + for (String line : new LinkedList<>(lore)) { + index++; + line = line.replace("§k", ""); + + if (line.startsWith("§7At ")) { + + String rawNumber = StringUtils.substringBetween(StringUtils.cleanColour(line), "At ", " Magical"); + if (rawNumber == null) return; + + //This ignores old repo entries in the item browser from neu + if (rawNumber.equals("mmm")) return; + + try { + scaledCurrentPower = scalePower(StringUtils.cleanAndParseInt(rawNumber)); + } catch (NumberFormatException ignored) { + return; + } + + event.toolTip.set(index, "§7At §6" + format.format((double) magicalPower) + " Magical Power§7:"); + foundMagicalPower = true; + continue; + } + + if (!foundMagicalPower) continue; + + String cleanLine = StringUtils.cleanColour(line); + if (cleanLine.equals("")) { + break; + } + + for (String operator : new String[]{"+", "-"}) { + if (!cleanLine.startsWith(operator)) continue; + String rawStat = StringUtils.cleanColour(StringUtils.substringBetween(line, operator, " ")); + + double currentStat; + try { + currentStat = 0.0 + StringUtils.cleanAndParseInt(rawStat.substring(0, rawStat.length() - 1)); + } catch (NumberFormatException ignored) { + continue; + } + double realStat = (currentStat / scaledCurrentPower) * scaledMagicalPower; + + String format = this.format.format((double) Math.round(realStat)); + format += rawStat.substring(rawStat.length() - 1); + + event.toolTip.set(index, line.replace(rawStat, format)); + } + } + } + + private double scalePower(int magicalPower) { + return Math.pow(29.97 * (Math.log(0.0019 * magicalPower + 1)), 1.2); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index e1848382..ade9edfe 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -564,6 +564,8 @@ public class NEUConfig extends Config { public long dailyHeavyPearlCompleted = 0L; @Expose public HashMap savedEquipment = new HashMap<>(); + @Expose + public int magicalPower = 0; } public HiddenLocationSpecific getLocationSpecific() { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java index d1660e68..bcb7e8a7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java @@ -172,4 +172,12 @@ public class TooltipTweaks { minStep = 1f ) public int tooltipBorderOpacity = 200; + + @Expose + @ConfigOption( + name = "Power Stone Stats", + desc = "Show your real magical power and real stat increase on power stones" + ) + @ConfigEditorBoolean + public boolean powerStoneStats = true; } -- cgit From c27583484181a9829d515a1984654fdd7554aa00 Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Fri, 29 Jul 2022 10:28:08 +0200 Subject: fix essence parsing on items that don't need other items (#195) --- .../moulberry/notenoughupdates/listener/RenderListener.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java index 794282f1..0c3f592b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java @@ -1173,9 +1173,11 @@ public class RenderListener { } } } - JsonObject itemsObj = jsonObject.get(id).getAsJsonObject().get("items").getAsJsonObject(); - jsonObject.get(id).getAsJsonObject().remove("items"); - jsonObject.get(id).getAsJsonObject().add("items", itemsObj); + if (jsonObject.get(id).getAsJsonObject().has("items")) { + JsonObject itemsObj = jsonObject.get(id).getAsJsonObject().get("items").getAsJsonObject(); + jsonObject.get(id).getAsJsonObject().remove("items"); + jsonObject.get(id).getAsJsonObject().add("items", itemsObj); + } Gson gson = new GsonBuilder().setPrettyPrinting().create(); try { try ( -- 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/ItemPriceInformation.java | 6 +-- .../moulberry/notenoughupdates/NEUOverlay.java | 4 +- .../notenoughupdates/auction/APIManager.java | 22 ++++---- .../notenoughupdates/auction/CustomAH.java | 4 +- .../listener/ItemTooltipListener.java | 10 ++-- .../notenoughupdates/listener/RenderListener.java | 16 +++--- .../miscfeatures/AuctionBINWarning.java | 8 +-- .../miscgui/AccessoryBagOverlay.java | 4 +- .../notenoughupdates/miscgui/TradeWindow.java | 60 +++++++++++----------- .../profileviewer/ProfileViewer.java | 8 +-- 10 files changed, 71 insertions(+), 71 deletions(-) (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java index 4b5630bc..b47a7c7f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java @@ -101,9 +101,9 @@ public class ItemPriceInformation { } JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname); JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname); - float lowestBinAvg = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalname); + double lowestBinAvg = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalname); - int lowestBin = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname); + long lowestBin = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname); APIManager.CraftInfo craftCost = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(internalname); boolean bazaarItem = bazaarInfo != null; @@ -211,7 +211,7 @@ public class ItemPriceInformation { tooltip.add(""); added = true; } - float cost = craftCost.craftCost; + double cost = craftCost.craftCost; if (shiftPressed) cost = cost * shiftStackMultiplier; tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Raw Craft Cost: " + diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index c048ce1b..de050e5e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1261,8 +1261,8 @@ public class NEUOverlay extends Gui { String internal1 = o1.get("internalname").getAsString(); String internal2 = o2.get("internalname").getAsString(); - float cost1 = manager.auctionManager.getLowestBin(internal1); - float cost2 = manager.auctionManager.getLowestBin(internal2); + double cost1 = manager.auctionManager.getLowestBin(internal1); + double cost2 = manager.auctionManager.getLowestBin(internal2); if (cost1 < cost2) return mult; if (cost1 > cost2) return -mult; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java index d4b6bd05..7c58cb4d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -273,11 +273,11 @@ public class APIManager { return keys; } - public int getLowestBin(String internalname) { - if (lowestBins != null && lowestBins.has(internalname)) { - JsonElement e = lowestBins.get(internalname); + public long getLowestBin(String internalName) { + if (lowestBins != null && lowestBins.has(internalName)) { + JsonElement e = lowestBins.get(internalName); if (e.isJsonPrimitive() && e.getAsJsonPrimitive().isNumber()) { - return e.getAsBigDecimal().intValue(); + return e.getAsBigDecimal().longValue(); } } return -1; @@ -775,13 +775,13 @@ public class APIManager { return e.getAsJsonObject(); } - public float getItemAvgBin(String internalname) { + public double getItemAvgBin(String internalName) { if (auctionPricesAvgLowestBinJson == null) return -1; - JsonElement e = auctionPricesAvgLowestBinJson.get(internalname); + JsonElement e = auctionPricesAvgLowestBinJson.get(internalName); if (e == null) { return -1; } - return Math.round(e.getAsFloat()); + return Math.round(e.getAsDouble()); } public Set getBazaarKeySet() { @@ -823,7 +823,7 @@ public class APIManager { public static class CraftInfo { public boolean fromRecipe = false; public boolean vanillaItem = false; - public float craftCost = -1; + public double craftCost = -1; } public CraftInfo getCraftCost(String internalname) { @@ -839,10 +839,10 @@ public class APIManager { visited.add(internalname); boolean vanillaItem = isVanillaItem(internalname); - float craftCost = Float.POSITIVE_INFINITY; + double craftCost = Double.POSITIVE_INFINITY; JsonObject auctionInfo = getItemAuctionInfo(internalname); - float lowestBin = getLowestBin(internalname); + double lowestBin = getLowestBin(internalname); JsonObject bazaarInfo = getBazaarInfo(internalname); if (bazaarInfo != null && bazaarInfo.get("curr_buy") != null) { @@ -889,7 +889,7 @@ public class APIManager { } } visited.remove(internalname); - if (Float.isInfinite(craftCost)) { + if (Double.isInfinite(craftCost)) { return null; } CraftInfo craftInfo = new CraftInfo(); 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 b5d34ed7..d8fedecb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java @@ -679,7 +679,7 @@ public class CustomAH extends Gui { boolean hasAuctionPrice = auctionInfo != null; boolean hasBazaarPrice = bazaarInfo != null; - int lowestBin = manager.auctionManager.getLowestBin(internalname); + long lowestBin = manager.auctionManager.getLowestBin(internalname); NumberFormat format = NumberFormat.getInstance(Locale.US); @@ -1375,7 +1375,7 @@ public class CustomAH extends Gui { } } if (getBinPriceFilterAmount() > -1) { - int lowestBin = + long lowestBin = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem( auc.getStack())); if (lowestBin > 0) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java index 1dc45cf8..14df3926 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java @@ -559,7 +559,7 @@ public class ItemTooltipListener { String missingItem = null; int totalValue = 0; - HashMap itemValues = new HashMap<>(); + HashMap itemValues = new HashMap<>(); for (int i = 0; i < 5; i++) { ItemStack item = lower.getStackInSlot(11 + i); String internal = neu.manager.getInternalNameForItem(item); @@ -572,7 +572,7 @@ public class ItemTooltipListener { } if (bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000; - float worth = -1; + double worth = -1; if (bazaarPrice > 0) { worth = bazaarPrice; } else { @@ -584,9 +584,9 @@ public class ItemTooltipListener { JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal); if (auctionInfo != null) { if (auctionInfo.has("clean_price")) { - worth = (int) auctionInfo.get("clean_price").getAsFloat(); + worth = (long)auctionInfo.get("clean_price").getAsDouble(); } else { - worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); + worth = (long) (auctionInfo.get("price").getAsDouble() / auctionInfo.get("count").getAsDouble()); } } break; @@ -675,7 +675,7 @@ public class ItemTooltipListener { newTooltip.add(neu + EnumChatFormatting.YELLOW + "Profit/Loss: " + plStringBIN); } - for (Map.Entry entry : itemValues.entrySet()) { + for (Map.Entry entry : itemValues.entrySet()) { newTooltip.add(neu + entry.getKey() + prefix + "+" + format.format(entry.getValue().intValue())); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java index 0c3f592b..35a3581a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java @@ -717,7 +717,7 @@ public class RenderListener { String missingItem = null; int totalValue = 0; - HashMap itemValues = new HashMap<>(); + HashMap itemValues = new HashMap<>(); for (int i = 0; i < 5; i++) { ItemStack item = lower.getStackInSlot(11 + i); String internal = neu.manager.getInternalNameForItem(item); @@ -730,7 +730,7 @@ public class RenderListener { } if (bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000; - float worth = -1; + double worth = -1; if (bazaarPrice > 0) { worth = bazaarPrice; } else { @@ -742,9 +742,9 @@ public class RenderListener { JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal); if (auctionInfo != null) { if (auctionInfo.has("clean_price")) { - worth = (int) auctionInfo.get("clean_price").getAsFloat(); + worth = (long) auctionInfo.get("clean_price").getAsDouble(); } else { - worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); + worth = (long) (auctionInfo.get("price").getAsDouble() / auctionInfo.get("count").getAsDouble()); } } break; @@ -813,7 +813,7 @@ public class RenderListener { valueStringBIN2 = missingItem; } - int profitLossBIN = totalValue - chestCost; + long profitLossBIN = totalValue - chestCost; boolean kismetUsed = false; // checking for kismet @@ -827,7 +827,7 @@ public class RenderListener { } } } - int kismetPrice = neu.manager.auctionManager.getLowestBin("KISMET_FEATHER"); + long kismetPrice = neu.manager.auctionManager.getLowestBin("KISMET_FEATHER"); String kismetStr = EnumChatFormatting.RED + format.format(kismetPrice) + " coins"; if (neu.config.dungeons.useKismetOnDungeonProfit) profitLossBIN = kismetUsed ? profitLossBIN - kismetPrice : profitLossBIN; @@ -884,10 +884,10 @@ public class RenderListener { } int index = 0; - for (Map.Entry entry : itemValues.entrySet()) { + for (Map.Entry entry : itemValues.entrySet()) { Utils.renderAlignedString( entry.getKey(), - prefix + format.format(entry.getValue().intValue()), + prefix + format.format(entry.getValue().longValue()), guiLeft + xSize + 4 + 10, guiTop + (neu.config.dungeons.useKismetOnDungeonProfit ? (kismetUsed ? 39 : 29) : 29) + (++index) * 10, 160 diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java index c52f8968..0d2d863d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java @@ -54,9 +54,9 @@ public class AuctionBINWarning extends GuiElement { private boolean showWarning = false; private List sellingTooltip; private String sellingName; - private int sellingPrice; - private int lowestPrice; - private int buyPercentage; + private long sellingPrice; + private long lowestPrice; + private long buyPercentage; private int sellStackAmount; private boolean isALoss = true; @@ -96,7 +96,7 @@ public class AuctionBINWarning extends GuiElement { if (priceMatcher.matches()) { try { - sellingPrice = Integer.parseInt(priceMatcher.group(1).replace(",", "")); + sellingPrice = Long.parseLong(priceMatcher.group(1).replace(",", "")); } catch (NumberFormatException ignored) { } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java index c8fd0fde..513252dc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java @@ -838,7 +838,7 @@ public class AccessoryBagOverlay { private static Comparator getItemComparator() { return (o1, o2) -> { - float cost1; + double cost1; JsonObject o1Auc = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o1); if (o1Auc != null && o1Auc.has("price")) { cost1 = o1Auc.get("price").getAsFloat(); @@ -849,7 +849,7 @@ public class AccessoryBagOverlay { else cost1 = 0; } - float cost2; + double cost2; JsonObject o2Auc = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o2); if (o2Auc != null && o2Auc.has("price")) { cost2 = o2Auc.get("price").getAsFloat(); 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; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java index 7ed3a799..4797254d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java @@ -562,11 +562,11 @@ public class ProfileViewer { JsonObject bzInfo = manager.auctionManager.getBazaarInfo(internalname); - int auctionPrice; + long auctionPrice; if (bzInfo != null && bzInfo.has("curr_sell")) { auctionPrice = (int) bzInfo.get("curr_sell").getAsFloat(); } else { - auctionPrice = (int) manager.auctionManager.getItemAvgBin(internalname); + auctionPrice = (long) manager.auctionManager.getItemAvgBin(internalname); if (auctionPrice <= 0) { auctionPrice = manager.auctionManager.getLowestBin(internalname); } @@ -590,11 +590,11 @@ public class ProfileViewer { JsonObject bzInfo2 = manager.auctionManager.getBazaarInfo(internalname2); - int auctionPrice2; + long auctionPrice2; if (bzInfo2 != null && bzInfo2.has("curr_sell")) { auctionPrice2 = (int) bzInfo2.get("curr_sell").getAsFloat(); } else { - auctionPrice2 = (int) manager.auctionManager.getItemAvgBin(internalname2); + auctionPrice2 = (long) manager.auctionManager.getItemAvgBin(internalname2); if (auctionPrice2 <= 0) { auctionPrice2 = manager.auctionManager.getLowestBin(internalname2); } -- cgit