def read(self, file_object): action_id = VarInt.read(file_object) self.action_type = PlayerListItemPacket.Action.type_from_id(action_id) action_count = VarInt.read(file_object) self.actions = [] for i in range(action_count): action = self.action_type() action.read(file_object) self.actions.append(action)
def _read(self, file_object): self.name = String.read(file_object) prop_count = VarInt.read(file_object) self.properties = [] for i in range(prop_count): property = PlayerListItemPacket.PlayerProperty() property.read(file_object) self.properties.append(property) self.gamemode = VarInt.read(file_object) self.ping = VarInt.read(file_object) has_display_name = Boolean.read(file_object) if has_display_name: self.display_name = String.read(file_object) else: self.display_name = None
def read(self, file_object): self.message_id = VarInt.read(file_object) self.successful = Boolean.read(file_object) if self.successful: self.data = TrailingByteArray.read(file_object) else: self.data = None
def read(self, file_object): self.chunk_x = Integer.read(file_object) self.chunk_z = Integer.read(file_object) records_count = VarInt.read(file_object) self.records = [] for i in range(records_count): record = self.Record() record.read(file_object) self.records.append(record)
def read(self, file_object): self.map_id = VarInt.read(file_object) self.scale = Byte.read(file_object) if self.context.protocol_version >= 107: self.is_tracking_position = Boolean.read(file_object) else: self.is_tracking_position = True if self.context.protocol_version >= 452: self.is_locked = Boolean.read(file_object) else: self.is_locked = False icon_count = VarInt.read(file_object) self.icons = [] for i in range(icon_count): if self.context.protocol_version >= 373: type = VarInt.read(file_object) else: type, direction = divmod(UnsignedByte.read(file_object), 16) x = Byte.read(file_object) z = Byte.read(file_object) if self.context.protocol_version >= 373: direction = UnsignedByte.read(file_object) if self.context.protocol_version >= 364: has_name = Boolean.read(file_object) display_name = String.read(file_object) if has_name else None else: display_name = None icon = MapPacket.MapIcon(type, direction, (x, z), display_name) self.icons.append(icon) self.width = UnsignedByte.read(file_object) if self.width: self.height = UnsignedByte.read(file_object) x = Byte.read(file_object) z = Byte.read(file_object) self.offset = (x, z) self.pixels = VarIntPrefixedByteArray.read(file_object) else: self.height = 0 self.offset = None self.pixels = None
def read(self, file_object): self.entity_id = VarInt.read(file_object) if self.context.protocol_version >= 49: self.object_uuid = UUID.read(file_object) if self.context.protocol_version >= 458: self.type_id = VarInt.read(file_object) else: self.type_id = Byte.read(file_object) xyz_type = Double if self.context.protocol_version >= 100 else Integer for attr in 'x', 'y', 'z': setattr(self, attr, xyz_type.read(file_object)) for attr in 'pitch', 'yaw': setattr(self, attr, Angle.read(file_object)) self.data = Integer.read(file_object) if self.context.protocol_version >= 49 or self.data > 0: for attr in 'velocity_x', 'velocity_y', 'velocity_z': setattr(self, attr, Short.read(file_object))
def read(self, file_object): if self.context.protocol_version >= 353: self.origin = VarInt.read(file_object) self.x = Double.read(file_object) self.y = Double.read(file_object) self.z = Double.read(file_object) is_entity = Boolean.read(file_object) if is_entity: # If the entity given by entity ID cannot be found, # this packet should be treated as if is_entity was false. self.entity_id = VarInt.read(file_object) self.entity_origin = VarInt.read(file_object) else: self.entity_id = None else: # Protocol version 352 is_entity = Boolean.read(file_object) self.entity_id = VarInt.read(file_object) if is_entity else None if not is_entity: self.x = Double.read(file_object) self.y = Double.read(file_object) self.z = Double.read(file_object)
def read(self, file_object): event_id = VarInt.read(file_object) self.event = CombatEventPacket.EventType.type_from_id(event_id)() self.event.read(file_object)
def read(self, file_object): self.player_id = VarInt.read(file_object) self.entity_id = Integer.read(file_object) self.message = String.read(file_object)
def read(self, file_object): self.duration = VarInt.read(file_object) self.entity_id = Integer.read(file_object)
def read(self, file_object): h_position = UnsignedByte.read(file_object) self.x, self.z = h_position >> 4, h_position & 0xF self.y = UnsignedByte.read(file_object) self.block_state_id = VarInt.read(file_object)
def _read(self, file_object): self.ping = VarInt.read(file_object)
def _read(self, file_object): self.gamemode = VarInt.read(file_object)