diff options
Diffstat (limited to 'src/main/java/at/hannibal2')
5 files changed, 69 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index c1856c035..c63a6fe32 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -323,6 +323,7 @@ class SkyHanniMod { loadModule(PacketTest()) loadModule(TestBingo) loadModule(TestCopyRngMeterValues) + loadModule(HighlightMissingRepoItems()) } @Mod.EventHandler diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/DevData.java b/src/main/java/at/hannibal2/skyhanni/config/features/DevData.java index 77a0fcf33..1fb5a2be1 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/DevData.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/DevData.java @@ -48,6 +48,12 @@ public class DevData { public boolean showInternalName = false; @Expose + @ConfigOption(name = "Show empty internal names", desc = "Shows internal name even if it is blank.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean showEmptyNames = false; + + @Expose @ConfigOption(name = "Show item UUID", desc = "Show the Unique Identifier of items. in the lore.") @ConfigEditorBoolean @ConfigAccordionId(id = 0) @@ -60,6 +66,12 @@ public class DevData { public boolean copyRngMeter = false; @Expose + @ConfigOption(name = "Highlight Missing Repo Items", desc = "Highlights each item in the current inventory that is not in your current NEU repo.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean highlightMissingRepo = false; + + @Expose public Position debugPos = new Position(10, 10, false, true); @Expose 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 diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniTestCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniTestCommand.kt index d3a7e982f..d10fc49f3 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniTestCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniTestCommand.kt @@ -167,6 +167,7 @@ class SkyHanniTestCommand { val itemStack = event.itemStack if (itemStack != null) { val internalName = itemStack.getInternalName() + if (internalName == "" && !SkyHanniMod.feature.dev.showEmptyNames) return event.toolTip.add("Internal Name: '$internalName'") } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index dc98f3a0a..97f1b7ca3 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -30,7 +30,8 @@ object NEUItems { private val multiplierCache = mutableMapOf<String, Pair<String, Int>>() private val recipesCache = mutableMapOf<String, Set<NeuRecipe>>() private val enchantmentNamePattern = Pattern.compile("^(?<format>(?:§.)+)(?<name>[^§]+) (?<level>[IVXL]+)$") - private var allItemsCache = mapOf<String, String>() // item name -> internal name + var allItemsCache = mapOf<String, String>() // item name -> internal name + var allInternalNames = mutableListOf<String>() fun getInternalName(itemName: String): String { return getInternalNameOrNull(itemName) ?: throw Error("getInternalName is null for '$itemName'") @@ -53,11 +54,13 @@ object NEUItems { return null } - private fun readAllNeuItems(): Map<String, String> { + fun readAllNeuItems(): Map<String, String> { + allInternalNames.clear() val map = mutableMapOf<String, String>() for (internalName in manager.itemInformation.keys) { val name = manager.createItem(internalName).displayName.removeColor().lowercase() map[name] = internalName + allInternalNames.add(internalName) } return map } |