diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoSuitInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoSuitInventoryMenu.kt index 847af7831..3d5d3c2ad 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoSuitInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoSuitInventoryMenu.kt @@ -144,6 +144,39 @@ class ExoSuitInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen return true } + override fun quickMoveStack(ply: Player, slotIndex: Int): ItemStack { + if (slots[slotIndex].item.isEmpty || !slots[slotIndex].mayPickup(ply)) { + return ItemStack.EMPTY + } + + if (combinedInventorySlots.any { it.index == slotIndex }) { + val item = slots[slotIndex].item + val copy = item.copy() + moveItemStackTo(item, hotbarSlots) + return copy + } else if (hotbarSlots.any { it.index == slotIndex } || craftingSlots.any { it.index == slotIndex }) { + val item = slots[slotIndex].item + val copy = item.copy() + moveItemStackTo(item, combinedInventorySlots) + return copy + } else if (slotIndex == craftingResultSlot.index) { + val item = craftingResultSlot.item + val leftover = moveItemStackToSlots(item, combinedInventorySlots, simulate = true) + + if (leftover.isEmpty) { + val copy = item.copy() + moveItemStackToSlots(item, combinedInventorySlots, simulate = false) + item.count = 0 + craftingResultSlot.onTake(ply, copy) + return copy + } + + return ItemStack.EMPTY + } + + return ItemStack.EMPTY + } + companion object : ContainerSynchronizer { // ServerPlayer#nextContainerCounter // this.containerCounter = this.containerCounter % 100 + 1; diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 0cedb260d..0f488284c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -222,20 +222,12 @@ abstract class MatteryMenu @JvmOverloads protected constructor( var moveToPlayer: Boolean? = null - for (slot in storageSlots) { - if (slot.index == slotIndex) { - moveToPlayer = true - break - } + if (storageSlots.any { it.index == slotIndex }) { + moveToPlayer = true } - if (moveToPlayer == null) { - for (slot in playerInventorySlots) { - if (slot.index == slotIndex) { - moveToPlayer = false - break - } - } + if (moveToPlayer == null && playerInventorySlots.any { it.index == slotIndex }) { + moveToPlayer = false } if (moveToPlayer == null) {