aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/features/Croesus.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/dulkirmod/features/Croesus.kt')
-rw-r--r--src/main/kotlin/dulkirmod/features/Croesus.kt23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/main/kotlin/dulkirmod/features/Croesus.kt b/src/main/kotlin/dulkirmod/features/Croesus.kt
index e38616c..36bf3ee 100644
--- a/src/main/kotlin/dulkirmod/features/Croesus.kt
+++ b/src/main/kotlin/dulkirmod/features/Croesus.kt
@@ -12,10 +12,12 @@ import net.minecraftforge.fml.common.gameevent.TickEvent
class Croesus {
var lastGuiOpenEvent: Long = 0
+ var lastPageNumber = 1
@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
val lastInCroesus = inCroesusBool
+ var pageNumber = 1
if (!Config.hideOpenedChests) return
if (mc.currentScreen == null || !(mc.currentScreen is GuiChest)) {
@@ -24,6 +26,14 @@ class Croesus {
}
inCroesusBool = (ContainerNameUtil.currentGuiChestName == "Croesus")
+ if (inCroesusBool) {
+ pageNumber = findPageNumber()
+ }
+
+ // weird way of detecting page turn
+ if(lastPageNumber != pageNumber)
+ lastGuiOpenEvent = System.currentTimeMillis()
+
if (inCroesusBool && !lastInCroesus) {
lastGuiOpenEvent = System.currentTimeMillis()
}
@@ -35,9 +45,8 @@ class Croesus {
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)
+ val tagList: NBTTagList = stack.getSubCompound("display", false)?.getTagList("Lore", 8) ?: continue
for (j in 0 until tagList.tagCount()) {
if (tagList.getStringTagAt(j) == "§aChests have been opened!") boolArray[i - 9] = true
}
@@ -45,6 +54,16 @@ class Croesus {
}
}
+ private fun findPageNumber(): Int {
+ val stackPrev = mc.thePlayer.openContainer.getSlot(45).stack ?: return lastPageNumber
+
+ val stackPrevLore = stackPrev.getSubCompound("display", false)?.getTagList("Lore", 8) ?: return 1
+
+ if (stackPrevLore.getStringTagAt(0).contains("1")) return 2
+
+ return 3
+ }
+
companion object {
var inCroesusBool: Boolean = false
var boolArray = BooleanArray(36) { false }