diff options
author | HiZe_ <superhize@hotmail.com> | 2023-10-26 12:29:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-26 12:29:43 +0200 |
commit | 2c061eb7fc7c6f8f4e5889504e6b390c71e6a269 (patch) | |
tree | 1191375f0e1a463e3f2d8ac82cbba3b67dfa8c85 /src/main | |
parent | d75c1ced1eb024cc216febd7676e851aa5d434a4 (diff) | |
download | skyhanni-2c061eb7fc7c6f8f4e5889504e6b390c71e6a269.tar.gz skyhanni-2c061eb7fc7c6f8f4e5889504e6b390c71e6a269.tar.bz2 skyhanni-2c061eb7fc7c6f8f4e5889504e6b390c71e6a269.zip |
Update: Sack display (#587)
highlight full sacks and price+amount of trophy sacks #587
Diffstat (limited to 'src/main')
3 files changed, 67 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java index 7025dc2e0..1f6494fd7 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java @@ -160,6 +160,11 @@ public class InventoryConfig { public boolean enabled = true; @Expose + @ConfigOption(name = "Highlight Full", desc = "Highlight items that are full in red.\n§eDo not need the option above to be enabled.") + @ConfigEditorBoolean + public boolean highlightFull = true; + + @Expose @ConfigOption(name = "Number Format", desc = "Either show Default, Formatted or Unformatted numbers.\n" + "§eDefault: §72,240/2.2k\n" + "§eFormatted: §72.2k/2.2k\n" + diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index 35e664cd7..7db58cd62 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -10,12 +10,14 @@ import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.getFillet import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity import at.hannibal2.skyhanni.features.inventory.SackDisplay import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy 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.getNpcPriceOrNull import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber @@ -153,15 +155,24 @@ object SackAPI { item.colorCode = group("color") item.stored = stored item.total = group("total") + if (savingSacks) setSackItem(item.internalName, item.stored.formatNumber()) - item.price = if (isTrophySack) { - val trophyName = - internalName.asString().lowercase().substringBeforeLast("_").replace("_", "") - val filletValue = - TrophyFishManager.getInfoByName(trophyName)?.getFilletValue(sackRarity!!) ?: 0 - val storedNumber = stored.formatNumber() - "MAGMA_FISH".asInternalName().sackPrice((filletValue * storedNumber).toString()) - } else internalName.sackPrice(stored).coerceAtLeast(0) + val price: Long + if (isTrophySack) { + val internal = stack.getInternalName_old() + val trophyFishName = internal.substringBeforeLast("_") + .replace("_", "").lowercase() + val trophyRarityName = internal.substringAfterLast("_") + val info = TrophyFishManager.getInfo(trophyFishName) + val rarity = TrophyRarity.getByName(trophyRarityName) ?: TrophyRarity.BRONZE + val filletValue = (info?.getFilletValue(rarity) ?: 0) * stored.toLong() + price = "MAGMA_FISH".asInternalName().sackPrice(filletValue.toString()) + item.magmaFish = filletValue.toString() + } else { + price = internalName.sackPrice(stored).coerceAtLeast(0) + } + item.price = price + if (isRuneSack) { val level = group("level") @@ -320,6 +331,7 @@ object SackAPI { var stored: String = "0", var total: String = "0", var price: Long = 0, + var magmaFish: String = "0", ) } @@ -331,6 +343,7 @@ data class SackItem( fun getStatus() = status ?: SackStatus.MISSING } + private val gemstoneMap = mapOf( "Jade Gemstones" to "ROUGH_JADE_GEM".asInternalName(), "Amber Gemstones" to "ROUGH_AMBER_GEM".asInternalName(), diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt index 0b8231879..11cddf73b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt @@ -2,17 +2,19 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.SackAPI +import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi -import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.addButton import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector -import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStack -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -32,6 +34,19 @@ object SackDisplay { } } + @SubscribeEvent + fun onRender(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!SackAPI.inSackInventory) return + if (!config.highlightFull) return + for (slot in InventoryUtils.getItemsInOpenChest()) { + val stack = slot.stack + val lore = stack.getLore() + if (lore.any { it.startsWith("§7Stored: §a")}) { + slot highlight LorenzColor.RED + } + } + } + fun update(savingSacks: Boolean) { display = drawDisplay(savingSacks) } @@ -40,6 +55,7 @@ object SackDisplay { val newDisplay = mutableListOf<List<Any>>() var totalPrice = 0L var rendered = 0 + var totalMagmaFish = 0L SackAPI.getSacksData(savingSacks) val sackItems = SackAPI.sackItem.toList() @@ -61,7 +77,7 @@ object SackDisplay { val amountShowing = if (config.itemToShow > sortedPairs.size) sortedPairs.size else config.itemToShow newDisplay.addAsSingletonList("§7Items in Sacks: §o(Rendering $amountShowing of ${sortedPairs.size} items)") for ((itemName, item) in sortedPairs) { - val (internalName, colorCode, stored, total, price) = item + val (internalName, colorCode, stored, total, price, magmaFish) = item totalPrice += price if (rendered >= config.itemToShow) continue if (stored == "0" && !config.showEmpty) continue @@ -84,6 +100,23 @@ object SackDisplay { ) if (colorCode == "§a") add(" §c§l(Full!)") + if (SackAPI.isTrophySack && magmaFish.toLong() > 0) { + totalMagmaFish += magmaFish.toLong() + add( + Renderable.hoverTips( + " §7(§d${magmaFish.toLong()} ", + listOf( + "§6Magmafish: §b${magmaFish.toLong().addSeparators()}", + "§6Magmafish value: §b${price / magmaFish.toLong()}", + "§6Magmafish per: §b${magmaFish.toLong() / stored.toLong()}" + + ) + ) + ) + add("MAGMA_FISH".asInternalName().getItemStack()) + add("§7)") + + } if (config.showPrice && price != 0L) add(" §7(§6${format(price)}§7)") }) rendered++ @@ -99,6 +132,9 @@ object SackDisplay { config.sortingType = it.ordinal update(false) }) + + if (SackAPI.isTrophySack) newDisplay.addAsSingletonList("§cTotal Magmafish: §6${totalMagmaFish.addSeparators()}") + newDisplay.addButton( prefix = "§7Number format: ", getName = NumberFormat.entries[config.numberFormat].DisplayName, @@ -107,6 +143,7 @@ object SackDisplay { update(false) } ) + if (config.showPrice) { newDisplay.addSelector<PriceFrom>(" ", getName = { type -> type.displayName }, |