コード例 #1
0
 def send_air_chunk(self, x, z):
     sections = []
     if x == 0 and z == 0:
         sections = [(BlockArray.empty(self.registry), None)
                     for _ in range(16)]
         sections[9][0][0] = {"name": "minecraft:bedrock"}
     sections_data = self.buff_type.pack_chunk(sections)
     motion_world = PackedArray.empty_height()
     motion_blocking = TagLongArray(PackedArray.empty_height())
     world_surface = TagLongArray(PackedArray.empty_height())
     heightmap = TagRoot({
         "":
         TagCompound({
             "MOTION_BLOCKING": motion_blocking,
             "WORLD_SURFACE": world_surface
         })
     })
     biomes = [27 for _ in range(1024)]
     block_entities = []
     self.send_packet(
         "chunk_data",
         self.buff_type.pack("ii?", x, z, True),
         self.buff_type.pack_chunk_bitmask(sections),
         self.buff_type.pack_nbt(heightmap),  # added in 1.14
         self.buff_type.pack_varint(0),
         b"",
         # b"".join(self.buff_type.pack_varint(biome) for biome in biomes),
         # self.buff_type.pack_array("I", biomes),
         self.buff_type.pack_varint(len(sections_data)),
         sections_data,
         self.buff_type.pack_varint(len(block_entities)),
         b""
         # b"".join(self.buff_type.pack_nbt(entity) for entity in block_entities),
     )
コード例 #2
0
ファイル: version_1_17.py プロジェクト: JLyne/LinkingServer
    def send_reset_world(self):
        data = [
            self.protocol.buff_type.pack_varint(0),
            b'',
            self.protocol.buff_type.pack_nbt(
                TagRoot({
                    '':
                    TagCompound({
                        "MOTION_BLOCKING":
                        TagLongArray(PackedArray.empty_height())
                    })
                })),
            self.protocol.buff_type.pack_varint(1024),
        ]

        for i in range(1024):
            data.append(self.protocol.buff_type.pack_varint(127))

        data.append(self.protocol.buff_type.pack_varint(0))
        data.append(b'')
        data.append(self.protocol.buff_type.pack_varint(0))
        data.append(b'')

        for x in range(-8, 8):
            for y in range(-8, 8):
                self.protocol.send_packet(
                    "chunk_data", self.protocol.buff_type.pack("ii", x, y),
                    *data)
コード例 #3
0
ファイル: World.py プロジェクト: AlexisHuvier/PyMine
 def send_chunk(self, x, z):
     emptyHeight = TagRoot({"": TagCompound({
         "MOTION_BLOCKING": TagLongArray(PackedArray.empty_height())
     })})
     try:
         cdpacket = ChunkDataPacket(self.protocol.buff_type, x, z, False, emptyHeight, [None]*16, [1]*256, [])
         self.protocol.send_packet(cdpacket.type_, *cdpacket.datas)
     except ValueError:
         pass
コード例 #4
0
ファイル: v1_9.py プロジェクト: vcokltfre/quarry
    def unpack_chunk_section(self, overworld=True):
        """
        Unpacks a chunk section. Returns a 3-tuple of
        ``(blocks, block_lights, sky_lights)``, where *sky_lights* is ``None``
        when *overworld* is ``False``. The returned values are sequences of
        length 4096 (16x16x16).
        """

        value_width = self.unpack('B')
        palette = self.unpack_chunk_section_palette(value_width)
        array = self.unpack_chunk_section_array(value_width)
        blocks = BlockArray.from_bytes(bytes=array,
                                       palette=palette,
                                       registry=self.registry,
                                       non_air=None,
                                       value_width=value_width)
        block_lights = PackedArray.from_light_bytes(self.read(2048))
        if overworld:
            sky_lights = PackedArray.from_light_bytes(self.read(2048))
        else:
            sky_lights = None

        return blocks, block_lights, sky_lights
コード例 #5
0
ファイル: network.py プロジェクト: SuperTails/112craft
def unpackLightArray(buf) -> PackedArray:
    length = buf.unpack_varint()
    assert(length == 2048)

    return PackedArray.from_light_bytes(buf.read(length))
コード例 #6
0
 def from_buff(cls, buff):
     return cls(
         PackedArray.from_bytes(bytes=buff.read(
             buff.unpack('i') * (cls.width // 8)),
                                sector_width=cls.width))
コード例 #7
0
 def from_buff(cls, buff):
     length = buff.unpack('i')
     data = buff.read(length * (cls.width // 8))
     return cls(PackedArray.from_bytes(data, length, cls.width, cls.width))