diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-07-17 12:42:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-17 12:42:27 +0200 |
commit | 81358be1e6fe2ba1de02afcd2d08a969679bd14a (patch) | |
tree | 55ef8fa79c36f9a21b338e59d46b81b7bf2c3975 /src/main/java/at/hannibal2/skyhanni/features | |
parent | fb7384530a123d2b6159afb0ca16db658eaa26b5 (diff) | |
download | skyhanni-81358be1e6fe2ba1de02afcd2d08a969679bd14a.tar.gz skyhanni-81358be1e6fe2ba1de02afcd2d08a969679bd14a.tar.bz2 skyhanni-81358be1e6fe2ba1de02afcd2d08a969679bd14a.zip |
Feature: Crown of Avarice Counter (#2229)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/itemabilities/CrownOfAvariceCounter.kt | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/CrownOfAvariceCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/CrownOfAvariceCounter.kt new file mode 100644 index 000000000..207e1b92b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/CrownOfAvariceCounter.kt @@ -0,0 +1,51 @@ +package at.hannibal2.skyhanni.features.itemabilities + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.extraAttributes +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getItemStack +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable +import at.hannibal2.skyhanni.utils.renderables.Renderable +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object CrownOfAvariceCounter { + + private val config get() = SkyHanniMod.feature.inventory.itemAbilities.crownOfAvarice + + private val internalName = "CROWN_OF_AVARICE".asInternalName() + + private var render: Renderable? = null + + @SubscribeEvent + fun onOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { + render?.let { config.position.renderRenderable(it, posLabel = "Crown of Avarice Counter") } + } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + render = check() + } + + fun check(): Renderable? { + if (!LorenzUtils.inSkyBlock) return null + if (!config.enable) return null + val item = InventoryUtils.getHelmet() + if (item?.getInternalNameOrNull() != internalName) return null + val count = item.extraAttributes.getLong("collected_coins"); + return Renderable.horizontalContainer( + listOf( + Renderable.itemStack(internalName.getItemStack()), + Renderable.string("ยง6" + if (config.shortFormat) count.shortFormat() else count.addSeparators()), + ), + ) + } +} |