diff options
Diffstat (limited to 'src/main/kotlin/dulkirmod/features')
-rw-r--r-- | src/main/kotlin/dulkirmod/features/Croesus.kt | 59 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/DungeonLeap.kt | 57 |
2 files changed, 86 insertions, 30 deletions
diff --git a/src/main/kotlin/dulkirmod/features/Croesus.kt b/src/main/kotlin/dulkirmod/features/Croesus.kt index 0ddfe9e..188c6a9 100644 --- a/src/main/kotlin/dulkirmod/features/Croesus.kt +++ b/src/main/kotlin/dulkirmod/features/Croesus.kt @@ -2,31 +2,60 @@ package dulkirmod.features import dulkirmod.DulkirMod.Companion.mc import dulkirmod.config.Config +import dulkirmod.utils.ContainerNameUtil import net.minecraft.client.gui.inventory.GuiChest -import net.minecraft.inventory.ContainerChest import net.minecraft.inventory.Slot +import net.minecraft.nbt.NBTTagList +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent class Croesus { + + var lastGuiOpenEvent : Long = 0 + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + val lastInCroesus = inCroesusBool + + if (!Config.hideOpenedChests) return + if (mc.currentScreen == null || !(mc.currentScreen is GuiChest)) { + inCroesusBool = false + return + } + inCroesusBool = (ContainerNameUtil.currentGuiChestName == "Croesus") + + if (inCroesusBool && !lastInCroesus) { + lastGuiOpenEvent = System.currentTimeMillis() + } + + if (inCroesusBool && System.currentTimeMillis() - lastGuiOpenEvent < 300) { + for (i in 9..44) { + boolArray[i-9] = false + val slotIn = mc.thePlayer.openContainer.getSlot(i) + + if (slotIn.stack == null) continue + val stack = slotIn.stack + if (stack.getSubCompound("display", true)?.getTagList("Lore", 8) == null) continue + + val tagList: NBTTagList = stack.getSubCompound("display", true).getTagList("Lore", 8) + for (j in 0 until tagList.tagCount()) { + if (tagList.getStringTagAt(j) == "§aChests have been opened!") boolArray[i-9] = true + } + } + } + } companion object { - var currentlyOpenChestName = "" + var inCroesusBool : Boolean = false + var boolArray = BooleanArray(36) {false} fun inCroesus(): Boolean { - if (mc.currentScreen == null || !(mc.currentScreen is GuiChest)) return false - val chest = mc.currentScreen as GuiChest - val container = chest.inventorySlots as ContainerChest - currentlyOpenChestName = container.lowerChestInventory.displayName.unformattedText - if (currentlyOpenChestName == "Croesus") return true - return false + return inCroesusBool } fun isChestOpened(slotIn: Slot): Boolean { - if (!Config.hideOpenedChests) return false - if (slotIn.stack?.getTooltip(mc.thePlayer, false) == null) return false - - var tooltip = slotIn.stack.getTooltip(mc.thePlayer, false) - if (tooltip.contains("§5§o§aChests have been opened!")) return true - - return false + if (!inCroesusBool) return false + val slotindex = slotIn.slotIndex + if (slotindex !in 9..44) return false + return boolArray[slotindex - 9] } } }
\ No newline at end of file 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 |