From 4314c0c6fe9fdf46c4aeddfae2c212b2bcfe3a49 Mon Sep 17 00:00:00 2001 From: Xupie <81492239+Xupie@users.noreply.github.com> Date: Sat, 6 Jul 2024 11:40:56 +0300 Subject: Feature: Armor Stack Display (#1811) Co-authored-by: Xupie <> Co-authored-by: Cal Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../config/features/combat/CombatConfig.java | 5 +++ .../config/features/combat/StackDisplayConfig.java | 20 ++++++++++ .../skyhanni/features/combat/ArmorStackDisplay.kt | 43 ++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/combat/StackDisplayConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/features/combat/ArmorStackDisplay.kt (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/CombatConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/CombatConfig.java index 456c3451f..b01647609 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/combat/CombatConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/combat/CombatConfig.java @@ -24,6 +24,11 @@ public class CombatConfig { @Accordion public QuiverConfig quiverConfig = new QuiverConfig(); + @Expose + @ConfigOption(name = "Armor Stack Display", desc = "") + @Accordion + public StackDisplayConfig stackDisplayConfig = new StackDisplayConfig(); + @Expose @ConfigOption(name = "Summonings", desc = "") @Accordion diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/StackDisplayConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/StackDisplayConfig.java new file mode 100644 index 000000000..a955fec7a --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/combat/StackDisplayConfig.java @@ -0,0 +1,20 @@ +package at.hannibal2.skyhanni.config.features.combat; + +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 StackDisplayConfig { + @Expose + @ConfigOption(name = "Enable", desc = "Display the number of stacks on armor pieces like Crimson, Terror, Aurora etc.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = false; + + @Expose + @ConfigLink(owner = StackDisplayConfig.class, field = "enabled") + public Position position = new Position(480, -210, 1.9f); +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ArmorStackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ArmorStackDisplay.kt new file mode 100644 index 000000000..942adc20b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ArmorStackDisplay.kt @@ -0,0 +1,43 @@ +package at.hannibal2.skyhanni.features.combat + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.ActionBarUpdateEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RegexUtils.findMatcher +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object ArmorStackDisplay { + private val config get() = SkyHanniMod.feature.combat.stackDisplayConfig + private var display = "" + + /** + * REGEX-TEST: §66,171/4,422❤ §6§l10ᝐ§r §a1,295§a❈ Defense §b525/1,355✎ §3400ʬ + * REGEX-TEST: §66,171/4,422❤ §65ᝐ §b-150 Mana (§6Wither Impact§b) §b1,016/1,355✎ §3400ʬ + */ + private val armorStackPattern by RepoPattern.pattern( + "combat.armorstack.actionbar", + " (?:§6|§6§l)(?\\d+[ᝐ⁑|҉Ѫ⚶])" + ) + + @SubscribeEvent + fun onActionBar(event: ActionBarUpdateEvent) { + if (!isEnabled()) return + val stacks = armorStackPattern.findMatcher(event.actionBar) { + "§6§l" + group("stack") + } ?: "" + display = stacks + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { + if (!isEnabled()) return + config.position.renderString(display, posLabel = "Armor Stack Display") + } + + fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled +} -- cgit