aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorPaloys <40764414+Paloys@users.noreply.github.com>2024-05-26 15:54:48 +0200
committerGitHub <noreply@github.com>2024-05-26 15:54:48 +0200
commitbbf8a530599f84923167ceeab195a39205fa5131 (patch)
tree8250e123c280594ac71d06376bbd71a7016dd73f /src/main/java
parent6396e78aef1b0e712968931b78d422deae3e08b0 (diff)
downloadskyhanni-bbf8a530599f84923167ceeab195a39205fa5131.tar.gz
skyhanni-bbf8a530599f84923167ceeab195a39205fa5131.tar.bz2
skyhanni-bbf8a530599f84923167ceeab195a39205fa5131.zip
Feature: Added a "Craftable!" message to the garden visitor shopping list when craftable from sacks (#1891)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt23
1 files changed, 23 insertions, 0 deletions
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 aeb049417..7dcd156a1 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
@@ -43,6 +43,7 @@ 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
@@ -206,10 +207,32 @@ object GardenVisitorFeatures {
}
if (config.shoppingList.showSackCount) {
+ var amountInSacks = 0
internalName.getAmountInSacksOrNull()?.let {
+ amountInSacks = it
val textColour = if (it >= amount) "a" else "e"
list.add(" §7(§${textColour}x${it.addSeparators()} §7in sacks)")
}
+ val ingredients = NEUItems.getRecipes(internalName)
+ // TODO describe what this line does
+ .firstOrNull() { !it.allIngredients().first().internalItemId.contains("PEST") }
+ ?.allIngredients() ?: return
+ val requiredIngredients = mutableMapOf<String, Int>()
+ for (ingredient in ingredients) {
+ val key = ingredient.internalItemId
+ requiredIngredients[key] = requiredIngredients.getOrDefault(key, 0) + ingredient.count.toInt()
+ }
+ var hasIngredients = true
+ for ((key, value) in requiredIngredients) {
+ val sackItem = key.asInternalName().getAmountInSacks()
+ if (sackItem < value * (amount - amountInSacks)) {
+ hasIngredients = false
+ break
+ }
+ }
+ if (hasIngredients) {
+ list.add(" §7(§aCraftable!§7)")
+ }
}
add(list)