aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/garden
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-09-24 10:27:50 +0200
committerGitHub <noreply@github.com>2024-09-24 10:27:50 +0200
commit1e9764d1d1209177d4a939a9b812931a7d49a926 (patch)
treeb903d47fb7f4f23db60211a29419a06863982dd5 /src/main/java/at/hannibal2/skyhanni/features/garden
parent04d2530a67ef9ae2b877a448e15ce16fadd4c25b (diff)
downloadskyhanni-1e9764d1d1209177d4a939a9b812931a7d49a926.tar.gz
skyhanni-1e9764d1d1209177d4a939a9b812931a7d49a926.tar.bz2
skyhanni-1e9764d1d1209177d4a939a9b812931a7d49a926.zip
Backend: PrimitiveIngredient changes and code cleanup (#2576)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt14
2 files changed, 13 insertions, 14 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 2e8d78966..70392bb46 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
@@ -29,6 +29,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
+import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.ConfigUtils
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.HypixelCommands
@@ -51,6 +52,7 @@ import at.hannibal2.skyhanni.utils.NEUItems.getPrice
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
+import at.hannibal2.skyhanni.utils.PrimitiveIngredient.Companion.toPrimitiveItemStacks
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
@@ -253,16 +255,13 @@ object GardenVisitorFeatures {
?.ingredients ?: emptySet()
if (ingredients.isEmpty()) return
- // TODO change key to NEUInternalName
- val requiredIngredients = mutableMapOf<String, Int>()
- for (ingredient in ingredients) {
- val key = ingredient.internalName.asString()
- requiredIngredients[key] =
- requiredIngredients.getOrDefault(key, 0) + ingredient.count.toInt()
+ val requiredIngredients = mutableMapOf<NEUInternalName, Int>()
+ for ((key, count) in ingredients.toPrimitiveItemStacks()) {
+ requiredIngredients.addOrPut(key, count)
}
var hasIngredients = true
for ((key, value) in requiredIngredients) {
- val sackItem = key.asInternalName().getAmountInSacks()
+ val sackItem = key.getAmountInSacks()
if (sackItem < value * (amount - amountInSacks)) {
hasIngredients = false
break
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 f2e4f80fb..9b14483dc 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
@@ -7,12 +7,14 @@ import at.hannibal2.skyhanni.events.garden.visitor.VisitorOpenEvent
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.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.ItemUtils
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.getItemStack
+import at.hannibal2.skyhanni.utils.PrimitiveIngredient.Companion.toPrimitiveItemStacks
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraft.entity.player.InventoryPlayer
import net.minecraftforge.fml.common.eventhandler.EventPriority
@@ -73,15 +75,13 @@ object GardenVisitorSupercraft {
// TODO describe what this line does
.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.internalName.asString()
- ingredientReqs[key] = ingredientReqs.getOrDefault(key, 0) + ingredient.count.toInt()
+ val requiredIngredients = mutableMapOf<NEUInternalName, Int>()
+ for ((key, count) in ingredients.toPrimitiveItemStacks()) {
+ requiredIngredients.addOrPut(key, count)
}
hasIngredients = true
- for ((key, value) in ingredientReqs) {
- val sackItem = key.asInternalName().getAmountInSacks()
+ for ((key, value) in requiredIngredients) {
+ val sackItem = key.getAmountInSacks()
lastSuperCraftMaterial = internalName.asString()
if (sackItem < value * amount) {
hasIngredients = false