Fix terminal appearing to change buffer mode to from_network when insertion fails

This commit is contained in:
Shadowfacts 2021-03-28 13:48:56 -04:00
parent 4fa5a12746
commit e4662b0f6f
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 9 additions and 1 deletions

View File

@ -109,7 +109,15 @@ abstract class AbstractTerminalBlockEntity(type: BlockEntityType<*>): DeviceBloc
}
override fun doHandleItemStack(packet: ItemStackPacket): ItemStack {
val remaining = internalBuffer.insert(packet.stack, TerminalBufferInventory.Mode.FROM_NETWORK)
val mode =
if (packet.bounceCount > 0) {
// if this stack bounced from an inventory, that means we previously tried to send it to the network, so retry
TerminalBufferInventory.Mode.TO_NETWORK
} else {
TerminalBufferInventory.Mode.FROM_NETWORK
}
val remaining = internalBuffer.insert(packet.stack, mode)
// this happens outside the normal update loop because by receiving the item stack packet
// we "know" how much the count in the source inventory has changed