blob: 45ad93ca12d2ea982f83ff2d415da48b9c9d855b (
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
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
|
package at.hannibal2.skyhanni.features.minion
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.jsonobjects.repo.InfernoMinionFuelsJson
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object InfernoMinionFeatures {
private val config get() = SkyHanniMod.feature.misc.minions
private val infernoMinionTitlePattern by RepoPattern.pattern(
"minion.infernominiontitle",
"Inferno Minion .*"
)
private var fuelItemIds = listOf<NEUInternalName>()
private var inInventory = false
@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<InfernoMinionFuelsJson>("InfernoMinionFuels")
fuelItemIds = data.minionFuels
}
@SubscribeEvent
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
inInventory = infernoMinionTitlePattern.matches(event.inventoryName)
}
@SubscribeEvent
fun onInventoryClose(event: InventoryCloseEvent) {
inInventory = false
}
@SubscribeEvent
fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!config.infernoFuelBlocker) return
if (!inInventory) return
val containsFuel =
NEUInternalName.fromItemNameOrNull(event.container.getSlot(19).stack.name) in fuelItemIds
if (!containsFuel) return
if (event.slot?.slotNumber == 19 || event.slot?.slotNumber == 53) {
if (KeyboardManager.isModifierKeyDown()) return
event.cancel()
}
}
@SubscribeEvent
fun onTooltip(event: LorenzToolTipEvent) {
if (!config.infernoFuelBlocker) return
if (!inInventory) return
val containsFuel = NEUInternalName.fromItemNameOrNull(event.itemStack.name) in fuelItemIds
if (!containsFuel) return
if (event.slot.slotNumber == 19) {
event.toolTip.add("")
event.toolTip.add("§c[SkyHanni] is blocking you from taking this out!")
event.toolTip.add(" §7(Bypass by holding the ${KeyboardManager.getModifierKeyName()} key)")
}
if (event.slot.slotNumber == 53) {
event.toolTip.add("")
event.toolTip.add("§c[SkyHanni] is blocking you from picking this minion up!")
event.toolTip.add(" §7(Bypass by holding the ${KeyboardManager.getModifierKeyName()} key)")
}
}
}
|