From 45fa1f8859a39583d0c1edc6e1e9e13f6b00c179 Mon Sep 17 00:00:00 2001 From: nmccullagh Date: Mon, 17 Jun 2024 01:32:48 +0100 Subject: [PATCH 1/9] Add Craft Cost Tooltip --- .../config/categories/GeneralCategory.java | 7 ++ .../config/configs/GeneralConfig.java | 3 + .../item/tooltip/TooltipInfoType.java | 2 +- .../skyblock/item/tooltip/TooltipManager.java | 14 ++-- .../tooltip/adders/CraftPriceTooltip.java | 70 +++++++++++++++++++ .../assets/skyblocker/lang/en_us.json | 1 + 6 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index fa87be3d48..d43fe24f93 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -155,6 +155,13 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.general.itemTooltip.enableBazaarPrice = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.general.itemTooltip.enableCraftingCost")) + .binding(defaults.general.itemTooltip.enableCraftingCost, + () -> config.general.itemTooltip.enableCraftingCost, + newValue -> config.general.itemTooltip.enableCraftingCost = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.general.itemTooltip.enableObtainedDate")) .binding(defaults.general.itemTooltip.enableObtainedDate, diff --git a/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java index 9f612028a6..ae891b7064 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java @@ -114,6 +114,9 @@ public static class ItemTooltip { @SerialEntry public boolean enableBazaarPrice = true; + @SerialEntry + public boolean enableCraftingCost = false; + @SerialEntry public boolean enableObtainedDate = true; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java index d82b26825e..1e3b5a7f59 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java @@ -22,7 +22,7 @@ public enum TooltipInfoType implements Runnable { NPC("https://hysky.de/api/npcprice", itemTooltip -> itemTooltip.enableNPCPrice, true), - BAZAAR("https://hysky.de/api/bazaar", itemTooltip -> itemTooltip.enableBazaarPrice || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.enableProfitCalculator || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.croesusProfit || SkyblockerConfigManager.get().uiAndVisuals.chestValue.enableChestValue, itemTooltip -> itemTooltip.enableBazaarPrice, false), + BAZAAR("https://hysky.de/api/bazaar", itemTooltip -> itemTooltip.enableBazaarPrice || itemTooltip.enableCraftingCost || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.enableProfitCalculator || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.croesusProfit || SkyblockerConfigManager.get().uiAndVisuals.chestValue.enableChestValue, itemTooltip -> itemTooltip.enableBazaarPrice, false), LOWEST_BINS("https://hysky.de/api/auctions/lowestbins", itemTooltip -> itemTooltip.enableLowestBIN || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.enableProfitCalculator || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.croesusProfit || SkyblockerConfigManager.get().uiAndVisuals.chestValue.enableChestValue, itemTooltip -> itemTooltip.enableLowestBIN, false), ONE_DAY_AVERAGE("https://hysky.de/api/auctions/lowestbins/average/1day.json", itemTooltip -> itemTooltip.enableAvgBIN, false), THREE_DAY_AVERAGE("https://hysky.de/api/auctions/lowestbins/average/3day.json", itemTooltip -> itemTooltip.enableAvgBIN || SkyblockerConfigManager.get().uiAndVisuals.searchOverlay.enableAuctionHouse, itemTooltip -> itemTooltip.enableAvgBIN, false), diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipManager.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipManager.java index e3a2ef04ec..cb8efb0caf 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipManager.java @@ -3,6 +3,7 @@ import de.hysky.skyblocker.mixins.accessors.HandledScreenAccessor; import de.hysky.skyblocker.skyblock.chocolatefactory.ChocolateFactorySolver; import de.hysky.skyblocker.skyblock.item.tooltip.adders.*; +import de.hysky.skyblocker.skyblock.item.tooltip.adders.CraftPriceTooltip; import de.hysky.skyblocker.utils.Utils; import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; @@ -27,12 +28,13 @@ public class TooltipManager { new BazaarPriceTooltip(2), new LBinTooltip(3), new AvgBinTooltip(4), - new DungeonQualityTooltip(5), - new MotesTooltip(6), - new ObtainedDateTooltip(7), - new MuseumTooltip(8), - new ColorTooltip(9), - new AccessoryTooltip(10), + new CraftPriceTooltip(5), + new DungeonQualityTooltip(6), + new MotesTooltip(7), + new ObtainedDateTooltip(8), + new MuseumTooltip(9), + new ColorTooltip(10), + new AccessoryTooltip(11), }; private static final ArrayList currentScreenAdders = new ArrayList<>(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java new file mode 100644 index 0000000000..849505a85a --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java @@ -0,0 +1,70 @@ +package de.hysky.skyblocker.skyblock.item.tooltip.adders; + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; +import de.hysky.skyblocker.skyblock.item.tooltip.TooltipAdder; +import de.hysky.skyblocker.skyblock.item.tooltip.TooltipInfoType; +import de.hysky.skyblocker.utils.NEURepoManager; +import io.github.moulberry.repo.data.NEUIngredient; +import io.github.moulberry.repo.data.NEUItem; +import io.github.moulberry.repo.data.NEURecipe; +import net.minecraft.item.ItemStack; +import net.minecraft.screen.slot.Slot; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.jetbrains.annotations.Nullable; + +import java.util.List; +import java.util.Map; + +public class CraftPriceTooltip extends TooltipAdder { + public CraftPriceTooltip(int priority) { + super(priority); + } + + @Override + public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List lines) { + if (!SkyblockerConfigManager.get().general.itemTooltip.enableCraftingCost) return; + + String neuName = stack.getNeuName(); + String internalID = stack.getSkyblockId(); + if (neuName == null || internalID == null) return; + + if (TooltipInfoType.ONE_DAY_AVERAGE.getData() == null || TooltipInfoType.BAZAAR.getData() == null) { + ItemTooltip.nullWarning(); + return; + } + + NEUItem neuItem = NEURepoManager.NEU_REPO.getItems().getItemBySkyblockId(internalID); + if (neuItem == null) return; + + List neuRecipes = neuItem.getRecipes(); + if (neuRecipes.isEmpty()) return; + + double totalCraftCost = 0.0; + + for (NEUIngredient input : neuRecipes.getFirst().getAllInputs()) { + String inputItemName = input.getItemId(); + double inputItemCount = input.getAmount(); + + double inputItemCost = getItemCost(inputItemName); + totalCraftCost += inputItemCost * inputItemCount; + } + + if (totalCraftCost == 0) return; + + lines.add(Text.literal(String.format("%-18s", "Crafting Cost:")) + .formatted(Formatting.GOLD) + .append(ItemTooltip.getCoinsMessage(totalCraftCost, 1))); + } + + private double getItemCost(String itemName) { + if (TooltipInfoType.BAZAAR.getData().has(itemName)) { + return TooltipInfoType.BAZAAR.getData().getAsJsonObject(itemName).get("sellPrice").getAsDouble(); + } else if (TooltipInfoType.LOWEST_BINS.getData().has(itemName)) { + return TooltipInfoType.LOWEST_BINS.getData().get(itemName).getAsDouble(); + } else { + return 0.0; // No data available + } + } +} diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index a73d523d1f..326be7bec5 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -237,6 +237,7 @@ "skyblocker.config.general.itemTooltip.enableAccessoriesHelper.@Tooltip[5]": "You don't own any accessory from this family.", "skyblocker.config.general.itemTooltip.enableAvgBIN": "Enable Avg. BIN Price", "skyblocker.config.general.itemTooltip.enableBazaarPrice": "Enable Bazaar buy/sell Price", + "skyblocker.config.general.itemTooltip.enableCraftingCost": "Enable Crafting Cost", "skyblocker.config.general.itemTooltip.enableExoticTooltip": "Enable Exotic Tooltip", "skyblocker.config.general.itemTooltip.enableExoticTooltip.@Tooltip": "Displays the type of exotic below the item's name if an armor piece is exotic.", "skyblocker.config.general.itemTooltip.enableLowestBIN": "Enable Lowest BIN Price", From 3187223676066b0a3b42b662ae10f2dc601a099f Mon Sep 17 00:00:00 2001 From: nmccullagh Date: Mon, 17 Jun 2024 21:28:54 +0100 Subject: [PATCH 2/9] recursion hurts my head --- .../tooltip/adders/CraftPriceTooltip.java | 61 +++++++++++++------ 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java index 849505a85a..8b06229ccd 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java @@ -16,8 +16,12 @@ import java.util.List; import java.util.Map; +import java.util.HashMap; public class CraftPriceTooltip extends TooltipAdder { + private final Map cachedCraftCosts = new HashMap<>(); + private static final int MAX_RECURSION_DEPTH = 10; + public CraftPriceTooltip(int priority) { super(priority); } @@ -30,7 +34,7 @@ public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List String internalID = stack.getSkyblockId(); if (neuName == null || internalID == null) return; - if (TooltipInfoType.ONE_DAY_AVERAGE.getData() == null || TooltipInfoType.BAZAAR.getData() == null) { + if (TooltipInfoType.LOWEST_BINS.getData() == null || TooltipInfoType.BAZAAR.getData() == null) { ItemTooltip.nullWarning(); return; } @@ -41,30 +45,51 @@ public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List List neuRecipes = neuItem.getRecipes(); if (neuRecipes.isEmpty()) return; - double totalCraftCost = 0.0; - - for (NEUIngredient input : neuRecipes.getFirst().getAllInputs()) { - String inputItemName = input.getItemId(); - double inputItemCount = input.getAmount(); - - double inputItemCost = getItemCost(inputItemName); - totalCraftCost += inputItemCost * inputItemCount; - } + double totalCraftCost = getItemCost(neuRecipes.getFirst(), 0); if (totalCraftCost == 0) return; lines.add(Text.literal(String.format("%-18s", "Crafting Cost:")) .formatted(Formatting.GOLD) - .append(ItemTooltip.getCoinsMessage(totalCraftCost, 1))); + .append(ItemTooltip.getCoinsMessage(totalCraftCost, stack.getCount()))); } - private double getItemCost(String itemName) { - if (TooltipInfoType.BAZAAR.getData().has(itemName)) { - return TooltipInfoType.BAZAAR.getData().getAsJsonObject(itemName).get("sellPrice").getAsDouble(); - } else if (TooltipInfoType.LOWEST_BINS.getData().has(itemName)) { - return TooltipInfoType.LOWEST_BINS.getData().get(itemName).getAsDouble(); - } else { - return 0.0; // No data available + private double getItemCost(NEURecipe recipe, int depth) { + if (depth >= MAX_RECURSION_DEPTH) return -1; + + double totalCraftCost = 0; + for (NEUIngredient input : recipe.getAllInputs()) { + String inputItemName = input.getItemId(); + double inputItemCount = input.getAmount(); + if (cachedCraftCosts.containsKey(inputItemName)) { + totalCraftCost += cachedCraftCosts.get(inputItemName) * inputItemCount; + continue; + } + + double itemCost = 0; + + if (TooltipInfoType.BAZAAR.getData().has(inputItemName)) { + itemCost = TooltipInfoType.BAZAAR.getData().getAsJsonObject(inputItemName).get("sellPrice").getAsDouble(); + } else if (TooltipInfoType.LOWEST_BINS.getData().has(inputItemName)) { + itemCost = TooltipInfoType.LOWEST_BINS.getData().get(inputItemName).getAsDouble(); + } + + if (itemCost > 0) { + cachedCraftCosts.put(inputItemName, itemCost); + } + + NEUItem neuItem = NEURepoManager.NEU_REPO.getItems().getItemBySkyblockId(inputItemName); + if (neuItem != null) { + List neuRecipes = neuItem.getRecipes(); + if (!neuRecipes.isEmpty()) { + double craftCost = getItemCost(neuRecipes.getFirst(), depth + 1); + if (craftCost != -1) itemCost = Math.min(itemCost, craftCost); + cachedCraftCosts.put(inputItemName, itemCost); + } + } + + totalCraftCost += itemCost * inputItemCount; } + return totalCraftCost; } } From 77fbbf665c93c1c5be2aed9b195e335d1eade6d9 Mon Sep 17 00:00:00 2001 From: nmccullagh Date: Wed, 26 Jun 2024 06:23:31 +0100 Subject: [PATCH 3/9] add max recursion. Probs shoulda done this anyway. Also stops NEU Recipes that arent recipes from blowing up the game --- .../skyblock/item/tooltip/adders/CraftPriceTooltip.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java index 8b06229ccd..32279aa7ff 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java @@ -20,7 +20,7 @@ public class CraftPriceTooltip extends TooltipAdder { private final Map cachedCraftCosts = new HashMap<>(); - private static final int MAX_RECURSION_DEPTH = 10; + private static final int MAX_RECURSION_DEPTH = 15; public CraftPriceTooltip(int priority) { super(priority); From 8f11e44052ff41df1477d8c10de3bc1129252ec1 Mon Sep 17 00:00:00 2001 From: nmccullagh Date: Mon, 1 Jul 2024 01:18:34 +0100 Subject: [PATCH 4/9] lets not assume 1 output --- .../config/categories/GeneralCategory.java | 6 +++--- .../config/configs/GeneralConfig.java | 19 ++++++++++++++++++- .../item/tooltip/TooltipInfoType.java | 2 +- .../tooltip/adders/CraftPriceTooltip.java | 19 ++++++++++--------- .../assets/skyblocker/lang/en_us.json | 7 ++++++- 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index d43fe24f93..3f2ddc9be3 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -155,12 +155,12 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.general.itemTooltip.enableBazaarPrice = newValue) .controller(ConfigUtils::createBooleanController) .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.general.itemTooltip.enableCraftingCost")) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.general.itemTooltip.craft")) .binding(defaults.general.itemTooltip.enableCraftingCost, () -> config.general.itemTooltip.enableCraftingCost, newValue -> config.general.itemTooltip.enableCraftingCost = newValue) - .controller(ConfigUtils::createBooleanController) + .controller(ConfigUtils::createEnumCyclingListController) .build()) .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.general.itemTooltip.enableObtainedDate")) diff --git a/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java index ae891b7064..754e15f152 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java @@ -115,7 +115,7 @@ public static class ItemTooltip { public boolean enableBazaarPrice = true; @SerialEntry - public boolean enableCraftingCost = false; + public Craft enableCraftingCost = Craft.OFF; @SerialEntry public boolean enableObtainedDate = true; @@ -142,6 +142,23 @@ public String toString() { } } + public enum Craft { + SELL_ORDER, BUY_ORDER, OFF; + + @Override + public String toString() { + return I18n.translate("skyblocker.config.general.itemTooltip.craft." + name()); + } + + public String getOrder() { + return switch (this) { + case SELL_ORDER -> "sellPrice"; + case BUY_ORDER -> "buyPrice"; + case OFF -> null; + }; + } + } + public static class ItemInfoDisplay { @SerialEntry public boolean slotText = true; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java index 1e3b5a7f59..dfb97bee27 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java @@ -22,7 +22,7 @@ public enum TooltipInfoType implements Runnable { NPC("https://hysky.de/api/npcprice", itemTooltip -> itemTooltip.enableNPCPrice, true), - BAZAAR("https://hysky.de/api/bazaar", itemTooltip -> itemTooltip.enableBazaarPrice || itemTooltip.enableCraftingCost || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.enableProfitCalculator || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.croesusProfit || SkyblockerConfigManager.get().uiAndVisuals.chestValue.enableChestValue, itemTooltip -> itemTooltip.enableBazaarPrice, false), + BAZAAR("https://hysky.de/api/bazaar", itemTooltip -> itemTooltip.enableBazaarPrice || itemTooltip.enableCraftingCost.getOrder() != null || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.enableProfitCalculator || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.croesusProfit || SkyblockerConfigManager.get().uiAndVisuals.chestValue.enableChestValue, itemTooltip -> itemTooltip.enableBazaarPrice, false), LOWEST_BINS("https://hysky.de/api/auctions/lowestbins", itemTooltip -> itemTooltip.enableLowestBIN || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.enableProfitCalculator || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.croesusProfit || SkyblockerConfigManager.get().uiAndVisuals.chestValue.enableChestValue, itemTooltip -> itemTooltip.enableLowestBIN, false), ONE_DAY_AVERAGE("https://hysky.de/api/auctions/lowestbins/average/1day.json", itemTooltip -> itemTooltip.enableAvgBIN, false), THREE_DAY_AVERAGE("https://hysky.de/api/auctions/lowestbins/average/3day.json", itemTooltip -> itemTooltip.enableAvgBIN || SkyblockerConfigManager.get().uiAndVisuals.searchOverlay.enableAuctionHouse, itemTooltip -> itemTooltip.enableAvgBIN, false), diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java index 32279aa7ff..35c717ff4e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java @@ -1,6 +1,7 @@ package de.hysky.skyblocker.skyblock.item.tooltip.adders; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.config.configs.GeneralConfig; import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; import de.hysky.skyblocker.skyblock.item.tooltip.TooltipAdder; import de.hysky.skyblocker.skyblock.item.tooltip.TooltipInfoType; @@ -14,9 +15,9 @@ import net.minecraft.util.Formatting; import org.jetbrains.annotations.Nullable; +import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.HashMap; public class CraftPriceTooltip extends TooltipAdder { private final Map cachedCraftCosts = new HashMap<>(); @@ -28,11 +29,10 @@ public CraftPriceTooltip(int priority) { @Override public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List lines) { - if (!SkyblockerConfigManager.get().general.itemTooltip.enableCraftingCost) return; + if (SkyblockerConfigManager.get().general.itemTooltip.enableCraftingCost == GeneralConfig.Craft.OFF) return; - String neuName = stack.getNeuName(); String internalID = stack.getSkyblockId(); - if (neuName == null || internalID == null) return; + if (stack.getNeuName() == null || internalID == null) return; if (TooltipInfoType.LOWEST_BINS.getData() == null || TooltipInfoType.BAZAAR.getData() == null) { ItemTooltip.nullWarning(); @@ -43,15 +43,16 @@ public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List if (neuItem == null) return; List neuRecipes = neuItem.getRecipes(); - if (neuRecipes.isEmpty()) return; + if (neuRecipes.isEmpty() || neuRecipes.getFirst().getClass().equals(io.github.moulberry.repo.data.NEUKatUpgradeRecipe.class)) return; double totalCraftCost = getItemCost(neuRecipes.getFirst(), 0); + cachedCraftCosts.clear(); if (totalCraftCost == 0) return; - lines.add(Text.literal(String.format("%-18s", "Crafting Cost:")) - .formatted(Formatting.GOLD) - .append(ItemTooltip.getCoinsMessage(totalCraftCost, stack.getCount()))); + neuRecipes.getFirst().getAllOutputs().stream().findFirst().ifPresent(neuIngredient -> + lines.add(Text.literal(String.format("%-20s", "Crafting Price:")).formatted(Formatting.GOLD) + .append(ItemTooltip.getCoinsMessage(totalCraftCost / neuIngredient.getAmount(), stack.getCount())))); } private double getItemCost(NEURecipe recipe, int depth) { @@ -69,7 +70,7 @@ private double getItemCost(NEURecipe recipe, int depth) { double itemCost = 0; if (TooltipInfoType.BAZAAR.getData().has(inputItemName)) { - itemCost = TooltipInfoType.BAZAAR.getData().getAsJsonObject(inputItemName).get("sellPrice").getAsDouble(); + itemCost = TooltipInfoType.BAZAAR.getData().getAsJsonObject(inputItemName).get(SkyblockerConfigManager.get().general.itemTooltip.enableCraftingCost.getOrder()).getAsDouble(); } else if (TooltipInfoType.LOWEST_BINS.getData().has(inputItemName)) { itemCost = TooltipInfoType.LOWEST_BINS.getData().get(inputItemName).getAsDouble(); } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 326be7bec5..216a6e85fb 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -226,6 +226,7 @@ "skyblocker.config.general.itemTooltip.avg.BOTH": "Both", "skyblocker.config.general.itemTooltip.avg.ONE_DAY": "1 day price", "skyblocker.config.general.itemTooltip.avg.THREE_DAY": "3 day price", + "skyblocker.config.general.itemTooltip.avg": "Average Type", "skyblocker.config.general.itemTooltip.dungeonQuality": "Dungeon Quality", "skyblocker.config.general.itemTooltip.dungeonQuality.@Tooltip": "Displays quality and tier of dungeon drops from mobs.\n\n\nReminder:\nTier 1-3 dropped from F1-F3\nTier 4-7 dropped from F4-F7 or M1-M4\nTier 8-10 are dropped only from M5-M7", "skyblocker.config.general.itemTooltip.enableAccessoriesHelper": "Enable Accessories Helper", @@ -237,7 +238,11 @@ "skyblocker.config.general.itemTooltip.enableAccessoriesHelper.@Tooltip[5]": "You don't own any accessory from this family.", "skyblocker.config.general.itemTooltip.enableAvgBIN": "Enable Avg. BIN Price", "skyblocker.config.general.itemTooltip.enableBazaarPrice": "Enable Bazaar buy/sell Price", - "skyblocker.config.general.itemTooltip.enableCraftingCost": "Enable Crafting Cost", + "skyblocker.config.general.itemTooltip.craft": "Crafting Cost", + "skyblocker.config.general.itemTooltip.craft.@Tooltip": "You can choose which Bazaar order type to use in crafting calculation", + "skyblocker.config.general.itemTooltip.craft.OFF": "Off", + "skyblocker.config.general.itemTooltip.craft.SELL_ORDER": "Sell Order", + "skyblocker.config.general.itemTooltip.craft.BUY_ORDER": "Buy Order", "skyblocker.config.general.itemTooltip.enableExoticTooltip": "Enable Exotic Tooltip", "skyblocker.config.general.itemTooltip.enableExoticTooltip.@Tooltip": "Displays the type of exotic below the item's name if an armor piece is exotic.", "skyblocker.config.general.itemTooltip.enableLowestBIN": "Enable Lowest BIN Price", From 69b7c0a00a6d236953604415556d7d4a729b7228 Mon Sep 17 00:00:00 2001 From: nmccullagh Date: Fri, 5 Jul 2024 13:07:33 +0100 Subject: [PATCH 5/9] add a 30s persistent cache --- src/main/java/de/hysky/skyblocker/SkyblockerMod.java | 2 ++ .../item/tooltip/adders/CraftPriceTooltip.java | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index d793e73d33..8187c12294 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -35,6 +35,7 @@ import de.hysky.skyblocker.skyblock.item.tooltip.BackpackPreview; import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; import de.hysky.skyblocker.skyblock.item.tooltip.TooltipManager; +import de.hysky.skyblocker.skyblock.item.tooltip.adders.CraftPriceTooltip; import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; import de.hysky.skyblocker.skyblock.rift.TheRift; import de.hysky.skyblocker.skyblock.searchoverlay.SearchOverManager; @@ -200,6 +201,7 @@ public void onInitializeClient() { Scheduler.INSTANCE.scheduleCyclic(DwarvenHud::update, 40); Scheduler.INSTANCE.scheduleCyclic(CrystalsHud::update, 40); Scheduler.INSTANCE.scheduleCyclic(PlayerListMgr::updateList, 20); + Scheduler.INSTANCE.scheduleCyclic(CraftPriceTooltip::clearCache, 600); } /** diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java index 35c717ff4e..c19c2f5388 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java @@ -18,9 +18,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; public class CraftPriceTooltip extends TooltipAdder { - private final Map cachedCraftCosts = new HashMap<>(); + private final static Map cachedCraftCosts = new ConcurrentHashMap<>(); private static final int MAX_RECURSION_DEPTH = 15; public CraftPriceTooltip(int priority) { @@ -28,7 +29,7 @@ public CraftPriceTooltip(int priority) { } @Override - public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List lines) { + public void addToTooltip(@Nullable Slot focusedSloFt, ItemStack stack, List lines) { if (SkyblockerConfigManager.get().general.itemTooltip.enableCraftingCost == GeneralConfig.Craft.OFF) return; String internalID = stack.getSkyblockId(); @@ -46,7 +47,6 @@ public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List if (neuRecipes.isEmpty() || neuRecipes.getFirst().getClass().equals(io.github.moulberry.repo.data.NEUKatUpgradeRecipe.class)) return; double totalCraftCost = getItemCost(neuRecipes.getFirst(), 0); - cachedCraftCosts.clear(); if (totalCraftCost == 0) return; @@ -93,4 +93,8 @@ private double getItemCost(NEURecipe recipe, int depth) { } return totalCraftCost; } + + public static void clearCache() { + cachedCraftCosts.clear(); + } } From bcfe90d6d22d7dac119e28d77c8e5b27fc1c7a1a Mon Sep 17 00:00:00 2001 From: nmccullagh Date: Fri, 5 Jul 2024 13:48:27 +0100 Subject: [PATCH 6/9] schedule cache invalidation with price updates, and with config changes --- src/main/java/de/hysky/skyblocker/SkyblockerMod.java | 2 -- .../skyblocker/config/categories/GeneralCategory.java | 2 ++ .../skyblocker/skyblock/item/tooltip/ItemTooltip.java | 3 +++ .../skyblock/item/tooltip/TooltipInfoType.java | 10 ++-------- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 8187c12294..d793e73d33 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -35,7 +35,6 @@ import de.hysky.skyblocker.skyblock.item.tooltip.BackpackPreview; import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; import de.hysky.skyblocker.skyblock.item.tooltip.TooltipManager; -import de.hysky.skyblocker.skyblock.item.tooltip.adders.CraftPriceTooltip; import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; import de.hysky.skyblocker.skyblock.rift.TheRift; import de.hysky.skyblocker.skyblock.searchoverlay.SearchOverManager; @@ -201,7 +200,6 @@ public void onInitializeClient() { Scheduler.INSTANCE.scheduleCyclic(DwarvenHud::update, 40); Scheduler.INSTANCE.scheduleCyclic(CrystalsHud::update, 40); Scheduler.INSTANCE.scheduleCyclic(PlayerListMgr::updateList, 20); - Scheduler.INSTANCE.scheduleCyclic(CraftPriceTooltip::clearCache, 600); } /** diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index 3f2ddc9be3..514b4d43b6 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -3,6 +3,7 @@ import de.hysky.skyblocker.config.ConfigUtils; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.configs.GeneralConfig; +import de.hysky.skyblocker.skyblock.item.tooltip.adders.CraftPriceTooltip; import de.hysky.skyblocker.skyblock.shortcut.ShortcutsConfigScreen; import dev.isxander.yacl3.api.*; import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder; @@ -160,6 +161,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.itemTooltip.enableCraftingCost, () -> config.general.itemTooltip.enableCraftingCost, newValue -> config.general.itemTooltip.enableCraftingCost = newValue) + .listener((Option craft, GeneralConfig.Craft newCraft) -> CraftPriceTooltip.clearCache()) .controller(ConfigUtils::createEnumCyclingListController) .build()) .option(Option.createBuilder() diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java index cc3d20994d..97a73a8072 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java @@ -2,6 +2,7 @@ import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.config.configs.GeneralConfig; +import de.hysky.skyblocker.skyblock.item.tooltip.adders.CraftPriceTooltip; import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.scheduler.Scheduler; @@ -128,6 +129,8 @@ public static void init() { LOGGER.error("Encountered unknown error while downloading tooltip data", e); return null; }); + + CraftPriceTooltip.clearCache(); }, 1200, true); } } \ No newline at end of file diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java index dfb97bee27..92adf49dce 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java @@ -1,29 +1,23 @@ package de.hysky.skyblocker.skyblock.item.tooltip; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.google.gson.stream.JsonReader; import de.hysky.skyblocker.SkyblockerMod; -import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.config.configs.GeneralConfig; import de.hysky.skyblocker.utils.Http; import de.hysky.skyblocker.utils.Utils; +import org.jetbrains.annotations.Nullable; -import java.io.StringReader; import java.net.http.HttpHeaders; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.function.Predicate; -import org.jetbrains.annotations.Nullable; - public enum TooltipInfoType implements Runnable { NPC("https://hysky.de/api/npcprice", itemTooltip -> itemTooltip.enableNPCPrice, true), BAZAAR("https://hysky.de/api/bazaar", itemTooltip -> itemTooltip.enableBazaarPrice || itemTooltip.enableCraftingCost.getOrder() != null || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.enableProfitCalculator || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.croesusProfit || SkyblockerConfigManager.get().uiAndVisuals.chestValue.enableChestValue, itemTooltip -> itemTooltip.enableBazaarPrice, false), - LOWEST_BINS("https://hysky.de/api/auctions/lowestbins", itemTooltip -> itemTooltip.enableLowestBIN || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.enableProfitCalculator || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.croesusProfit || SkyblockerConfigManager.get().uiAndVisuals.chestValue.enableChestValue, itemTooltip -> itemTooltip.enableLowestBIN, false), + LOWEST_BINS("https://hysky.de/api/auctions/lowestbins", itemTooltip -> itemTooltip.enableLowestBIN || itemTooltip.enableCraftingCost.getOrder() != null || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.enableProfitCalculator || SkyblockerConfigManager.get().dungeons.dungeonChestProfit.croesusProfit || SkyblockerConfigManager.get().uiAndVisuals.chestValue.enableChestValue, itemTooltip -> itemTooltip.enableLowestBIN, false), ONE_DAY_AVERAGE("https://hysky.de/api/auctions/lowestbins/average/1day.json", itemTooltip -> itemTooltip.enableAvgBIN, false), THREE_DAY_AVERAGE("https://hysky.de/api/auctions/lowestbins/average/3day.json", itemTooltip -> itemTooltip.enableAvgBIN || SkyblockerConfigManager.get().uiAndVisuals.searchOverlay.enableAuctionHouse, itemTooltip -> itemTooltip.enableAvgBIN, false), MOTES("https://hysky.de/api/motesprice", itemTooltip -> itemTooltip.enableMotesPrice, itemTooltip -> itemTooltip.enableMotesPrice && Utils.isInTheRift(), true), From b22cf286d971af6e2c27f4dfcbe6e1829935a5b7 Mon Sep 17 00:00:00 2001 From: nmccullagh Date: Fri, 5 Jul 2024 14:41:37 +0100 Subject: [PATCH 7/9] add exception handling for null cases --- .../item/tooltip/adders/CraftPriceTooltip.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java index c19c2f5388..f36254f3bf 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java @@ -14,6 +14,8 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.HashMap; import java.util.List; @@ -21,6 +23,7 @@ import java.util.concurrent.ConcurrentHashMap; public class CraftPriceTooltip extends TooltipAdder { + protected static final Logger LOGGER = LoggerFactory.getLogger(CraftPriceTooltip.class.getName()); private final static Map cachedCraftCosts = new ConcurrentHashMap<>(); private static final int MAX_RECURSION_DEPTH = 15; @@ -46,13 +49,18 @@ public void addToTooltip(@Nullable Slot focusedSloFt, ItemStack stack, List neuRecipes = neuItem.getRecipes(); if (neuRecipes.isEmpty() || neuRecipes.getFirst().getClass().equals(io.github.moulberry.repo.data.NEUKatUpgradeRecipe.class)) return; - double totalCraftCost = getItemCost(neuRecipes.getFirst(), 0); + try { + double totalCraftCost = getItemCost(neuRecipes.getFirst(), 0); - if (totalCraftCost == 0) return; + if (totalCraftCost == 0) return; - neuRecipes.getFirst().getAllOutputs().stream().findFirst().ifPresent(neuIngredient -> - lines.add(Text.literal(String.format("%-20s", "Crafting Price:")).formatted(Formatting.GOLD) - .append(ItemTooltip.getCoinsMessage(totalCraftCost / neuIngredient.getAmount(), stack.getCount())))); + neuRecipes.getFirst().getAllOutputs().stream().findFirst().ifPresent(neuIngredient -> + lines.add(Text.literal(String.format("%-20s", "Crafting Price:")).formatted(Formatting.GOLD) + .append(ItemTooltip.getCoinsMessage(totalCraftCost / neuIngredient.getAmount(), stack.getCount())))); + + } catch (Exception e) { + LOGGER.error("[Skyblocker Craft Price] Error calculating craftprice tooltip for: " + internalID, e); + } } private double getItemCost(NEURecipe recipe, int depth) { From fb16a9bebc82698c5149a11426cace87edd5a627 Mon Sep 17 00:00:00 2001 From: nmccullagh Date: Sat, 6 Jul 2024 11:34:36 +0100 Subject: [PATCH 8/9] feedback2 --- .../skyblocker/config/categories/GeneralCategory.java | 2 +- .../skyblock/item/tooltip/adders/CraftPriceTooltip.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index 514b4d43b6..279b7f6a35 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -161,7 +161,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.itemTooltip.enableCraftingCost, () -> config.general.itemTooltip.enableCraftingCost, newValue -> config.general.itemTooltip.enableCraftingCost = newValue) - .listener((Option craft, GeneralConfig.Craft newCraft) -> CraftPriceTooltip.clearCache()) + .listener((Option ignored, GeneralConfig.Craft ignored2) -> CraftPriceTooltip.clearCache()) .controller(ConfigUtils::createEnumCyclingListController) .build()) .option(Option.createBuilder() diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java index f36254f3bf..32c36c9a1c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java @@ -24,7 +24,7 @@ public class CraftPriceTooltip extends TooltipAdder { protected static final Logger LOGGER = LoggerFactory.getLogger(CraftPriceTooltip.class.getName()); - private final static Map cachedCraftCosts = new ConcurrentHashMap<>(); + private static final Map cachedCraftCosts = new ConcurrentHashMap<>(); private static final int MAX_RECURSION_DEPTH = 15; public CraftPriceTooltip(int priority) { @@ -47,16 +47,16 @@ public void addToTooltip(@Nullable Slot focusedSloFt, ItemStack stack, List neuRecipes = neuItem.getRecipes(); - if (neuRecipes.isEmpty() || neuRecipes.getFirst().getClass().equals(io.github.moulberry.repo.data.NEUKatUpgradeRecipe.class)) return; + if (neuRecipes.isEmpty() || neuRecipes.getFirst() instanceof io.github.moulberry.repo.data.NEUKatUpgradeRecipe) return; try { double totalCraftCost = getItemCost(neuRecipes.getFirst(), 0); if (totalCraftCost == 0) return; - neuRecipes.getFirst().getAllOutputs().stream().findFirst().ifPresent(neuIngredient -> + neuRecipes.getFirst().getAllOutputs().stream().findFirst().ifPresent(outputIngredient -> lines.add(Text.literal(String.format("%-20s", "Crafting Price:")).formatted(Formatting.GOLD) - .append(ItemTooltip.getCoinsMessage(totalCraftCost / neuIngredient.getAmount(), stack.getCount())))); + .append(ItemTooltip.getCoinsMessage(totalCraftCost / outputIngredient.getAmount(), stack.getCount())))); } catch (Exception e) { LOGGER.error("[Skyblocker Craft Price] Error calculating craftprice tooltip for: " + internalID, e); From a8de449aad9cb82e2fd936d9e2a60858947db99c Mon Sep 17 00:00:00 2001 From: nmccullagh Date: Sat, 6 Jul 2024 12:46:28 +0100 Subject: [PATCH 9/9] Better sack support ig --- .../skyblock/item/tooltip/adders/CraftPriceTooltip.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java index 32c36c9a1c..f7af446eb0 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/CraftPriceTooltip.java @@ -13,6 +13,7 @@ import net.minecraft.screen.slot.Slot; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import org.apache.commons.lang3.math.NumberUtils; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,9 +55,15 @@ public void addToTooltip(@Nullable Slot focusedSloFt, ItemStack stack, List lines.add(Text.literal(String.format("%-20s", "Crafting Price:")).formatted(Formatting.GOLD) - .append(ItemTooltip.getCoinsMessage(totalCraftCost / outputIngredient.getAmount(), stack.getCount())))); + .append(ItemTooltip.getCoinsMessage(totalCraftCost / outputIngredient.getAmount(), amountInStack)))); } catch (Exception e) { LOGGER.error("[Skyblocker Craft Price] Error calculating craftprice tooltip for: " + internalID, e);