class SpawnPlayerPacket(Packet): @staticmethod def get_id(context): return 0x04 if context.protocol_version >= 721 else \ 0x05 if context.protocol_version >= 67 else \ 0x0C packet_name = 'spawn player' get_definition = staticmethod(lambda context: [ {'entity_id': VarInt}, {'player_UUID': UUID}, {'x': Double} if context.protocol_version >= 100 else {'x': FixedPoint(Integer)}, {'y': Double} if context.protocol_version >= 100 else {'y': FixedPoint(Integer)}, {'z': Double} if context.protocol_version >= 100 else {'z': FixedPoint(Integer)}, {'yaw': Angle}, {'pitch': Angle}, {'current_item': Short} if context.protocol_version <= 49 else {}, # TODO: read entity metadata (protocol < 550) ]) # Access the 'x', 'y', 'z' fields as a Vector tuple. position = multi_attribute_alias(Vector, 'x', 'y', 'z') # Access the 'yaw', 'pitch' fields as a Direction tuple. look = multi_attribute_alias(Direction, 'yaw', 'pitch') # Access the 'x', 'y', 'z', 'yaw', 'pitch' fields as a PositionAndLook. # NOTE: modifying the object retrieved from this property will not change # the packet; it can only be changed by attribute or property assignment. position_and_look = multi_attribute_alias( PositionAndLook, 'x', 'y', 'z', 'yaw', 'pitch')
def get_definition(context): delta_type = FixedPoint(Short, 12) \ if context.protocol_version >= 106 else \ FixedPoint(Byte) return [ {'entity_id': VarInt}, {'delta_x_float': delta_type}, {'delta_y_float': delta_type}, {'delta_z_float': delta_type}, {'on_ground': Boolean}, ]
class SpawnPlayerPacket(Packet): @staticmethod def get_id(context): return (0x04 if context.protocol_later_eq(721) else 0x05 if context.protocol_later_eq(67) else 0x0C) packet_name = "spawn player" get_definition = staticmethod(lambda context: [ { "entity_id": VarInt }, { "player_UUID": UUID }, { "x": Double } if context.protocol_later_eq(100) else { "x": FixedPoint(Integer) }, { "y": Double } if context.protocol_later_eq(100) else { "y": FixedPoint(Integer) }, { "z": Double } if context.protocol_later_eq(100) else { "z": FixedPoint(Integer) }, { "yaw": Angle }, { "pitch": Angle }, { "current_item": Short } if context.protocol_earlier_eq(49) else {}, # TODO: read entity metadata (protocol < 550) ]) # Access the 'x', 'y', 'z' fields as a Vector tuple. position = multi_attribute_alias(Vector, "x", "y", "z") # Access the 'yaw', 'pitch' fields as a Direction tuple. look = multi_attribute_alias(Direction, "yaw", "pitch") # Access the 'x', 'y', 'z', 'yaw', 'pitch' fields as a PositionAndLook. # NOTE: modifying the object retrieved from this property will not change # the packet; it can only be changed by attribute or property assignment. position_and_look = multi_attribute_alias(PositionAndLook, "x", "y", "z", "yaw", "pitch")
def get_definition(context): delta_type = (FixedPoint(Short, 12) if context.protocol_later_eq(106) else FixedPoint(Byte)) return [ { "entity_id": VarInt }, { "delta_x_float": delta_type }, { "delta_y_float": delta_type }, { "delta_z_float": delta_type }, { "on_ground": Boolean }, ]