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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
package at.hannibal2.skyhanni.features.mining
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.jsonobjects.repo.ParkourJson
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor
import at.hannibal2.skyhanni.utils.ConditionalUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
import at.hannibal2.skyhanni.utils.ParkourHelper
import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent
import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.client.player.inventory.ContainerLocalMenu
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class DeepCavernsGuide {
private val config get() = SkyHanniMod.feature.mining.deepCavernsGuide
private var parkourHelper: ParkourHelper? = null
private var show = false
private var showStartIcon = false
private val startIcon by lazy {
val neuItem = "MAP".asInternalName().getItemStack()
Utils.createItemStack(
neuItem.item,
"§bDeep Caverns Guide",
"§8(From SkyHanni)",
"",
"§7Manually enable the ",
"§7guide to the bottom",
"§7of the Deep Caverns."
)
}
@SubscribeEvent
fun onIslandChange(event: IslandChangeEvent) {
parkourHelper?.reset()
show = false
}
@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<ParkourJson>("DeepCavernsParkour")
parkourHelper = ParkourHelper(
data.locations,
data.shortCuts,
platformSize = 1.0,
detectionRange = 3.5,
depth = false,
onEndReach = {
show = false
}
)
updateConfig()
}
@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
ConditionalUtils.onToggle(config.rainbowColor, config.monochromeColor, config.lookAhead) {
updateConfig()
}
}
private fun updateConfig() {
parkourHelper?.run {
rainbowColor = config.rainbowColor.get()
monochromeColor = config.monochromeColor.get().toChromaColor()
lookAhead = config.lookAhead.get() + 1
}
}
@SubscribeEvent
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
showStartIcon = false
if (!isEnabled()) return
if (event.inventoryName != "Lift") return
if (LorenzUtils.skyBlockArea != "Gunpowder Mines") return
showStartIcon = true
event.inventoryItems[30]?.let {
if (it.displayName != "§aObsidian Sanctuary") {
if (!show) {
start()
ChatUtils.chat("Automatically enabling Deep Caverns Guide, helping you find the way to the bottom of the Deep Caverns and the path to Rhys.")
}
}
}
}
private fun start() {
show = true
parkourHelper?.reset()
if (parkourHelper == null) {
ChatUtils.clickableChat(
"DeepCavernsParkour missing in SkyHanni Repo! Try /shupdaterepo to fix it!",
onClick = {
SkyHanniMod.repo.updateRepo()
},
prefixColor = "§c"
)
}
}
@SubscribeEvent
fun onInventoryClose(event: InventoryCloseEvent) {
showStartIcon = false
}
@SubscribeEvent
fun replaceItem(event: ReplaceItemEvent) {
if (show) return
if (event.inventory is ContainerLocalMenu && showStartIcon && event.slotNumber == 49) {
event.replaceWith(startIcon)
}
}
@SubscribeEvent(priority = EventPriority.HIGH)
fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
if (showStartIcon && event.slotId == 49) {
event.isCanceled = true
ChatUtils.chat("Manually enabled Deep Caverns Guide.")
start()
}
}
@SubscribeEvent
fun onRenderWorld(event: LorenzRenderWorldEvent) {
if (!isEnabled()) return
if (!show) return
parkourHelper?.render(event)
}
fun isEnabled() = IslandType.DEEP_CAVERNS.isInIsland() && config.enabled
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.move(38, "mining.deepCavernsParkour", "mining.deepCavernsGuide")
}
}
|