From e0fc780a007acbc4c74520c0780a83edfaf477d2 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 17 Feb 2023 01:12:06 +0100 Subject: More Garden features around Visitor. --- .../java/at/hannibal2/skyhanni/utils/NEUItems.kt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt') 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() + private val itemNameCache = mutableMapOf() // 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)) { -- cgit