Fix not being able to extract items with network counts > 127 from
terminal
This commit is contained in:
parent
c9fe6400f0
commit
9d16a7e5cd
|
@ -26,7 +26,14 @@ object C2STerminalRequestItem: ServerReceiver {
|
||||||
val buf = PacketByteBufs.create()
|
val buf = PacketByteBufs.create()
|
||||||
buf.writeIdentifier(terminal.world!!.registryKey.value)
|
buf.writeIdentifier(terminal.world!!.registryKey.value)
|
||||||
buf.writeBlockPos(terminal.pos)
|
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)
|
buf.writeVarInt(amount)
|
||||||
return ClientPlayNetworking.createC2SPacket(CHANNEL, buf)
|
return ClientPlayNetworking.createC2SPacket(CHANNEL, buf)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue