aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/features/dungeons/DungeonLeap.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/dulkirmod/features/dungeons/DungeonLeap.kt')
-rw-r--r--src/main/kotlin/dulkirmod/features/dungeons/DungeonLeap.kt54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/main/kotlin/dulkirmod/features/dungeons/DungeonLeap.kt b/src/main/kotlin/dulkirmod/features/dungeons/DungeonLeap.kt
new file mode 100644
index 0000000..e7fdc29
--- /dev/null
+++ b/src/main/kotlin/dulkirmod/features/dungeons/DungeonLeap.kt
@@ -0,0 +1,54 @@
+package dulkirmod.features.dungeons
+
+import dulkirmod.DulkirMod.Companion.mc
+import dulkirmod.config.DulkirConfig
+import dulkirmod.utils.ContainerNameUtil
+import dulkirmod.utils.Utils
+import net.minecraft.client.gui.inventory.GuiChest
+import net.minecraft.inventory.Slot
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+
+object DungeonLeap {
+ var inLeapMenu = false
+ var leapPlayers = BooleanArray(5) { false }
+
+ private var lastGuiOpenEvent = 0L
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ val lastInLeap = inLeapMenu
+
+ if (!DulkirConfig.highlightLeap) return
+ if (mc.currentScreen == null || mc.currentScreen !is GuiChest) {
+ inLeapMenu = false
+ return
+ }
+ inLeapMenu = (ContainerNameUtil.currentGuiChestName == "Spirit Leap")
+
+ if (inLeapMenu && !lastInLeap) {
+ lastGuiOpenEvent = System.currentTimeMillis()
+ }
+
+ if (inLeapMenu && System.currentTimeMillis() - lastGuiOpenEvent < 300) {
+ for (i in 11..15) {
+ leapPlayers[i - 11] = false
+ val slotIn = mc.thePlayer.openContainer.getSlot(i)
+
+ if (slotIn.stack == null) continue
+ val stack = slotIn.stack
+ if (Utils.stripColorCodes(stack.displayName).equals(DulkirConfig.highlightLeapName, true)) {
+ leapPlayers[i - 11] = true
+ }
+ }
+ }
+ }
+
+ fun isHighlightedLeapPlayer(slotIn: Slot): Boolean {
+ if (!inLeapMenu) return false
+ if (slotIn.inventory == mc.thePlayer.inventory) return false
+ val slotIndex = slotIn.slotIndex
+ if (slotIndex !in 11..15) return false
+ return leapPlayers[slotIndex - 11]
+ }
+} \ No newline at end of file