diff options
author | Xupie <81492239+Xupie@users.noreply.github.com> | 2024-07-06 11:40:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-06 10:40:56 +0200 |
commit | 4314c0c6fe9fdf46c4aeddfae2c212b2bcfe3a49 (patch) | |
tree | b27f35f677b45cd09a9770e8e5fa163f07fb1423 /src/main/java/at/hannibal2/skyhanni | |
parent | e6b2bcbcdb17f729ead84fd2a2d5d8c0dc6eebc3 (diff) | |
download | skyhanni-4314c0c6fe9fdf46c4aeddfae2c212b2bcfe3a49.tar.gz skyhanni-4314c0c6fe9fdf46c4aeddfae2c212b2bcfe3a49.tar.bz2 skyhanni-4314c0c6fe9fdf46c4aeddfae2c212b2bcfe3a49.zip |
Feature: Armor Stack Display (#1811)
Co-authored-by: Xupie <>
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
3 files changed, 68 insertions, 0 deletions
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 @@ -25,6 +25,11 @@ public class CombatConfig { public QuiverConfig quiverConfig = new QuiverConfig(); @Expose + @ConfigOption(name = "Armor Stack Display", desc = "") + @Accordion + public StackDisplayConfig stackDisplayConfig = new StackDisplayConfig(); + + @Expose @ConfigOption(name = "Summonings", desc = "") @Accordion public SummoningsConfig summonings = new SummoningsConfig(); 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)(?<stack>\\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 +} |