diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-02-27 02:25:12 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-26 16:25:12 +0100 |
commit | d524a9979b1de74c07a90d806703e518b2b184a1 (patch) | |
tree | 1e6ced8eb280fb0542f1c0f1425e2e064ddb0a4b /src/main/java/at/hannibal2/skyhanni | |
parent | 8d7eb45435c328792638cba18eed498e139706a8 (diff) | |
download | skyhanni-d524a9979b1de74c07a90d806703e518b2b184a1.tar.gz skyhanni-d524a9979b1de74c07a90d806703e518b2b184a1.tar.bz2 skyhanni-d524a9979b1de74c07a90d806703e518b2b184a1.zip |
= Fixed HighlightMissingRepoItems. #1062
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
3 files changed, 12 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt b/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt index 62bb84b94..6eea21007 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt @@ -3,12 +3,10 @@ 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.NeuRepositoryReloadEvent import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUItems -import at.hannibal2.skyhanni.utils.NEUItems.allItemsCache import at.hannibal2.skyhanni.utils.RenderUtils.highlight import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest @@ -35,10 +33,10 @@ class HighlightMissingRepoItems { } private fun highlightItems(slots: Iterable<Slot>) { - if (allItemsCache.isEmpty()) return + if (NEUItems.allInternalNames.isEmpty()) return for (slot in slots) { val internalName = slot.stack?.getInternalNameOrNull() ?: continue - if (allItemsCache.containsValue(internalName)) continue + if (NEUItems.allInternalNames.contains(internalName)) continue if (NEUItems.ignoreItemsFilter.match(internalName.asString())) continue slot highlight LorenzColor.RED @@ -46,11 +44,6 @@ class HighlightMissingRepoItems { } @SubscribeEvent - fun onNeuRepoReload(event: NeuRepositoryReloadEvent) { - NEUItems.allItemsCache = NEUItems.readAllNeuItems() - } - - @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(3, "dev.highlightMissingRepo", "dev.debug.highlightMissingRepo") } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt index d17f579ed..baf9ee8ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt @@ -74,6 +74,7 @@ object ItemNameResolver { if (NEUItems.allItemsCache.isEmpty()) { NEUItems.allItemsCache = NEUItems.readAllNeuItems() } + NEUItems.allItemsCache[lowercase]?.let { itemNameCache[lowercase] = it return it diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 69f1e4fc3..1ca6e2a70 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.data.jsonobjects.repo.MultiFilterJson +import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.bazaar.BazaarDataHolder import at.hannibal2.skyhanni.test.command.ErrorManager @@ -40,6 +41,7 @@ object NEUItems { private val ingredientsCache = mutableMapOf<NeuRecipe, Set<Ingredient>>() var allItemsCache = mapOf<String, NEUInternalName>() // item name -> internal name + val allInternalNames = mutableListOf<NEUInternalName>() val ignoreItemsFilter = MultiFilter() private val fallbackItem by lazy { @@ -56,15 +58,22 @@ object NEUItems { ignoreItemsFilter.load(ignoredItems) } + @SubscribeEvent + fun onNeuRepoReload(event: NeuRepositoryReloadEvent) { + allItemsCache = readAllNeuItems() + } + @Deprecated("Use NEUInternalName rather than String", ReplaceWith("getInternalNameFromItemName()")) fun getRawInternalName(itemName: String): String = NEUInternalName.fromItemName(itemName).asString() fun readAllNeuItems(): Map<String, NEUInternalName> { + allInternalNames.clear() val map = mutableMapOf<String, NEUInternalName>() for (rawInternalName in allNeuRepoItems().keys) { val name = manager.createItem(rawInternalName).displayName.removeColor().lowercase() val internalName = rawInternalName.asInternalName() map[name] = internalName + allInternalNames.add(internalName) } return map } |