aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2023-06-28 08:25:08 +1000
committerGitHub <noreply@github.com>2023-06-28 00:25:08 +0200
commit53caebdecfffdcb3c386bc9ae412c32e8a6c709c (patch)
treee92bff6ee3a3cc7446a6e205074491db92e0f6bd /src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt
parentbe8b1c2ef97ad3ce210aa4e7a771323c381dd029 (diff)
downloadskyhanni-53caebdecfffdcb3c386bc9ae412c32e8a6c709c.tar.gz
skyhanni-53caebdecfffdcb3c386bc9ae412c32e8a6c709c.tar.bz2
skyhanni-53caebdecfffdcb3c386bc9ae412c32e8a6c709c.zip
Merge pull request #258
* highlight items missing in NEU repo * fixed it detecting some wrong items * Merge branch 'hannibal002:beta' into highlight_missing_neu_items
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt b/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt
new file mode 100644
index 000000000..63b552373
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt
@@ -0,0 +1,50 @@
+package at.hannibal2.skyhanni.test
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.GuiContainerEvent
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUItems
+import at.hannibal2.skyhanni.utils.RenderUtils.highlight
+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 {
+
+ @SubscribeEvent(priority = EventPriority.LOWEST)
+ fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (!SkyHanniMod.feature.dev.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) {
+ if (!slot.hasStack) continue
+ val internalName = slot.stack.getInternalName()
+ if (internalName == "") continue
+ if (!NEUItems.allInternalNames.contains(internalName)) {
+ slot highlight LorenzColor.RED
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onRepoReload(event: io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent) {
+ NEUItems.allItemsCache = NEUItems.readAllNeuItems()
+ }
+} \ No newline at end of file