diff options
| author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-09-07 21:32:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-07 21:32:20 +0200 |
| commit | 321188e2828284484718a78ecaf9e7a98905d658 (patch) | |
| tree | 6f22a6ad68977d6e20c53cc7f559f501dadb76cc /src/main/java/at/hannibal2/skyhanni/features/mining | |
| parent | e657a74d8ef21bfc05873b5a2dcd73b6c1b8503f (diff) | |
| download | skyhanni-321188e2828284484718a78ecaf9e7a98905d658.tar.gz skyhanni-321188e2828284484718a78ecaf9e7a98905d658.tar.bz2 skyhanni-321188e2828284484718a78ecaf9e7a98905d658.zip | |
Backend: Cleanup Forge Gfs (#2434)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/mining')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/mining/ForgeGfs.kt | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/ForgeGfs.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/ForgeGfs.kt index 28f117832..995198674 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/ForgeGfs.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/ForgeGfs.kt @@ -8,12 +8,13 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.CollectionUtils +import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull -import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.player.inventory.ContainerLocalMenu @@ -78,27 +79,15 @@ object ForgeGfs { // Search for the first 4 columns only // Normally would be 3, but the gemstone mixture is the only one that overflows to 4 - for (i in 0..53) { - if (i % 9 <= 3) { - val currentItem = event.container.getSlot(i).stack - val amount = currentItem.stackSize - val currItemInternalName = currentItem.getInternalNameOrNull() ?: continue - if (SackAPI.sackListInternalNames.contains(currItemInternalName.asString())) { - itemMap.addAndFold(currItemInternalName, amount) - } + for (i in CollectionUtils.takeColumn(0, 53, 0, 4)) { + val currentItem = event.container.getSlot(i).stack + val currItemInternalName = currentItem.getInternalNameOrNull() ?: continue + if (SackAPI.sackListInternalNames.contains(currItemInternalName.asString())) { + itemMap.addOrPut(currItemInternalName, currentItem.stackSize) } } - for ((internalName, amount) in itemMap) { - val getItYet = GetFromSackAPI.getFromSack(internalName, amount) - if (!getItYet) { - ChatUtils.chat("§cFailed to get $amount ${internalName.itemNameWithoutColor} from sacks.") - } - } - } - - private fun MutableMap<NEUInternalName, Int>.addAndFold(key: NEUInternalName, value: Int) { - this[key] = this.getOrDefault(key, 0) + value + GetFromSackAPI.getFromSack(itemMap.map { it.key.makePrimitiveStack(it.value) }) } fun isEnabled() = LorenzUtils.inSkyBlock && config.forgeGfs |
