Quick moving in exosuit inventory
This commit is contained in:
parent
b00182fc6e
commit
c8c4e2931f
@ -144,6 +144,39 @@ class ExoSuitInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
|
|||||||
return true
|
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 {
|
companion object : ContainerSynchronizer {
|
||||||
// ServerPlayer#nextContainerCounter
|
// ServerPlayer#nextContainerCounter
|
||||||
// this.containerCounter = this.containerCounter % 100 + 1;
|
// this.containerCounter = this.containerCounter % 100 + 1;
|
||||||
|
@ -222,20 +222,12 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
|
|||||||
|
|
||||||
var moveToPlayer: Boolean? = null
|
var moveToPlayer: Boolean? = null
|
||||||
|
|
||||||
for (slot in storageSlots) {
|
if (storageSlots.any { it.index == slotIndex }) {
|
||||||
if (slot.index == slotIndex) {
|
|
||||||
moveToPlayer = true
|
moveToPlayer = true
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moveToPlayer == null) {
|
if (moveToPlayer == null && playerInventorySlots.any { it.index == slotIndex }) {
|
||||||
for (slot in playerInventorySlots) {
|
|
||||||
if (slot.index == slotIndex) {
|
|
||||||
moveToPlayer = false
|
moveToPlayer = false
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moveToPlayer == null) {
|
if (moveToPlayer == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user