blob: 9e99fdbae7c148d931082101f644ed1d1f2548fc (
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
|
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryOpenEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object HighlightOnHoverSlot {
val currentSlots = mutableMapOf<Pair<Int, Int>, List<Int>>()
@SubscribeEvent
fun onInventoryOpen(event: InventoryOpenEvent) {
currentSlots.clear()
}
@SubscribeEvent
fun onInventoryClose(event: InventoryCloseEvent) {
currentSlots.clear()
}
@SubscribeEvent(priority = EventPriority.LOW)
fun onDrawBackground(event: GuiContainerEvent.BackgroundDrawnEvent) {
if (!LorenzUtils.inSkyBlock) return
val list = currentSlots.flatMapTo(mutableSetOf()) { it.value }
for (slot in InventoryUtils.getItemsInOpenChest()) {
if (slot.slotNumber in list) {
slot highlight LorenzColor.GREEN
}
}
}
}
|