From af7f09284caa16d7ba70c97a2c28c6a8fc1f83e6 Mon Sep 17 00:00:00 2001 From: Walker Selby Date: Sat, 9 Dec 2023 13:36:05 -0800 Subject: Internal Change: Minion craft helper NEUInternalName (#619) Changed MinionCraftHelper to use NeuInternalName. #619 --- .../java/at/hannibal2/skyhanni/utils/NEUItems.kt | 39 +++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/utils') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 02c8dff54..dff8a77e9 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -33,8 +33,8 @@ import java.util.regex.Pattern object NEUItems { val manager: NEUManager get() = NotEnoughUpdates.INSTANCE.manager private val itemNameCache = mutableMapOf() // item name -> internal name - private val multiplierCache = mutableMapOf>() - private val recipesCache = mutableMapOf>() + private val multiplierCache = mutableMapOf>() + private val recipesCache = mutableMapOf>() private val ingredientsCache = mutableMapOf>() private val enchantmentNamePattern = Pattern.compile("^(?(?:§.)+)(?[^§]+) (?[IVXL]+)$") var allItemsCache = mapOf() // item name -> internal name @@ -231,11 +231,6 @@ object NEUItems { } fun getMultiplier(internalName: NEUInternalName, tryCount: Int = 0): Pair { - val pair = getMultiplier(internalName.asString(), tryCount) - return Pair(pair.first.asInternalName(), pair.second) - } - - fun getMultiplier(internalName: String, tryCount: Int = 0): Pair { if (multiplierCache.contains(internalName)) { return multiplierCache[internalName]!! } @@ -250,27 +245,27 @@ object NEUItems { for (recipe in getRecipes(internalName)) { if (recipe !is CraftingRecipe) continue - val map = mutableMapOf() + val map = mutableMapOf() for (ingredient in recipe.getCachedIngredients()) { val count = ingredient.count.toInt() - var internalItemId = ingredient.internalItemId + var internalItemId = ingredient.internalItemId.asInternalName() // ignore cactus green - if (internalName == "ENCHANTED_CACTUS_GREEN" && internalItemId == "INK_SACK-2") { - internalItemId = "CACTUS" + if (internalName == "ENCHANTED_CACTUS_GREEN".asInternalName() && internalItemId == "INK_SACK-2".asInternalName()) { + internalItemId = "CACTUS".asInternalName() } // ignore wheat in enchanted cookie - if (internalName == "ENCHANTED_COOKIE" && internalItemId == "WHEAT") { + if (internalName == "ENCHANTED_COOKIE".asInternalName() && internalItemId == "WHEAT".asInternalName()) { continue } // ignore golden carrot in enchanted golden carrot - if (internalName == "ENCHANTED_GOLDEN_CARROT" && internalItemId == "GOLDEN_CARROT") { + if (internalName == "ENCHANTED_GOLDEN_CARROT".asInternalName() && internalItemId == "GOLDEN_CARROT".asInternalName()) { continue } // ignore rabbit hide in leather - if (internalName == "LEATHER" && internalItemId == "RABBIT_HIDE") { + if (internalName == "LEATHER".asInternalName() && internalItemId == "RABBIT_HIDE".asInternalName()) { continue } @@ -293,14 +288,20 @@ object NEUItems { val result = Pair(internalName, 1) multiplierCache[internalName] = result return result + + } + + fun getMultiplier(internalName: String, tryCount: Int = 0): Pair { + val pair = getMultiplier(internalName.asInternalName(), tryCount) + return Pair(pair.first.asString(), pair.second) } - fun getRecipes(minionId: String): Set { - if (recipesCache.contains(minionId)) { - return recipesCache[minionId]!! + fun getRecipes(internalName: NEUInternalName): Set { + if (recipesCache.contains(internalName)) { + return recipesCache[internalName]!! } - val recipes = manager.getRecipesFor(minionId) - recipesCache[minionId] = recipes + val recipes = manager.getRecipesFor(internalName.asString()) + recipesCache[internalName] = recipes return recipes } -- cgit