aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-10 11:33:25 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-10 11:33:25 +0200
commit954578ca269cc71c4751c328c1b6ed51553c1f99 (patch)
tree76aaaa8b03e6a597c0b233e6309a662549bbd856 /src
parentbf860a73e1206a132f446f23915f0ca0e3bbf615 (diff)
downloadskyhanni-954578ca269cc71c4751c328c1b6ed51553c1f99.tar.gz
skyhanni-954578ca269cc71c4751c328c1b6ed51553c1f99.tar.bz2
skyhanni-954578ca269cc71c4751c328c1b6ed51553c1f99.zip
Fixed bazaar item detection problems for some items
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index 7fbb70539..ac9b2da2b 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -18,13 +18,14 @@ import net.minecraft.client.renderer.RenderHelper
import net.minecraft.init.Items
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
+import java.util.regex.Pattern
object NEUItems {
val manager: NEUManager get() = NotEnoughUpdates.INSTANCE.manager
private val itemNameCache = mutableMapOf<String, String>() // item name -> internal name
private val multiplierCache = mutableMapOf<String, Pair<String, Int>>()
private val recipesCache = mutableMapOf<String, Set<NeuRecipe>>()
- private val turboBookPattern = "§fTurbo-(?<name>.*) (?<level>.)".toPattern()
+ private val enchantmentNamePattern = Pattern.compile("^(?<format>(?:§.)+)(?<name>[^§]+) (?<level>[IVXL]+)$")
fun getInternalName(itemName: String): String {
return getInternalNameOrNull(itemName) ?: throw Error("getInternalName is null for '$itemName'")
@@ -35,12 +36,11 @@ object NEUItems {
return itemNameCache[itemName]!!
}
- var internalName = turboBookPattern.matchMatcher(itemName) {
- val type = group("name")
- val level = group("level").romanToDecimal()
- val name = turboCheck(type).uppercase()
- "TURBO_$name;$level"
- } ?: ItemResolutionQuery.findInternalNameByDisplayName(itemName, false) ?: return null
+ resolveEnchantmentByName(itemName)?.let {
+ itemNameCache[itemName] = it
+ return it
+ }
+ var internalName = ItemResolutionQuery.findInternalNameByDisplayName(itemName, false) ?: return null
// This fixes a NEU bug with §9Hay Bale (cosmetic item)
// TODO remove workaround when this is fixed in neu
@@ -53,8 +53,8 @@ object NEUItems {
}
private fun turboCheck(text: String): String {
- if (text == "Cocoa") return "Coco"
- if (text == "Cacti") return "Cactus"
+ if (text == "Turbo-Cocoa") return "Turbo-Coco"
+ if (text == "Turbo-Cacti") return "Turbo-Cactus"
return text
}
@@ -228,4 +228,15 @@ object NEUItems {
return false
}
+
+ // Taken and edited from NEU
+ private fun resolveEnchantmentByName(enchantmentName: String): String? {
+ return enchantmentNamePattern.matchMatcher(enchantmentName) {
+ val name = group("name").trim { it <= ' ' }
+ val ultimate = group("format").lowercase().contains("§l")
+ ((if (ultimate && name != "Ultimate Wise") "ULTIMATE_" else "")
+ + turboCheck(name).replace(" ", "_").replace("-", "_").uppercase()
+ + ";" + group("level").romanToDecimal())
+ }
+ }
} \ No newline at end of file