Terminal: Add right-clicking to request half a stack
This commit is contained in:
parent
37692aac7d
commit
14125143dc
|
@ -8,6 +8,7 @@ import net.minecraft.entity.player.PlayerInventory
|
|||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.Identifier
|
||||
import net.shadowfacts.phycon.PhysicalConnectivity
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
|
@ -57,16 +58,25 @@ class TerminalContainer(syncId: Int, playerInv: PlayerInventory, val terminal: T
|
|||
}
|
||||
|
||||
override fun onSlotClick(slotId: Int, clickData: Int, actionType: SlotActionType, player: PlayerEntity): ItemStack {
|
||||
if (actionType == SlotActionType.QUICK_MOVE) {
|
||||
if (slotId < 54) {
|
||||
if (slotId in 0 until 54) {
|
||||
// the slot clicked was one of the network stacks
|
||||
val slot = slotList[slotId]
|
||||
if (actionType == SlotActionType.QUICK_MOVE) {
|
||||
val stack = slotList[slotId].stack
|
||||
if (!stack.isEmpty && !player.world.isClient) {
|
||||
terminal.requestItem(stack, min(stack.count, stack.maxCount))
|
||||
}
|
||||
return ItemStack.EMPTY
|
||||
} else if (actionType == SlotActionType.PICKUP && clickData == 1) {
|
||||
if (clickData == 1) {
|
||||
// right click, request half stack
|
||||
val stack = slotList[slotId].stack
|
||||
if (!stack.isEmpty && !player.world.isClient) {
|
||||
terminal.requestItem(stack, ceil(min(stack.count, stack.maxCount) / 2f).toInt())
|
||||
}
|
||||
} else {
|
||||
// todo: left click, show amount dialog
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
return super.onSlotClick(slotId, clickData, actionType, player)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue