only include non-None fields when making packets

There is no 'null' type in MC proto, so a None means
that said attr was not set
This commit is contained in:
əlemi 2022-01-14 16:22:38 +01:00
parent 0216be7c4d
commit 8f92743454

View file

@ -23,7 +23,8 @@ class Packet:
self.definition = self._definitions[proto] self.definition = self._definitions[proto]
self.id = self._ids[proto] self.id = self._ids[proto]
for name, t in self.definition: for name, t in self.definition:
setattr(self, name, t.pytype(kwargs[name]) if name in kwargs else None) if name in kwargs and kwargs[name] is not None:
setattr(self, name, t.pytype(kwargs[name]))
@property @property
def processed(self) -> Event: def processed(self) -> Event: