Пример #1
0
    def read(self, file_object):
        self.entity_id = VarInt.read(file_object)
        if self._context.protocol_version >= 49:
            self.objectUUID = UUID.read(file_object)
        type_id = Byte.read(file_object)
        self.type = SpawnObjectPacket.EntityType.get_type_by_id(type_id)

        if self._context.protocol_version >= 100:
            self.x = Double.read(file_object)
            self.y = Double.read(file_object)
            self.z = Double.read(file_object)
        else:
            self.x = Integer.read(file_object)
            self.y = Integer.read(file_object)
            self.z = Integer.read(file_object)

        self.pitch = UnsignedByte.read(file_object)
        self.yaw = UnsignedByte.read(file_object)
        self.data = Integer.read(file_object)

        if self._context.protocol_version < 49:
            if self.data > 0:
                self.velocity_x = Short.read(file_object)
                self.velocity_y = Short.read(file_object)
                self.velocity_z = Short.read(file_object)
        else:
            self.velocity_x = Short.read(file_object)
            self.velocity_y = Short.read(file_object)
            self.velocity_z = Short.read(file_object)
Пример #2
0
 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)
         self.records.append(record)
Пример #3
0
 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)
     record_type = self.BaseRecord.get_subclass(self.context)
     self.records = []
     for i in range(records_count):
         record = record_type(h_position=UnsignedByte.read(file_object),
                              y_coordinate=UnsignedByte.read(file_object),
                              blockData=VarInt.read(file_object))
         self.records.append(record)
Пример #4
0
 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):
         rec_horizontal_position = UnsignedByte.read(file_object)
         rec_y_coordinate = UnsignedByte.read(file_object)
         rec_blockData = VarInt.read(file_object)
         record = MultiBlockChangePacket.Record(
                      rec_horizontal_position,
                      rec_y_coordinate, rec_blockData)
         self.records.append(record)
Пример #5
0
    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))
Пример #6
0
    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()
Пример #7
0
 def read(self, file_object):
     self.x = Float.read(file_object)
     self.y = Float.read(file_object)
     self.z = Float.read(file_object)
     self.radius = Float.read(file_object)
     records_count = Integer.read(file_object)
     self.records = []
     for i in range(records_count):
         rec_x = Byte.read(file_object)
         rec_y = Byte.read(file_object)
         rec_z = Byte.read(file_object)
         record = ExplosionPacket.Record(rec_x, rec_y, rec_z)
         self.records.append(record)
     self.player_motion_x = Float.read(file_object)
     self.player_motion_y = Float.read(file_object)
     self.player_motion_z = Float.read(file_object)
Пример #8
0
 def read(self, file_object):
     self.x = Float.read(file_object)
     self.y = Float.read(file_object)
     self.z = Float.read(file_object)
     self.radius = Float.read(file_object)
     records_count = Integer.read(file_object)
     self.records = []
     for i in range(records_count):
         rec_x = Byte.read(file_object)
         rec_y = Byte.read(file_object)
         rec_z = Byte.read(file_object)
         record = ExplosionPacket.Record(rec_x, rec_y, rec_z)
         self.records.append(record)
     self.player_motion_x = Float.read(file_object)
     self.player_motion_y = Float.read(file_object)
     self.player_motion_z = Float.read(file_object)
Пример #9
0
    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)
        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, UnsignedByte.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))
Пример #10
0
    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, UnsignedByte.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))
Пример #11
0
    def read(self, file_object):
        self.entity_id = VarInt.read(file_object)
        if self.context.protocol_later_eq(49):
            self.object_uuid = UUID.read(file_object)

        if self.context.protocol_later_eq(458):
            self.type_id = VarInt.read(file_object)
        else:
            self.type_id = Byte.read(file_object)

        xyz_type = Double if self.context.protocol_later_eq(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_later_eq(49) or self.data > 0:
            for attr in "velocity_x", "velocity_y", "velocity_z":
                setattr(self, attr, Short.read(file_object))
Пример #12
0
 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)
Пример #13
0
 def read(self, file_object):
     self.duration = VarInt.read(file_object)
     self.entity_id = Integer.read(file_object)
Пример #14
0
 def read(cls, file_object):
     return Vector(*(Integer.read(file_object) / 8.0 for i in range(3)))
Пример #15
0
 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)
Пример #16
0
 def read(self, file_object):
     self.duration = VarInt.read(file_object)
     self.entity_id = Integer.read(file_object)