aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/PrimitiveIngredient.kt26
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/PrimitiveRecipe.kt53
12 files changed, 126 insertions, 61 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt
index e4bae4f05..e94fb8d84 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt
@@ -1,13 +1,12 @@
package at.hannibal2.skyhanni.features.bingo
import at.hannibal2.skyhanni.test.command.ErrorManager
-import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.NEUInternalName
-import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.NEUItems.getCachedIngredients
+import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
+import at.hannibal2.skyhanni.utils.PrimitiveRecipe
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe
object FirstMinionTier {
@@ -30,20 +29,20 @@ object FirstMinionTier {
) {
for (minionId in tierOneMinionsFiltered) {
for (recipe in NEUItems.getRecipes(minionId)) {
- if (recipe !is CraftingRecipe) continue
+ if (!recipe.isCraftingRecipe()) continue
checkOne(recipe, help, minions, minionId)
}
}
}
private fun checkOne(
- recipe: CraftingRecipe,
+ recipe: PrimitiveRecipe,
help: Map<NEUInternalName, Int>,
minions: MutableMap<String, NEUInternalName>,
minionId: NEUInternalName,
) {
- if (recipe.getCachedIngredients().any { help.contains(it.internalItemId.asInternalName()) }) {
- val name = recipe.output.itemStack.name.removeColor()
+ if (recipe.getCachedIngredients().any { help.contains(it.internalName) }) {
+ val name = recipe.output?.internalName?.getItemStackOrNull()?.displayName?.removeColor() ?: return
val abc = name.replace(" I", " 0")
minions[abc] = minionId.replace("_1", "_0")
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt
index c12bafc39..dbec4ea57 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt
@@ -24,7 +24,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.JsonArray
import com.google.gson.JsonObject
-import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe
import net.minecraft.client.Minecraft
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -139,7 +138,7 @@ object MinionCraftHelper {
for (recipe in recipes) {
for (ingredient in recipe.getCachedIngredients()) {
- val ingredientInternalName = ingredient.internalItemId.asInternalName()
+ val ingredientInternalName = ingredient.internalName
if (ingredientInternalName == internalName) return true
val ingredientPrimitive = NEUItems.getPrimitiveMultiplier(ingredientInternalName)
@@ -169,10 +168,10 @@ object MinionCraftHelper {
if (internalName.contains("_GENERATOR_")) {
for (recipe in NEUItems.getRecipes(internalName)) {
- if (recipe !is CraftingRecipe) continue
+ if (!recipe.isCraftingRecipe()) continue
for (ingredient in recipe.getCachedIngredients()) {
- val id = ingredient.internalItemId.asInternalName()
+ val id = ingredient.internalName
if (!id.contains("_GENERATOR_") && !allIngredients.contains(id)) {
allIngredients.add(id)
}
@@ -194,13 +193,12 @@ object MinionCraftHelper {
newDisplay.add(minionName)
val nextMinionId = minionId.addOneToId()
for (recipe in NEUItems.getRecipes(nextMinionId)) {
- if (recipe !is CraftingRecipe) continue
- val output = recipe.output
- val internalItemId = output.internalItemId.asInternalName()
- if (!internalItemId.contains("_GENERATOR_")) continue
+ if (!recipe.isCraftingRecipe()) continue
+ val output = recipe.output ?: continue
+ if (!output.internalName.contains("_GENERATOR_")) continue
val map = mutableMapOf<NEUInternalName, Int>()
- for (input in recipe.inputs) {
- val itemId = input.internalItemId.asInternalName()
+ for (input in recipe.ingredients) {
+ val itemId = input.internalName
if (minionId != itemId) {
val count = input.count.toInt()
val old = map.getOrDefault(itemId, 0)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
index aed4f7e7c..2e8d78966 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
@@ -46,7 +46,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems
-import at.hannibal2.skyhanni.utils.NEUItems.allIngredients
import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
import at.hannibal2.skyhanni.utils.NEUItems.getPrice
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
@@ -250,13 +249,14 @@ object GardenVisitorFeatures {
val ingredients = NEUItems.getRecipes(internalName)
// TODO describe what this line does
- .firstOrNull() { !it.allIngredients().first().internalItemId.contains("PEST") }
- ?.allIngredients() ?: emptySet()
+ .firstOrNull { !it.ingredients.first().internalName.contains("PEST") }
+ ?.ingredients ?: emptySet()
if (ingredients.isEmpty()) return
+ // TODO change key to NEUInternalName
val requiredIngredients = mutableMapOf<String, Int>()
for (ingredient in ingredients) {
- val key = ingredient.internalItemId
+ val key = ingredient.internalName.asString()
requiredIngredients[key] =
requiredIngredients.getOrDefault(key, 0) + ingredient.count.toInt()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt
index f441d17ab..26bfa7f26 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt
@@ -8,14 +8,11 @@ import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.HypixelCommands
-import at.hannibal2.skyhanni.utils.ItemUtils.itemName
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems
-import at.hannibal2.skyhanni.utils.NEUItems.allIngredients
import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
import at.hannibal2.skyhanni.utils.SimpleTimeMark
-import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.entity.player.InventoryPlayer
import net.minecraftforge.fml.common.eventhandler.EventPriority
@@ -74,11 +71,12 @@ object GardenVisitorSupercraft {
private fun getSupercraftForSacks(internalName: NEUInternalName, amount: Int) {
val ingredients = NEUItems.getRecipes(internalName)
// TODO describe what this line does
- .firstOrNull { !it.allIngredients().first().internalItemId.contains("PEST") }
- ?.allIngredients() ?: return
+ .firstOrNull { !it.ingredients.first().internalName.contains("PEST") }
+ ?.ingredients ?: return
+ // TODO change key to NEUInternalName
val ingredientReqs = mutableMapOf<String, Int>()
for (ingredient in ingredients) {
- val key = ingredient.internalItemId
+ val key = ingredient.internalName.asString()
ingredientReqs[key] = ingredientReqs.getOrDefault(key, 0) + ingredient.count.toInt()
}
hasIngredients = true
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt
index 6b841f5a4..8612c9795 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt
@@ -20,12 +20,12 @@ import at.hannibal2.skyhanni.utils.NEUItems.isVanillaItem
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.toPrimitiveStackOrNull
+import at.hannibal2.skyhanni.utils.PrimitiveRecipe
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
-import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.floor
@@ -71,7 +71,7 @@ object CraftableItemList {
val recipes = NEUItems.getRecipes(internalName)
for (recipe in recipes) {
- if (recipe !is CraftingRecipe) continue
+ if (!recipe.isCraftingRecipe()) continue
val renderable = createItemRenderable(recipe, availableMaterial, pricePer, internalName) ?: continue
lines[internalName] = renderable
}
@@ -79,7 +79,7 @@ object CraftableItemList {
}
private fun createItemRenderable(
- recipe: CraftingRecipe,
+ recipe: PrimitiveRecipe,
availableMaterial: Map<NEUInternalName, Long>,
pricePer: MutableMap<NEUInternalName, Double>,
internalName: NEUInternalName,
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt
index 953809b96..81e12f913 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt
@@ -20,13 +20,13 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzRarity
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
-import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull
import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull
import at.hannibal2.skyhanni.utils.NEUItems.getRawCraftCostOrNull
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
+import at.hannibal2.skyhanni.utils.PrimitiveIngredient
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAbilityScrolls
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getArmorDye
@@ -58,7 +58,6 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.hasJalapenoBook
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.hasWoodSingularity
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRecombobulated
import at.hannibal2.skyhanni.utils.StringUtils.allLettersFirstUppercase
-import io.github.moulberry.notenoughupdates.recipes.Ingredient
import io.github.notenoughupdates.moulconfig.observer.Property
import net.minecraft.item.ItemStack
import java.util.Locale
@@ -889,12 +888,12 @@ object EstimatedItemValueCalculator {
val previousTotal = totalPrice
for (ingredients in slot.value) {
- val ingredient = Ingredient(NEUItems.manager, ingredients)
+ val ingredient = PrimitiveIngredient(ingredients)
- totalPrice += if (ingredient.isCoins) {
+ totalPrice += if (ingredient.isCoin()) {
ingredient.count
} else {
- ingredient.internalItemId.asInternalName().getPrice() * ingredient.count
+ ingredient.internalName.getPrice() * ingredient.count
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
index 045ce5bce..32b287cb9 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
@@ -449,7 +449,7 @@ object SkyHanniDebugsAndTests {
}
@SubscribeEvent
- fun onSHowCraftPrice(event: LorenzToolTipEvent) {
+ fun onShowCraftPrice(event: LorenzToolTipEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!debugConfig.showCraftPrice) return
val price = event.itemStack.getInternalNameOrNull()?.getRawCraftCostOrNull() ?: return
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt
index b12f3640e..66775b2d6 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt
@@ -9,18 +9,17 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
import at.hannibal2.skyhanni.utils.NEUItems.getRecipes
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
-import io.github.moulberry.notenoughupdates.recipes.NeuRecipe
object ItemPriceUtils {
fun NEUInternalName.getPrice(
priceSource: ItemPriceSource = ItemPriceSource.BAZAAR_INSTANT_BUY,
- pastRecipes: List<NeuRecipe> = emptyList(),
+ pastRecipes: List<PrimitiveRecipe> = emptyList(),
) = getPriceOrNull(priceSource, pastRecipes) ?: 0.0
fun NEUInternalName.getPriceOrNull(
priceSource: ItemPriceSource = ItemPriceSource.BAZAAR_INSTANT_BUY,
- pastRecipes: List<NeuRecipe> = emptyList(),
+ pastRecipes: List<PrimitiveRecipe> = emptyList(),
): Double? {
when (this) {
NEUInternalName.JASPER_CRYSTAL -> return 0.0
@@ -60,7 +59,7 @@ object ItemPriceUtils {
// NEUItems.manager.auctionManager.getCraftCost(asString())?.craftCost
fun NEUInternalName.getRawCraftCostOrNull(
priceSource: ItemPriceSource = ItemPriceSource.BAZAAR_INSTANT_BUY,
- pastRecipes: List<NeuRecipe> = emptyList(),
+ pastRecipes: List<PrimitiveRecipe> = emptyList(),
): Double? = getRecipes(this).filter { it !in pastRecipes }
.map { it.getRecipePrice(priceSource, pastRecipes + it) }
.filter { it >= 0 }
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index cc1a4362b..ac35c0741 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -7,7 +7,6 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.ItemPriceUtils.getPrice
-import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
@@ -20,7 +19,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.StringUtils.removeResets
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.common.collect.Lists
-import io.github.moulberry.notenoughupdates.recipes.NeuRecipe
import io.github.moulberry.notenoughupdates.util.NotificationHandler
import net.minecraft.client.Minecraft
import net.minecraft.init.Items
@@ -463,19 +461,19 @@ object ItemUtils {
return list
}
- fun neededItems(recipe: NeuRecipe): Map<NEUInternalName, Int> {
+ fun neededItems(recipe: PrimitiveRecipe): Map<NEUInternalName, Int> {
val neededItems = mutableMapOf<NEUInternalName, Int>()
for (ingredient in recipe.ingredients) {
- val material = ingredient.internalItemId.asInternalName()
+ val material = ingredient.internalName
val amount = ingredient.count.toInt()
neededItems.addOrPut(material, amount)
}
return neededItems
}
- fun NeuRecipe.getRecipePrice(
+ fun PrimitiveRecipe.getRecipePrice(
priceSource: ItemPriceSource = ItemPriceSource.BAZAAR_INSTANT_BUY,
- pastRecipes: List<NeuRecipe> = emptyList(),
+ pastRecipes: List<PrimitiveRecipe> = emptyList(),
): Double = neededItems(this).map {
it.key.getPrice(priceSource, pastRecipes) * it.value
}.sum()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index 81eb2968c..34d491cee 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -30,9 +30,6 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates
import io.github.moulberry.notenoughupdates.events.ProfileDataLoadedEvent
import io.github.moulberry.notenoughupdates.overlays.AuctionSearchOverlay
import io.github.moulberry.notenoughupdates.overlays.BazaarSearchOverlay
-import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe
-import io.github.moulberry.notenoughupdates.recipes.Ingredient
-import io.github.moulberry.notenoughupdates.recipes.NeuRecipe
import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery
import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.client.Minecraft
@@ -57,8 +54,8 @@ object NEUItems {
val manager: NEUManager get() = NotEnoughUpdates.INSTANCE.manager
private val multiplierCache = mutableMapOf<NEUInternalName, PrimitiveItemStack>()
- private val recipesCache = mutableMapOf<NEUInternalName, Set<NeuRecipe>>()
- private val ingredientsCache = mutableMapOf<NeuRecipe, Set<Ingredient>>()
+ private val recipesCache = mutableMapOf<NEUInternalName, Set<PrimitiveRecipe>>()
+ private val ingredientsCache = mutableMapOf<PrimitiveRecipe, Set<PrimitiveIngredient>>()
private val itemIdCache = mutableMapOf<Item, List<NEUInternalName>>()
private val hypixelApiGson by lazy {
@@ -183,7 +180,7 @@ object NEUItems {
@Deprecated("Moved to ItemPriceUtils", ReplaceWith(""))
fun NEUInternalName.getPrice(
priceSource: ItemPriceSource = ItemPriceSource.BAZAAR_INSTANT_BUY,
- pastRecipes: List<NeuRecipe> = emptyList(),
+ pastRecipes: List<PrimitiveRecipe> = emptyList(),
): Double = getPriceNew(priceSource, pastRecipes)
@Deprecated("Moved to ItemPriceUtils", ReplaceWith(""))
@@ -198,11 +195,11 @@ object NEUItems {
@Deprecated("Moved to ItemPriceUtils", ReplaceWith(""))
fun NEUInternalName.getPriceOrNull(
priceSource: ItemPriceSource = ItemPriceSource.BAZAAR_INSTANT_BUY,
- pastRecipes: List<NeuRecipe> = emptyList(),
+ pastRecipes: List<PrimitiveRecipe> = emptyList(),
): Double? = this.getPriceOrNullNew(priceSource, pastRecipes)
@Deprecated("Moved to ItemPriceUtils", ReplaceWith(""))
- fun NEUInternalName.getRawCraftCostOrNull(pastRecipes: List<NeuRecipe> = emptyList()): Double? =
+ fun NEUInternalName.getRawCraftCostOrNull(pastRecipes: List<PrimitiveRecipe> = emptyList()): Double? =
getRawCraftCostOrNullNew(ItemPriceSource.BAZAAR_INSTANT_BUY, pastRecipes)
fun NEUInternalName.getItemStackOrNull(): ItemStack? = ItemResolutionQuery(manager)
@@ -309,12 +306,12 @@ object NEUItems {
return internalName.makePrimitiveStack()
}
for (recipe in getRecipes(internalName)) {
- if (recipe !is CraftingRecipe) continue
+ if (!recipe.isCraftingRecipe()) continue
val map = mutableMapOf<NEUInternalName, Int>()
for (ingredient in recipe.getCachedIngredients()) {
val count = ingredient.count.toInt()
- var internalItemId = ingredient.internalItemId.asInternalName()
+ var internalItemId = ingredient.internalName
// ignore cactus green
if (internalName == "ENCHANTED_CACTUS_GREEN".asInternalName() && internalItemId == "INK_SACK-2".asInternalName()) {
internalItemId = "CACTUS".asInternalName()
@@ -356,13 +353,13 @@ object NEUItems {
return result
}
- fun getRecipes(internalName: NEUInternalName): Set<NeuRecipe> {
+ fun getRecipes(internalName: NEUInternalName): Set<PrimitiveRecipe> {
return recipesCache.getOrPut(internalName) {
- manager.getRecipesFor(internalName.asString())
+ PrimitiveRecipe.convertMultiple(manager.getRecipesFor(internalName.asString())).toSet()
}
}
- fun NeuRecipe.getCachedIngredients() = ingredientsCache.getOrPut(this) { allIngredients() }
+ fun PrimitiveRecipe.getCachedIngredients() = ingredientsCache.getOrPut(this) { ingredients }
fun neuHasFocus(): Boolean {
if (AuctionSearchOverlay.shouldReplace()) return true
@@ -391,6 +388,4 @@ object NEUItems {
val jsonObject = ConfigManager.gson.fromJson(jsonString, JsonObject::class.java)
return manager.jsonToStack(jsonObject, false)
}
-
- fun NeuRecipe.allIngredients(): Set<Ingredient> = ingredients
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/PrimitiveIngredient.kt b/src/main/java/at/hannibal2/skyhanni/utils/PrimitiveIngredient.kt
new file mode 100644
index 000000000..e8d1edefc
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/PrimitiveIngredient.kt
@@ -0,0 +1,26 @@
+package at.hannibal2.skyhanni.utils
+
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.SKYBLOCK_COIN
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
+import io.github.moulberry.notenoughupdates.recipes.Ingredient
+
+class PrimitiveIngredient(val internalName: NEUInternalName, val count: Double = 1.0) {
+
+ constructor(internalName: NEUInternalName, count: Int) : this(internalName, count.toDouble())
+
+ constructor(ingredientIdentifier: String) : this(
+ ingredientIdentifier.substringBefore(':').asInternalName(),
+ ingredientIdentifier.substringAfter(':').toDoubleOrNull() ?: 1.0,
+ )
+
+ companion object {
+ fun coinIngredient(count: Double = 1.0) = PrimitiveIngredient(SKYBLOCK_COIN, count)
+
+ fun fromNeuIngredient(neuIngredient: Ingredient) = PrimitiveIngredient(neuIngredient.internalItemId.asInternalName(), neuIngredient.count)
+ }
+
+ fun isCoin() = internalName == SKYBLOCK_COIN
+
+
+ override fun toString() = "$internalName x$count"
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/PrimitiveRecipe.kt b/src/main/java/at/hannibal2/skyhanni/utils/PrimitiveRecipe.kt
new file mode 100644
index 000000000..f064183ba
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/PrimitiveRecipe.kt
@@ -0,0 +1,53 @@
+package at.hannibal2.skyhanni.utils
+
+import at.hannibal2.skyhanni.utils.RecipeType.CRAFTING
+import io.github.moulberry.notenoughupdates.recipes.EssenceUpgrades
+import io.github.moulberry.notenoughupdates.recipes.ForgeRecipe
+import io.github.moulberry.notenoughupdates.recipes.ItemShopRecipe
+import io.github.moulberry.notenoughupdates.recipes.KatRecipe
+import io.github.moulberry.notenoughupdates.recipes.MobLootRecipe
+import io.github.moulberry.notenoughupdates.recipes.NeuRecipe
+import io.github.moulberry.notenoughupdates.recipes.VillagerTradeRecipe
+
+data class PrimitiveRecipe(
+ val ingredients: Set<PrimitiveIngredient>,
+ val outputs: Set<PrimitiveIngredient>,
+ val recipeType: RecipeType,
+) {
+
+ val output by lazy { outputs.firstOrNull() }
+
+ companion object {
+ fun fromNeuRecipe(neuRecipe: NeuRecipe): PrimitiveRecipe {
+ val ingredients = neuRecipe.ingredients.map { PrimitiveIngredient.fromNeuIngredient(it) }.toSet()
+ val outputs = neuRecipe.outputs.map { PrimitiveIngredient.fromNeuIngredient(it) }.toSet()
+
+ val recipeType = when (neuRecipe::class.java) {
+ ForgeRecipe::class.java -> RecipeType.FORGE
+ VillagerTradeRecipe::class.java -> RecipeType.TRADE
+ EssenceUpgrades::class.java -> RecipeType.ESSENCE
+ MobLootRecipe::class.java -> RecipeType.MOB_DROP
+ ItemShopRecipe::class.java -> RecipeType.NPC_SHOP
+ KatRecipe::class.java -> RecipeType.KAT_UPGRADE
+ else -> CRAFTING
+ }
+
+ return PrimitiveRecipe(ingredients, outputs, recipeType)
+ }
+
+ fun convertMultiple(neuRecipes: Collection<NeuRecipe>) = neuRecipes.map { fromNeuRecipe(it) }
+ }
+
+ fun isCraftingRecipe() = this.recipeType == CRAFTING
+}
+
+enum class RecipeType {
+ FORGE,
+ TRADE,
+ MOB_DROP,
+ NPC_SHOP,
+ KAT_UPGRADE,
+ ESSENCE,
+ CRAFTING,
+ ;
+}