diff --git a/.idea/dictionaries/default_user.xml b/.idea/dictionaries/default_user.xml index eec6c321a802..c9692133b10d 100644 --- a/.idea/dictionaries/default_user.xml +++ b/.idea/dictionaries/default_user.xml @@ -210,6 +210,7 @@ ragnarock rclick recombobulated + recombobulation recombobulator redstone reindrake diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.kt index c70d0afa565e..da980522ff2f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data.jsonobjects.repo import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName import com.google.gson.annotations.Expose import com.google.gson.annotations.SerializedName @@ -11,4 +12,18 @@ data class ItemsJson( @Expose @SerializedName("lava_fishing_rods") val lavaFishingRods: List, @Expose @SerializedName("water_fishing_rods") val waterFishingRods: List, @Expose @SerializedName("book_bundle_amount") val bookBundleAmount: Map, + @Expose @SerializedName("value_calculation_data") val valueCalculationData: ItemValueCalculationDataJson, ) + +data class ItemValueCalculationDataJson( + @Expose @SerializedName("always_active_enchants") val alwaysActiveEnchants: Map, + @Expose @SerializedName("only_tier_one_prices") val onlyTierOnePrices: List, + @Expose @SerializedName("only_tier_five_prices") val onlyTierFivePrices: List, +) + +data class AlwaysActiveEnchantJson( + @Expose val level: Int, + @Expose val items: List, +) { + val internalNames = items.map { it.toInternalName() } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingReforge.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingReforge.kt index 75eccf4cc820..4feb8cf20d0a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingReforge.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingReforge.kt @@ -10,7 +10,7 @@ enum class FarmingReforge( val epic: Int, val legendary: Int, val mythic: Int, -) { // if reforge item is an empty string it means it will never be called, just for upgrading and recomb stats +) { // if reforge item is an empty string it means it will never be called, just for upgrading and recombobulating stats BLESSED("Blessed", "BLESSED_FRUIT", 5, 7, 9, 13, 16, 20), BOUNTIFUL("Bountiful", "GOLDEN_BALL", 1, 2, 3, 5, 7, 10), BLOOMING("Blooming", "FLOWERING_BOUQUET", 1, 2, 3, 4, 5, 6), diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt index 0baae0861fba..a7ced78fcff0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt @@ -20,7 +20,7 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull -import at.hannibal2.skyhanni.utils.ItemUtils.itemName +import at.hannibal2.skyhanni.utils.ItemUtils.itemNameFullyRarityAware import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addButton import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -121,12 +121,12 @@ object ChestValue { if (total < config.hideBelow) continue val textAmount = " §7x${amount.addSeparators()}:" val width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(textAmount) - val name = "${stack.itemName.reduceStringLength((config.nameLength - width), ' ')} $textAmount" + val name = "${stack.itemNameFullyRarityAware.reduceStringLength((config.nameLength - width), ' ')} $textAmount" val price = "§6${(total).formatPrice()}" val text = if (config.alignedDisplay) "$name $price" else - "${stack.itemName} §7x$amount: §6${total.formatPrice()}" + "${stack.itemNameFullyRarityAware} §7x$amount: §6${total.formatPrice()}" newDisplay.add( buildList { val renderable = Renderable.hoverTips( diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt index 20ae7c37a96e..6202c8b6fbee 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt @@ -49,6 +49,7 @@ object DiscordRPCManager : IPCListener { private var started = false private var nextUpdate: SimpleTimeMark = SimpleTimeMark.farPast() + // TODO move into item utils/api class var stackingEnchants: Map = emptyMap() fun start(fromCommand: Boolean = false) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt index c5bb3973b552..f372a22d6cda 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.misc.EstimatedItemValueConfig +import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemValueCalculationDataJson import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemsJson import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -49,6 +50,9 @@ object EstimatedItemValue { var bookBundleAmount = mapOf() private var currentlyShowing = false + lateinit var itemValueCalculationData: ItemValueCalculationDataJson + private set + fun isCurrentlyShowing() = currentlyShowing && Minecraft.getMinecraft().currentScreen != null @HandleEvent @@ -61,6 +65,7 @@ object EstimatedItemValue { fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("Items") bookBundleAmount = data.bookBundleAmount + itemValueCalculationData = data.valueCalculationData } @HandleEvent(onlyOnSkyblock = true) 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 9a7256d12039..abc782fb5430 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 @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc.items import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.ReforgeAPI +import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI.getKuudraTier import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI.isKuudraArmor @@ -23,6 +24,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.getReadableNBTDump import at.hannibal2.skyhanni.utils.ItemUtils.isRune import at.hannibal2.skyhanni.utils.ItemUtils.itemName +import at.hannibal2.skyhanni.utils.ItemUtils.itemNameBaseRarityAware import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzRarity @@ -120,18 +122,16 @@ object EstimatedItemValueCalculator { ::addEnchantments, ) - val farmingForDummies = "FARMING_FOR_DUMMIES".toInternalName() - val etherwarpConduit = "ETHERWARP_CONDUIT".toInternalName() - val etherwarpMerger = "ETHERWARP_MERGER".toInternalName() - val fumingPotatoBook = "FUMING_POTATO_BOOK".toInternalName() - val hotPotatoBook = "HOT_POTATO_BOOK".toInternalName() - val silex = "SIL_EX".toInternalName() - val transmissionTuner = "TRANSMISSION_TUNER".toInternalName() - val manaDisintegrator = "MANA_DISINTEGRATOR".toInternalName() + private val farmingForDummies = "FARMING_FOR_DUMMIES".toInternalName() + private val etherwarpConduit = "ETHERWARP_CONDUIT".toInternalName() + private val etherwarpMerger = "ETHERWARP_MERGER".toInternalName() + private val fumingPotatoBook = "FUMING_POTATO_BOOK".toInternalName() + private val hotPotatoBook = "HOT_POTATO_BOOK".toInternalName() + private val silex = "SIL_EX".toInternalName() + private val transmissionTuner = "TRANSMISSION_TUNER".toInternalName() + private val manaDisintegrator = "MANA_DISINTEGRATOR".toInternalName() - val kuudraUpgradeTiers = listOf("HOT_", "BURNING_", "FIERY_", "INFERNAL_") - - fun getTotalPrice(stack: ItemStack): Double = EstimatedItemValueCalculator.calculate(stack, mutableListOf()).first + fun getTotalPrice(stack: ItemStack): Double = calculate(stack, mutableListOf()).first fun calculate(stack: ItemStack, list: MutableList): Pair { val basePrice = addBaseItem(stack, list) @@ -700,7 +700,7 @@ object EstimatedItemValueCalculator { } } - val name = internalName.itemName + val name = stack.itemNameBaseRarityAware if (internalName.startsWith("ENCHANTED_BOOK_BUNDLE_")) { list.add("§7Base item: $name") return 0.0 @@ -710,52 +710,25 @@ object EstimatedItemValueCalculator { return price } - // TODO repo - private val hasAlwaysScavenger = listOf( - "CRYPT_DREADLORD_SWORD".toInternalName(), - "ZOMBIE_SOLDIER_CUTLASS".toInternalName(), - "CONJURING_SWORD".toInternalName(), - "EARTH_SHARD".toInternalName(), - "ZOMBIE_KNIGHT_SWORD".toInternalName(), - "SILENT_DEATH".toInternalName(), - "ZOMBIE_COMMANDER_WHIP".toInternalName(), - "ICE_SPRAY_WAND".toInternalName(), - ) - - private val hasAlwaysReplenish = listOf( - "ADVANCED_GARDENING_HOE".toInternalName(), - "ADVANCED_GARDENING_AXE".toInternalName(), - ) - private fun addEnchantments(stack: ItemStack, list: MutableList): Double { val enchantments = stack.getEnchantments() ?: return 0.0 var totalPrice = 0.0 val map = mutableMapOf() - // todo use repo - val tieredEnchants = listOf("compact", "cultivating", "champion", "expertise", "hecatomb", "toxophilite") - - @Suppress("PropertyWrapping") - val onlyTierOnePrices = listOf("ultimate_chimera", "ultimate_fatal_tempo", "smoldering", "ultimate_flash", "divine_gift") - val onlyTierFivePrices = listOf("ferocious_mana", "hardened_mana", "mana_vampire", "strong_mana") - val internalName = stack.getInternalName() for ((rawName, rawLevel) in enchantments) { // efficiency 1-5 is cheap, 6-10 is handled by silex if (rawName == "efficiency") continue - if (rawName == "scavenger" && rawLevel == 5 && internalName in hasAlwaysScavenger) { - continue - } - - if (rawName == "replenish" && rawLevel == 1 && internalName in hasAlwaysReplenish) { - continue + val isAlwaysActive = EstimatedItemValue.itemValueCalculationData.alwaysActiveEnchants.entries.any { + it.key == rawName && it.value.level == rawLevel && it.value.internalNames.contains(internalName) } + if (isAlwaysActive) continue var level = rawLevel var multiplier = 1 - if (rawName in onlyTierOnePrices) { + if (rawName in EstimatedItemValue.itemValueCalculationData.onlyTierOnePrices) { when (rawLevel) { 2 -> multiplier = 2 @@ -765,7 +738,7 @@ object EstimatedItemValueCalculator { } level = 1 } - if (rawName in onlyTierFivePrices) { + if (rawName in EstimatedItemValue.itemValueCalculationData.onlyTierFivePrices) { when (rawLevel) { 6 -> multiplier = 2 7 -> multiplier = 4 @@ -780,7 +753,7 @@ object EstimatedItemValueCalculator { if (internalName.startsWith("ENCHANTED_BOOK_BUNDLE_")) { multiplier = EstimatedItemValue.bookBundleAmount.getOrDefault(rawName, 5) } - if (rawName in tieredEnchants) level = 1 + if (rawName in DiscordRPCManager.stackingEnchants.keys) level = 1 val enchantmentName = "$rawName;$level".uppercase().toInternalName() val itemStack = enchantmentName.getItemStackOrNull() ?: continue diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 4bb28c0f2dd8..7baf524cc650 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.ItemPriceUtils.getPrice +import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull import at.hannibal2.skyhanni.utils.NumberUtil.formatInt @@ -344,6 +345,11 @@ object ItemUtils { return data.itemCategory } + fun ItemStack.getItemBaseRarityOrNull(): LorenzRarity? { + val rarity = getItemRarityOrNull() ?: return null + return if (isRecombobulated(this)) LorenzRarity.entries.firstOrNull { it.id == rarity.id - 1 } else rarity + } + fun ItemStack.getItemRarityOrNull(): LorenzRarity? { val data = cachedData if (itemRarityLastCheck(data)) { @@ -460,6 +466,28 @@ object ItemUtils { return getInternalNameOrNull()?.itemName ?: "" } + /** + * Returns the item name with its base color, i.e. before recombobulation + */ + val ItemStack.itemNameBaseRarityAware: String + get() { + return getRarityName(getItemBaseRarityOrNull()) + } + + /** + * Returns the item name with its full color, i.e. after recombobulation + */ + val ItemStack.itemNameFullyRarityAware: String + get() { + return getRarityName(getItemRarityOrNull()) + } + + private fun ItemStack.getRarityName(rarity: LorenzRarity?): String = + if (rarity == null) itemName + else if (itemName.startsWith("§")) { + itemName.replaceFirst(Regex("§[0-9a-f]"), rarity.color.getChatColor()) + } else itemName + fun ItemStack.getAttributeFromShard(): Pair? { if (getInternalName().asString() != "ATTRIBUTE_SHARD") return null val attributes = getAttributes() ?: return null