don't try to serialize optional fields

This commit is contained in:
əlemi 2021-11-24 11:23:56 +01:00
parent d1d1eb5ca1
commit 5cc4c8d844

View file

@ -38,6 +38,7 @@ class Packet:
buf = io.BytesIO()
VarInt.write(self.id, buf)
for name, t in self.definition:
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