コード例 #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 write_fields(self, packet_buffer):
     Float.send(self.x, packet_buffer)
     Float.send(self.y, packet_buffer)
     Float.send(self.z, packet_buffer)
     Float.send(self.radius, packet_buffer)
     Integer.send(len(self.records), packet_buffer)
     for record in self.records:
         Byte.send(record.x, packet_buffer)
         Byte.send(record.y, packet_buffer)
         Byte.send(record.z, packet_buffer)
     Float.send(self.player_motion_x, packet_buffer)
     Float.send(self.player_motion_y, packet_buffer)
     Float.send(self.player_motion_z, packet_buffer)
コード例 #5
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)
コード例 #6
0
ファイル: explosion_packet.py プロジェクト: raxod502/pyCraft
 def write_fields(self, packet_buffer):
     Float.send(self.x, packet_buffer)
     Float.send(self.y, packet_buffer)
     Float.send(self.z, packet_buffer)
     Float.send(self.radius, packet_buffer)
     Integer.send(len(self.records), packet_buffer)
     for record in self.records:
         Byte.send(record.x, packet_buffer)
         Byte.send(record.y, packet_buffer)
         Byte.send(record.z, packet_buffer)
     Float.send(self.player_motion_x, packet_buffer)
     Float.send(self.player_motion_y, packet_buffer)
     Float.send(self.player_motion_z, packet_buffer)
コード例 #7
0
ファイル: chunk_data_packet.py プロジェクト: kisate/mPyCraft
    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))
コード例 #8
0
    def write_fields(self, packet_buffer):
        VarInt.send(self.entity_id, packet_buffer)
        if self.context.protocol_version >= 49:
            UUID.send(self.object_uuid, packet_buffer)
        Byte.send(self.type_id, packet_buffer)

        xyz_type = Double if self.context.protocol_version >= 100 else Integer
        for coord in self.x, self.y, self.z:
            xyz_type.send(coord, packet_buffer)
        for coord in self.pitch, self.yaw:
            UnsignedByte.send(coord, packet_buffer)

        Integer.send(self.data, packet_buffer)
        if self.context.protocol_version >= 49 or self.data > 0:
            for coord in self.velocity_x, self.velocity_y, self.velocity_z:
                Short.send(coord, packet_buffer)
コード例 #9
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()
コード例 #10
0
    def write_fields(self, packet_buffer):
        VarInt.send(self.entity_id, packet_buffer)
        if self.context.protocol_version >= 49:
            UUID.send(self.object_uuid, packet_buffer)

        if self.context.protocol_version >= 458:
            VarInt.send(self.type_id, packet_buffer)
        else:
            Byte.send(self.type_id, packet_buffer)

        xyz_type = Double if self.context.protocol_version >= 100 else Integer
        for coord in self.x, self.y, self.z:
            xyz_type.send(coord, packet_buffer)
        for coord in self.pitch, self.yaw:
            UnsignedByte.send(coord, packet_buffer)

        Integer.send(self.data, packet_buffer)
        if self.context.protocol_version >= 49 or self.data > 0:
            for coord in self.velocity_x, self.velocity_y, self.velocity_z:
                Short.send(coord, packet_buffer)
コード例 #11
0
    def write_fields(self, packet_buffer):
        VarInt.send(self.entity_id, packet_buffer)
        if self.context.protocol_later_eq(49):
            UUID.send(self.object_uuid, packet_buffer)

        if self.context.protocol_later_eq(458):
            VarInt.send(self.type_id, packet_buffer)
        else:
            Byte.send(self.type_id, packet_buffer)

        # pylint: disable=no-member
        xyz_type = Double if self.context.protocol_later_eq(100) else Integer
        for coord in self.x, self.y, self.z:
            xyz_type.send(coord, packet_buffer)
        for coord in self.pitch, self.yaw:
            Angle.send(coord, packet_buffer)

        Integer.send(self.data, packet_buffer)
        if self.context.protocol_later_eq(49) or self.data > 0:
            for coord in self.velocity_x, self.velocity_y, self.velocity_z:
                Short.send(coord, packet_buffer)
コード例 #12
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)
コード例 #13
0
ファイル: explosion_packet.py プロジェクト: raxod502/pyCraft
 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)
コード例 #14
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))
コード例 #15
0
 def write_fields(self, packet_buffer):
     Integer.send(self.x, packet_buffer)
     Integer.send(self.z, packet_buffer)
     Boolean.send(self.full_chunk, packet_buffer)
     VarInt.send(self.bit_mask_y, packet_buffer)
     Nbt.send(self.heightmaps, packet_buffer)
     if self.full_chunk:
         for i in range(1024):
             Integer.send(self.biomes[i], packet_buffer)
     VarInt.send(len(self.data), packet_buffer)
     packet_buffer.send(self.data)
     VarInt.send(len(self.entities), packet_buffer)
     for e in self.entities:
         Nbt.send(e, packet_buffer)
コード例 #16
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))
コード例 #17
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))
コード例 #18
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)
コード例 #19
0
 def write_fields(self, packet_buffer):
     Integer.send(self.chunk_x, packet_buffer)
     Integer.send(self.chunk_z, packet_buffer)
     VarInt.send(len(self.records), packet_buffer)
     for record in self.records:
         record.write(packet_buffer)
コード例 #20
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)
コード例 #21
0
 def write(self, packet_buffer):
     VarInt.send(self.player_id, packet_buffer)
     Integer.send(self.entity_id, packet_buffer)
     String.send(self.message, packet_buffer)
コード例 #22
0
 def write(self, packet_buffer):
     VarInt.send(self.duration, packet_buffer)
     Integer.send(self.entity_id, packet_buffer)
コード例 #23
0
 def read(self, file_object):
     self.duration = VarInt.read(file_object)
     self.entity_id = Integer.read(file_object)
コード例 #24
0
ファイル: sound_effect_packet.py プロジェクト: afands/PyMcBot
 def send(cls, value, socket):
     for coordinate in value:
         Integer.send(int(coordinate * 8), socket)
コード例 #25
0
ファイル: sound_effect_packet.py プロジェクト: afands/PyMcBot
 def read(cls, file_object):
     return Vector(*(Integer.read(file_object) / 8.0 for i in range(3)))
コード例 #26
0
 def read(self, file_object):
     self.duration = VarInt.read(file_object)
     self.entity_id = Integer.read(file_object)
コード例 #27
0
 def write(self, packet_buffer):
     VarInt.send(self.duration, packet_buffer)
     Integer.send(self.entity_id, packet_buffer)
コード例 #28
0
 def write(self, packet_buffer):
     VarInt.send(self.player_id, packet_buffer)
     Integer.send(self.entity_id, packet_buffer)
     String.send(self.message, packet_buffer)