aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt21
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)) {