blob: 76488b13da90102f5c1b7fad19f74d4acd0fc997 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package com.ambientaddons.features.dungeon
import AmbientAddons.Companion.config
import AmbientAddons.Companion.mc
import com.ambientaddons.utils.Extensions.chest
import com.ambientaddons.utils.Extensions.items
import com.ambientaddons.utils.Extensions.stripControlCodes
import com.ambientaddons.utils.Area
import com.ambientaddons.utils.SBLocation
import com.ambientaddons.utils.dungeon.DungeonPlayers
import net.minecraftforge.client.event.GuiScreenEvent
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object DungeonReady {
private const val START_SLOT_INDEX = 13
private val READY_SLOTS = listOf(2, 3, 4, 5, 6)
private var hasClickedReady = false
private var hasClickedStart = false
@SubscribeEvent
fun onWorldUnload(event: WorldEvent.Unload) {
hasClickedReady = false
hasClickedStart = false
}
@SubscribeEvent
fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) {
if (config.autoReady == 0 || SBLocation.area != Area.Dungeon) return
val chest = event.gui?.chest ?: return
val chestName = chest.lowerChestInventory.name
if (chestName == "Start Dungeon?" && !hasClickedStart) {
if (config.autoReady == 1 && DungeonPlayers.playerCount != 5) return
hasClickedStart = true
mc.playerController.windowClick(chest.windowId, START_SLOT_INDEX, 2, 3, mc.thePlayer)
} else if (chestName.startsWith("Catacombs - ") && !hasClickedReady) {
val username = mc.thePlayer.name
val clickIndex = chest.lowerChestInventory.items.takeIf { it.last() != null }?.indexOfFirst {
username == it?.displayName?.stripControlCodes()?.substringAfter(" ")
}.takeIf { it != -1 } ?: return
hasClickedReady = true
mc.playerController.windowClick(chest.windowId, clickIndex + 9, 2, 3, mc.thePlayer)
}
}
}
|