aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/itemability/CrownOfAvariceConfig.java28
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/itemability/ItemAbilityConfig.java7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/CrownOfAvariceCounter.kt51
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt2
4 files changed, 88 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/itemability/CrownOfAvariceConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/itemability/CrownOfAvariceConfig.java
new file mode 100644
index 000000000..4c23afa12
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/itemability/CrownOfAvariceConfig.java
@@ -0,0 +1,28 @@
+package at.hannibal2.skyhanni.config.features.itemability;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import at.hannibal2.skyhanni.config.core.config.Position;
+import com.google.gson.annotations.Expose;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+
+public class CrownOfAvariceConfig {
+
+ @Expose
+ @ConfigOption(name = "Counter",
+ desc = "Shows the current coins of your crown of avarice (if worn).")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enable = false;
+
+ @Expose
+ @ConfigOption(name = "Counter format",
+ desc = "Have the crown of avarice counter as short format instead of every digit.")
+ @ConfigEditorBoolean
+ public boolean shortFormat = true;
+
+ @Expose
+ @ConfigLink(owner = CrownOfAvariceConfig.class,field = "enable")
+ public Position position = new Position(20,20);
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/itemability/ItemAbilityConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/itemability/ItemAbilityConfig.java
index d428b591f..21ba39b8e 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/itemability/ItemAbilityConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/itemability/ItemAbilityConfig.java
@@ -1,9 +1,11 @@
package at.hannibal2.skyhanni.config.features.itemability;
import at.hannibal2.skyhanni.config.FeatureToggle;
+import at.hannibal2.skyhanni.config.core.config.Position;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.Accordion;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
public class ItemAbilityConfig {
@@ -36,6 +38,11 @@ public class ItemAbilityConfig {
@Expose
public ChickenHeadConfig chickenHead = new ChickenHeadConfig();
+ @ConfigOption(name = "Crown of Avarice", desc = "")
+ @Accordion
+ @Expose
+ public CrownOfAvariceConfig crownOfAvarice = new CrownOfAvariceConfig();
+
@Expose
@ConfigOption(name = "Depleted Bonzo's Masks",
desc = "Highlight used Bonzo's Masks and Spirit Masks with a background.")
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()),
+ ),
+ )
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index 5bafb370a..3f8441629 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -46,6 +46,8 @@ object ItemUtils {
return list
}
+ val ItemStack.extraAttributes : NBTTagCompound get() = this.tagCompound.getCompoundTag("ExtraAttributes")
+
// TODO change else janni is sad
fun ItemStack.isCoopSoulBound(): Boolean =
getLore().any {