diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-03-12 18:04:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-12 18:04:56 +0100 |
| commit | b808a6aea1ba28ffd10712e7586b6f0d6cc1804a (patch) | |
| tree | 1c4b9f8eacd97718b4042393a39c0ccbccf8dfa9 /src/main/java/at/hannibal2/skyhanni/utils | |
| parent | 9f1ba8207e8ae14da50058eeaaf0eb750b530dfa (diff) | |
| download | skyhanni-b808a6aea1ba28ffd10712e7586b6f0d6cc1804a.tar.gz skyhanni-b808a6aea1ba28ffd10712e7586b6f0d6cc1804a.tar.bz2 skyhanni-b808a6aea1ba28ffd10712e7586b6f0d6cc1804a.zip | |
Internal Change: Code cleanup ContainerChest getAllItems (#1047)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt index c0b5e04df..3566761b2 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt @@ -80,4 +80,26 @@ object InventoryUtils { countItemsInLowerInventory { it.getInternalNameOrNull() == name } fun isItemInInventory(name: NEUInternalName) = getAmountOfItemInInventory(name) > 0 + + fun ContainerChest.getUpperItems(): Map<Slot, ItemStack> = buildMap { + for ((slot, stack) in getAllItems()) { + if (slot.slotNumber != slot.slotIndex) continue + this[slot] = stack + } + } + + fun ContainerChest.getLowerItems(): Map<Slot, ItemStack> = buildMap { + for ((slot, stack) in getAllItems()) { + if (slot.slotNumber == slot.slotIndex) continue + this[slot] = stack + } + } + + fun ContainerChest.getAllItems(): Map<Slot, ItemStack> = buildMap { + for (slot in inventorySlots) { + if (slot == null) continue + val stack = slot.stack ?: continue + this[slot] = stack + } + } } |
