From dffba2bb9abeb84e50816b69ea6f878ba9fc3d3f Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Sat, 24 Feb 2024 16:34:05 +0100 Subject: Fixed Book Bundle showing wrong amount of books. #1043 --- .../hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.java | 3 +++ .../skyhanni/features/misc/items/EstimatedItemValue.kt | 12 ++++++++++-- .../features/misc/items/EstimatedItemValueCalculator.kt | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.java index 87b5e4e00..ddd814159 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.java +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.java @@ -18,4 +18,7 @@ public class ItemsJson { @Expose public List water_fishing_rods; + + @Expose + public Map book_bundle_amount; } 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 aef1f392b..5ede5acf7 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 @@ -3,11 +3,13 @@ package at.hannibal2.skyhanni.features.misc.items import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemsJson import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.RenderItemTooltipEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle @@ -25,7 +27,6 @@ import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import com.google.gson.reflect.TypeToken -import io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer import net.minecraft.client.Minecraft import net.minecraft.init.Items @@ -41,12 +42,13 @@ object EstimatedItemValue { private val cache = mutableMapOf>>() private var lastToolTipTime = 0L var gemstoneUnlockCosts = HashMap>>() + var bookBundleAmount = mapOf() private var currentlyShowing = false fun isCurrentlyShowing() = currentlyShowing && Minecraft.getMinecraft().currentScreen != null @SubscribeEvent - fun onRepoReload(event: RepositoryReloadEvent) { + fun onRepoReload(event: io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent) { val data = manager.getJsonFromFile(File(manager.repoLocation, "constants/gemstonecosts.json")) if (data != null) @@ -60,6 +62,12 @@ object EstimatedItemValue { ChatUtils.error("Gemstone Slot Unlock Costs failed to load!") } + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + val data = event.getConstant("Items") + bookBundleAmount = data.book_bundle_amount ?: error("book_bundle_amount is missing") + } + @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { if (!LorenzUtils.inSkyBlock) return 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 8ea9195f8..87e582545 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 @@ -576,7 +576,7 @@ object EstimatedItemValueCalculator { level = 1 } if (internalName.startsWith("ENCHANTED_BOOK_BUNDLE_")) { - multiplier = 5 + multiplier = EstimatedItemValue.bookBundleAmount.getOrDefault(rawName, 5) } if (rawName in tieredEnchants) level = 1 -- cgit