Fix not being able to extract items with network counts > 127 from

terminal
This commit is contained in:
Shadowfacts 2021-02-17 23:18:15 -05:00
parent c9fe6400f0
commit 9d16a7e5cd
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 8 additions and 1 deletions

View File

@ -26,7 +26,14 @@ object C2STerminalRequestItem: ServerReceiver {
val buf = PacketByteBufs.create()
buf.writeIdentifier(terminal.world!!.registryKey.value)
buf.writeBlockPos(terminal.pos)
buf.writeItemStack(stack)
// Force the count of the stack to be 1 before serializing for the network because
// PacketByteBuf serializes the stack count as a byte. Otherwise counts > 127 will result in
// an overflow and be negative on the receiving side.
val stackCopy = stack.copy()
stackCopy.count = 1
buf.writeItemStack(stackCopy)
buf.writeVarInt(amount)
return ClientPlayNetworking.createC2SPacket(CHANNEL, buf)
}