don't try to serialize optional fields
This commit is contained in:
parent
d1d1eb5ca1
commit
5cc4c8d844
1 changed files with 2 additions and 1 deletions
|
@ -38,7 +38,8 @@ class Packet:
|
||||||
buf = io.BytesIO()
|
buf = io.BytesIO()
|
||||||
VarInt.write(self.id, buf)
|
VarInt.write(self.id, buf)
|
||||||
for name, t in self.definition:
|
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)
|
buf.seek(0)
|
||||||
return buf
|
return buf
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue