From 84d38008e0a02ee886ac31f7ccbbb9fe57b8932f Mon Sep 17 00:00:00 2001 From: alemidev Date: Fri, 17 Dec 2021 13:35:41 +0100 Subject: [PATCH] small improvements to packet --- aiocraft/mc/packet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aiocraft/mc/packet.py b/aiocraft/mc/packet.py index bd65721..5de2a2d 100644 --- a/aiocraft/mc/packet.py +++ b/aiocraft/mc/packet.py @@ -6,7 +6,7 @@ from typing import Tuple, Dict, Any from .types import Type, VarInt class Packet: - __slots__ = 'definition', '_processed', '_proto', '_state' + __slots__ = 'id', 'definition', '_processed', '_proto', '_state' id : int definition : Tuple[Tuple[str, Type]] @@ -57,12 +57,12 @@ class Packet: return False return True - def __str__(self) -> str: obj : Dict[str, Any] = {} # could be done with dict comp but the _ key gets put last :( obj["_"] = self.__class__.__name__ obj["_proto"] = self._proto obj["_state"] = self._state + obj["_id"] = f"0x{self.id:02x}" for key, t in self.definition: obj[key] = getattr(self, key, None) return json.dumps(obj, indent=2, default=str)