Improve metadata and auxiliary methods of existing packets.
* Add multi-attribute aliases to some packets, for user convenience. * Add support for writing PlayerListItemPacket. * Add 'fields' attributes to manually-read/written packet classes, implementing 'field_string' where appropriate to allow enable the default __repr__ implementation. * Modify data constructors where appropriate so that __repr__ implementations match their constructor protocols. * Improve comments on type aliases within packet classes. * Add/modify tests to cover the new functionality.
This commit is contained in:
1 parent
234e57716c
commit
e3d2b1a368
14 files changed
+389
-158
No files matched your search
@@ -15,7 +15,13 @@ class FacePlayerPacket(Packet):
|
||||
|
||||
packet_name = 'face player'
|
||||
|
||||
# Access the 'x', 'y', 'z' fields as a Vector.
|
||||
@property
|
||||
def fields(self):
|
||||
return ('origin', 'x', 'y', 'z', 'entity_id', 'entity_origin') \
|
||||
if self.context.protocol_version >= 353 else \
|
||||
('entity_id', 'x', 'y', 'z')
|
||||
|
||||
# Access the 'x', 'y', 'z' fields as a Vector tuple.
|
||||
target = multi_attribute_alias(Vector, 'x', 'y', 'z')
|
||||
|
||||
def read(self, file_object):
|
||||
|
||||
Reference in new issue
Block a user