aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorClicks <58398364+CuzImClicks@users.noreply.github.com>2024-09-21 13:20:10 +0200
committerGitHub <noreply@github.com>2024-09-21 13:20:10 +0200
commit0aa7a605a23f3b1740a481c39ca58835c53d0650 (patch)
tree8798f49232d1327768e800475f3b2d42333ec97e /src/main/java/at/hannibal2/skyhanni/features
parent1052203d26f8ded5d7a1b1eb25a32e0ce2e6c784 (diff)
downloadskyhanni-0aa7a605a23f3b1740a481c39ca58835c53d0650.tar.gz
skyhanni-0aa7a605a23f3b1740a481c39ca58835c53d0650.tar.bz2
skyhanni-0aa7a605a23f3b1740a481c39ca58835c53d0650.zip
Feature: Highlight Active Beacon Effect (#2546)
Co-authored-by: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/ActiveBeaconEffect.kt69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ActiveBeaconEffect.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ActiveBeaconEffect.kt
new file mode 100644
index 000000000..d0bc67fde
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ActiveBeaconEffect.kt
@@ -0,0 +1,69 @@
+package at.hannibal2.skyhanni.features.inventory
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.IslandType
+import at.hannibal2.skyhanni.events.GuiContainerEvent
+import at.hannibal2.skyhanni.events.InventoryCloseEvent
+import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
+import at.hannibal2.skyhanni.utils.RegexUtils.matches
+import at.hannibal2.skyhanni.utils.RenderUtils.highlight
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+@SkyHanniModule
+object ActiveBeaconEffect {
+
+ val config get() = SkyHanniMod.feature.inventory
+
+ private val patternGroup = RepoPattern.group("inventory.activebeaconeffect")
+
+ /**
+ * REGEX-TEST: Profile Stat Upgrades
+ */
+ private val inventoryPattern by patternGroup.pattern(
+ "inventory",
+ "Profile Stat Upgrades",
+ )
+
+ /**
+ * REGEX-TEST: §aActive stat boost!
+ */
+ private val slotPattern by patternGroup.pattern(
+ "slot.active",
+ "§aActive stat boost!",
+ )
+
+ private var slot: Int? = null
+
+ @SubscribeEvent
+ fun onInventoryFullyOpened(event: InventoryFullyOpenedEvent) {
+ if (!isEnabled()) return
+ if (!inventoryPattern.matches(event.inventoryName)) {
+ slot = null
+ return
+ }
+
+ slot = event.inventoryItems.filter { (_, stack) ->
+ stack.getLore().any { slotPattern.matches(it) }
+ }.firstNotNullOfOrNull { it.key }
+ }
+
+ @SubscribeEvent
+ fun onInventoryClose(event: InventoryCloseEvent) {
+ slot = null
+ }
+
+ @SubscribeEvent
+ fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
+ if (!isEnabled()) return
+ val slot = slot ?: return
+
+ event.gui.inventorySlots.getSlot(slot) highlight LorenzColor.GREEN
+ }
+
+ fun isEnabled() = IslandType.PRIVATE_ISLAND.isInIsland() && config.highlightActiveBeaconEffect
+}