aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/features/DungeonLeap.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/dulkirmod/features/DungeonLeap.kt')
-rw-r--r--src/main/kotlin/dulkirmod/features/DungeonLeap.kt91
1 files changed, 43 insertions, 48 deletions
diff --git a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt b/src/main/kotlin/dulkirmod/features/DungeonLeap.kt
index d1be829..9c54c46 100644
--- a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt
+++ b/src/main/kotlin/dulkirmod/features/DungeonLeap.kt
@@ -9,52 +9,47 @@ import net.minecraft.inventory.Slot
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
-class DungeonLeap {
-
-
- private var lastGuiOpenEvent: Long = 0
-
- @SubscribeEvent
- fun onTick(event: TickEvent.ClientTickEvent) {
- val lastInLeap = inLeapMenuBool
-
- if (!Config.highlightLeap) return
- if (mc.currentScreen == null || mc.currentScreen !is GuiChest) {
- inLeapMenuBool = false
- return
- }
- inLeapMenuBool = (ContainerNameUtil.currentGuiChestName == "Spirit Leap")
-
- if (inLeapMenuBool && !lastInLeap) {
- lastGuiOpenEvent = System.currentTimeMillis()
- }
-
- if (inLeapMenuBool && System.currentTimeMillis() - lastGuiOpenEvent < 300) {
- for (i in 11..15) {
- boolArray[i - 11] = false
- val slotIn = mc.thePlayer.openContainer.getSlot(i)
-
- if (slotIn.stack == null) continue
- val stack = slotIn.stack
- if (Utils.stripColorCodes(stack.displayName).lowercase() == Config.highlightLeapName.lowercase()) boolArray[i - 11] = true
- }
- }
- }
-
- companion object {
- var inLeapMenuBool: Boolean = false
- var boolArray = BooleanArray(5) { false }
-
- fun inLeapMenu(): Boolean {
- return inLeapMenuBool
- }
-
- fun isHighlightedLeapPlayer(slotIn: Slot): Boolean {
- if (!inLeapMenuBool) return false
- if (slotIn.inventory == mc.thePlayer.inventory) return false
- val slotIndex = slotIn.slotIndex
- if (slotIndex !in 11..15) return false
- return boolArray[slotIndex - 11]
- }
- }
+object DungeonLeap {
+ @JvmField
+ var inLeapMenu = false
+ var leapPlayers = BooleanArray(5) { false }
+
+ private var lastGuiOpenEvent = 0L
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ val lastInLeap = inLeapMenu
+
+ if (!Config.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(Config.highlightLeapName, true)) {
+ leapPlayers[i - 11] = true
+ }
+ }
+ }
+ }
+ @JvmStatic
+ 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