aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/features/Croesus.kt
diff options
context:
space:
mode:
authoringle <inglettronald@gmail.com>2022-10-28 12:17:26 -0500
committeringle <inglettronald@gmail.com>2022-10-28 12:17:26 -0500
commitbfa2b37155711e2a907f15d6e56d18378ae4f723 (patch)
treeffae5faade666c6ed631f8f8c438def680c9fc27 /src/main/kotlin/dulkirmod/features/Croesus.kt
parentfba8ecf8f06c03c36c8d4823fe5e5928bad98d32 (diff)
downloadDulkirMod-bfa2b37155711e2a907f15d6e56d18378ae4f723.tar.gz
DulkirMod-bfa2b37155711e2a907f15d6e56d18378ae4f723.tar.bz2
DulkirMod-bfa2b37155711e2a907f15d6e56d18378ae4f723.zip
+ Efficiency improvements
+ command for setting leap highlight + (I THINK) abiphone dnd (on by default)
Diffstat (limited to 'src/main/kotlin/dulkirmod/features/Croesus.kt')
-rw-r--r--src/main/kotlin/dulkirmod/features/Croesus.kt59
1 files changed, 44 insertions, 15 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