aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt22
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
+ }
+ }
}