diff options
Diffstat (limited to 'src/main/kotlin/dulkirmod/features/DungeonLeap.kt')
-rw-r--r-- | src/main/kotlin/dulkirmod/features/DungeonLeap.kt | 57 |
1 files changed, 42 insertions, 15 deletions
diff --git a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt b/src/main/kotlin/dulkirmod/features/DungeonLeap.kt index 54a304c..b8ce75e 100644 --- a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt +++ b/src/main/kotlin/dulkirmod/features/DungeonLeap.kt @@ -1,32 +1,59 @@ package dulkirmod.features import dulkirmod.DulkirMod +import dulkirmod.DulkirMod.Companion.mc import dulkirmod.config.Config +import dulkirmod.utils.ContainerNameUtil import dulkirmod.utils.Utils import net.minecraft.client.gui.inventory.GuiChest -import net.minecraft.inventory.ContainerChest 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 = DulkirMod.mc.thePlayer.openContainer.getSlot(i) + + if (slotIn.stack == null) continue + val stack = slotIn.stack + if (Utils.stripColorCodes(stack.displayName) == Config.highlightLeapName) boolArray[i-11] = true + } + } + } companion object { + var inLeapMenuBool : Boolean = false + var boolArray = BooleanArray(5) {false} + fun inLeapMenu(): Boolean { - if (DulkirMod.mc.currentScreen == null || !(DulkirMod.mc.currentScreen is GuiChest)) return false - val chest = DulkirMod.mc.currentScreen as GuiChest - val container = chest.inventorySlots as ContainerChest - Croesus.currentlyOpenChestName = container.lowerChestInventory.displayName.unformattedText - if (Croesus.currentlyOpenChestName == "Spirit Leap") return true - return false + return inLeapMenuBool } fun isHighlightedLeapPlayer(slotIn: Slot): Boolean { - if (slotIn.stack?.getTooltip(DulkirMod.mc.thePlayer, false) == null) return false - - val tooltip = slotIn.stack.getTooltip(DulkirMod.mc.thePlayer, false) - for (s in tooltip) { - var t = Utils.stripColorCodes(s) - if (t == Config.highlightLeapName) return true - } - return false + 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] } } }
\ No newline at end of file |