diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-17 01:12:06 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-17 01:12:06 +0100 |
commit | e0fc780a007acbc4c74520c0780a83edfaf477d2 (patch) | |
tree | 22889bf046e5649a605e0350df1772af05eb9fc4 /src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt | |
parent | 11600a35dce6f8c5b0031a8318a60c42522a952b (diff) | |
download | skyhanni-e0fc780a007acbc4c74520c0780a83edfaf477d2.tar.gz skyhanni-e0fc780a007acbc4c74520c0780a83edfaf477d2.tar.bz2 skyhanni-e0fc780a007acbc4c74520c0780a83edfaf477d2.zip |
More Garden features around Visitor.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 46c9c6fea..8c127fac8 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.utils.StringUtils.removeColor import io.github.moulberry.notenoughupdates.NotEnoughUpdates import io.github.moulberry.notenoughupdates.util.Utils import net.minecraft.client.renderer.GlStateManager @@ -9,6 +10,26 @@ import net.minecraft.item.ItemStack object NEUItems { private val itemCache = mutableMapOf<String, ItemStack>() + private val itemNameCache = mutableMapOf<String, String>() // display name -> internal name + + fun getInternalNameByName(rawName: String): String? { + val itemName = rawName.removeColor() + if (itemNameCache.containsKey(itemName)) { + return itemNameCache[itemName] + } + val manager = NotEnoughUpdates.INSTANCE.manager + for ((internalId, b) in manager.itemInformation) { + if (b.has("displayname")) { + val name = b.get("displayname").asString + if (name.contains(itemName)) { + itemNameCache[itemName] = internalId + return internalId + } + } + } + + return null + } fun readItemFromRepo(internalName: String): ItemStack { if (itemCache.contains(internalName)) { |