aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-07-02 09:00:36 +0200
committerGitHub <noreply@github.com>2024-07-02 09:00:36 +0200
commit8d0758ecf3ccffef632a3d6e2c84fd705a0035b7 (patch)
tree0a533a927f1834ac23ada7dfe77a5d1dea9b2109 /src/main/java/at/hannibal2/skyhanni
parent30b08ee4185f6924857762f0ece55598a2a24bea (diff)
downloadskyhanni-8d0758ecf3ccffef632a3d6e2c84fd705a0035b7.tar.gz
skyhanni-8d0758ecf3ccffef632a3d6e2c84fd705a0035b7.tar.bz2
skyhanni-8d0758ecf3ccffef632a3d6e2c84fd705a0035b7.zip
Fix: Gillsplash in Estimated Item Value (#2173)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt21
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt5
6 files changed, 54 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java
index 9164aacc3..8b58e4919 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java
@@ -66,6 +66,11 @@ public class DebugConfig {
public boolean showNpcPrice = false;
@Expose
+ @ConfigOption(name = "Show Craft Price", desc = "Show craft price in item lore.")
+ @ConfigEditorBoolean
+ public boolean showCraftPrice = false;
+
+ @Expose
@ConfigOption(name = "Show BZ Price", desc = "Show BZ price in item lore.")
@ConfigEditorBoolean
public boolean showBZPrice = false;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt
index 741021d87..6b841f5a4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt
@@ -10,10 +10,10 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.itemName
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName
-import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.NEUItems.getPrice
import at.hannibal2.skyhanni.utils.NEUItems.isVanillaItem
@@ -26,7 +26,6 @@ import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe
-import io.github.moulberry.notenoughupdates.recipes.NeuRecipe
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.floor
@@ -85,7 +84,7 @@ object CraftableItemList {
pricePer: MutableMap<NEUInternalName, Double>,
internalName: NEUInternalName,
): Renderable? {
- val neededItems = neededItems(recipe)
+ val neededItems = ItemUtils.neededItems(recipe)
// Just a fail save, should not happen normally
if (neededItems.isEmpty()) return null
@@ -142,16 +141,6 @@ object CraftableItemList {
return canCraftTotal.min()
}
- private fun neededItems(recipe: NeuRecipe): MutableMap<NEUInternalName, Int> {
- val neededItems = mutableMapOf<NEUInternalName, Int>()
- for (ingredient in recipe.ingredients) {
- val material = ingredient.internalItemId.asInternalName()
- val amount = ingredient.count.toInt()
- neededItems.addOrPut(material, amount)
- }
- return neededItems
- }
-
private fun readItems(): Map<NEUInternalName, Long> {
val materials = mutableMapOf<NEUInternalName, Long>()
for (stack in InventoryUtils.getItemsInOwnInventory()) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt
index 05d53fa65..1d6b21d2e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt
@@ -16,8 +16,10 @@ import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
+import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull
import at.hannibal2.skyhanni.utils.NEUItems.getPrice
import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull
+import at.hannibal2.skyhanni.utils.NEUItems.getRawCraftCostOrNull
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAbilityScrolls
@@ -538,6 +540,17 @@ object EstimatedItemValueCalculator {
price = 0.0
}
+ // If craft cost price is greater than npc price, and there is no ah/bz price, use craft cost instead
+ internalName.getNpcPriceOrNull()?.let { npcPrice ->
+ if (price == npcPrice) {
+ internalName.getRawCraftCostOrNull()?.let { rawCraftPrice ->
+ if (rawCraftPrice > npcPrice) {
+ price = rawCraftPrice
+ }
+ }
+ }
+ }
+
val name = internalName.itemName
if (internalName.startsWith("ENCHANTED_BOOK_BUNDLE_")) {
list.add("§7Base item: $name")
diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
index e718593f3..2a5092f27 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
@@ -46,6 +46,7 @@ import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull
import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull
+import at.hannibal2.skyhanni.utils.NEUItems.getRawCraftCostOrNull
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible
@@ -469,6 +470,15 @@ object SkyHanniDebugsAndTests {
}
@SubscribeEvent
+ fun onSHowCraftPrice(event: LorenzToolTipEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (!debugConfig.showCraftPrice) return
+ val price = event.itemStack.getInternalNameOrNull()?.getRawCraftCostOrNull() ?: return
+
+ event.toolTip.add("§7Craft price: ${price.addSeparators()}")
+ }
+
+ @SubscribeEvent
fun onShowBzPrice(event: LorenzToolTipEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!debugConfig.showBZPrice) return
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index 67f2865eb..c094df489 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -2,8 +2,10 @@ package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.data.PetAPI
import at.hannibal2.skyhanni.test.command.ErrorManager
+import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
+import at.hannibal2.skyhanni.utils.NEUItems.getPrice
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matches
@@ -14,6 +16,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.StringUtils.removeResets
import com.google.gson.GsonBuilder
import com.google.gson.JsonObject
+import io.github.moulberry.notenoughupdates.recipes.NeuRecipe
import net.minecraft.client.Minecraft
import net.minecraft.init.Items
import net.minecraft.item.ItemStack
@@ -339,7 +342,7 @@ object ItemUtils {
"internal name" to pet.getInternalName(),
"item name" to name,
"rarity id" to rarityId,
- "inventory name" to InventoryUtils.openInventoryName()
+ "inventory name" to InventoryUtils.openInventoryName(),
)
}
return rarity
@@ -409,4 +412,20 @@ object ItemUtils {
}
return list
}
+
+ fun neededItems(recipe: NeuRecipe): Map<NEUInternalName, Int> {
+ val neededItems = mutableMapOf<NEUInternalName, Int>()
+ for (ingredient in recipe.ingredients) {
+ val material = ingredient.internalItemId.asInternalName()
+ val amount = ingredient.count.toInt()
+ neededItems.addOrPut(material, amount)
+ }
+ return neededItems
+ }
+
+ fun getRecipePrice(recipe: NeuRecipe): Double =
+ neededItems(recipe).map {
+ it.key.getPrice() * it.value
+ }.sum()
+
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index 4b334d027..75d394631 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -197,7 +197,10 @@ object NEUItems {
return getNpcPriceOrNull() ?: getRawCraftCostOrNull()
}
- fun NEUInternalName.getRawCraftCostOrNull(): Double? = manager.auctionManager.getCraftCost(asString())?.craftCost
+ // If NEU fails to calculate the craft costs, we calculate it ourself.
+ fun NEUInternalName.getRawCraftCostOrNull(): Double? = manager.auctionManager.getCraftCost(asString())?.craftCost ?: run {
+ getRecipes(this).map { ItemUtils.getRecipePrice(it) }.minOrNull()
+ }
fun NEUInternalName.getItemStackOrNull(): ItemStack? = ItemResolutionQuery(manager)
.withKnownInternalName(asString())