From 5cc4c8d84435ce573aaae03d5b53ce2d2cae208c Mon Sep 17 00:00:00 2001 From: alemidev Date: Wed, 24 Nov 2021 11:23:56 +0100 Subject: [PATCH] don't try to serialize optional fields --- aiocraft/mc/packet.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aiocraft/mc/packet.py b/aiocraft/mc/packet.py index 76b4908..1c5ee98 100644 --- a/aiocraft/mc/packet.py +++ b/aiocraft/mc/packet.py @@ -38,7 +38,8 @@ class Packet: buf = io.BytesIO() VarInt.write(self.id, buf) for name, t in self.definition: - t.write(getattr(self, name, None), buf) + if getattr(self, name, None) is not None: # minecraft proto has no null type: this is an optional field left unset + t.write(getattr(self, name, None), buf) buf.seek(0) return buf