Quick moving in exosuit inventory

This commit is contained in:
DBotThePony 2022-08-31 14:25:43 +07:00
parent b00182fc6e
commit c8c4e2931f
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 37 additions and 12 deletions

View File

@ -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;

View File

@ -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) {