def read(self, file_object): self.transaction_id = VarInt.read(file_object) \ if self.context.protocol_later_eq(351) else None self.text = String.read(file_object) if self.context.protocol_earlier_eq(350): self.assume_command = Boolean.read(file_object) \ if self.context.protocol_later_eq(95) else None has_position = Boolean.read(file_object) if has_position: self.looked_at_block = Position.read(file_object)
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.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 icon_count = VarInt.read(file_object) self.icons = [] for i in range(icon_count): type, direction = divmod(UnsignedByte.read(file_object), 16) x = Byte.read(file_object) z = Byte.read(file_object) icon = MapPacket.MapIcon(type, direction, (x, z)) 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.map_id = VarInt.read(file_object) self.scale = Byte.read(file_object) if self.context.protocol_in_range(107, PRE | 6): self.is_tracking_position = Boolean.read(file_object) elif self.context.protocol_earlier(107): self.is_tracking_position = True if self.context.protocol_later_eq(452): self.is_locked = Boolean.read(file_object) else: self.is_locked = False if self.context.protocol_later_eq(PRE | 6): self.is_tracking_position = Boolean.read(file_object) icon_count = VarInt.read(file_object) self.icons = [] for i in range(icon_count): if self.context.protocol_later_eq(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_later_eq(373): direction = UnsignedByte.read(file_object) if self.context.protocol_later_eq(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.name = String.read(file_object) self.value = String.read(file_object) is_signed = Boolean.read(file_object) if is_signed: self.signature = String.read(file_object) else: self.signature = None
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) self.type = Type(VarInt.read(file_object)) if self.type == Type.INTERACT_AT: self.x = Float.read(file_object) self.y = Float.read(file_object) self.z = Float.read(file_object) if self.type == Type.INTERACT or self.type == Type.INTERACT_AT: self.hand = VarInt.read(file_object) self.sneaking = Boolean.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): # print('Reading chunk packet...') self.x = Integer.read(file_object) self.z = Integer.read(file_object) self.gu_continuous = Boolean.read(file_object) self.bitmask = VarInt.read(file_object) self.data_length = VarInt.read(file_object) self.data = file_object.read(self.data_length) self.chunk = ChunkDataPacket.Chunk(self.x, self.z, self.gu_continuous, self.bitmask) self.number_of_entities = VarInt.read(file_object) for _ in range(self.number_of_entities): self.chunk.entities.append(mynbt.parse_bytes(file_object))
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): if self.context.protocol_later_eq(346): self.transaction_id = VarInt.read(file_object) self.start = VarInt.read(file_object) self.length = VarInt.read(file_object) count = VarInt.read(file_object) self.matches = [] for i in range(count): match = String.read(file_object) has_tooltip = False if self.context.protocol_later_eq(357): has_tooltip = Boolean.read(file_object) tooltip = String.read(file_object) if has_tooltip else None tabmatch = TabCompletePacket.TabMatch(match, tooltip) self.matches.append(tabmatch)
def read(self, file_object): self.x = Integer.read(file_object) self.z = Integer.read(file_object) self.full_chunk = Boolean.read(file_object) self.bit_mask_y = VarInt.read(file_object) self.heightmaps = Nbt.read(file_object) self.biomes = [] if self.full_chunk: for i in range(1024): self.biomes.append(Integer.read(file_object)) size = VarInt.read(file_object) self.data = file_object.read(size) size_entities = VarInt.read(file_object) self.entities = [] for i in range(size_entities): self.entities.append(Nbt.read(file_object)) self.decode_chunk_data()
def _read(self, 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