blob: 28e657c1e8b72d08a53a5d7bc7f01a7c70311dc2 (
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
|
package at.hannibal2.skyhanni.test
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.MultiFilter
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.jsonobjects.MultiFilterJson
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.client.gui.inventory.GuiInventory
import net.minecraft.inventory.Slot
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class HighlightMissingRepoItems {
private val ignoreItems = MultiFilter()
@SubscribeEvent(priority = EventPriority.LOWEST)
fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!SkyHanniMod.feature.dev.debug.highlightMissingRepo) return
val gui = event.gui
if (gui is GuiChest) {
highlightItems(gui.inventorySlots.inventorySlots)
} else if (gui is GuiInventory) {
val player = Minecraft.getMinecraft().thePlayer
highlightItems(player.inventoryContainer.inventorySlots)
}
}
private fun highlightItems(slots: Iterable<Slot>) {
if (NEUItems.allInternalNames.isEmpty()) return
for (slot in slots) {
val internalName = slot.stack?.getInternalNameOrNull() ?: continue
if (NEUItems.allInternalNames.contains(internalName)) continue
if (ignoreItems.match(internalName.asString())) continue
slot highlight LorenzColor.RED
}
}
@SubscribeEvent
fun onNeuRepoReload(event: io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent) {
NEUItems.allItemsCache = NEUItems.readAllNeuItems()
}
@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val ignoredItems = event.getConstant<MultiFilterJson>("IgnoredItems")
ignoreItems.load(ignoredItems)
}
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.move(3, "dev.highlightMissingRepo", "dev.debug.highlightMissingRepo")
}
}
|