Пример #1
0
 def _load_binary_chunk_at(self, region_file, offset):
     region_file.seek(offset)
     datalen = int.from_bytes(region_file.read(4),
                              byteorder='big',
                              signed=False)
     compr = region_file.read(1)
     decompressed = zlib.decompress(region_file.read(datalen))
     data = nbt.parse_nbt(stream.InputStream(decompressed))
     chunk_pos = (data.get('Level').get('xPos').get(),
                  data.get('Level').get('zPos').get())
     chunk = Chunk(chunk_pos[0], chunk_pos[1], data)
     return chunk
Пример #2
0
    def __init__(self, world_path: str, username: str = "", uuid: str = ""):
        if uuid == "":
            uuid = self._username_to_uuid(username)

        uuid_fn = self._uuid_to_filename(uuid)
        player_path = os.path.join(world_path, "playerdata", uuid_fn + ".dat")
        with gzip.open(player_path, mode='rb') as player_file:
            in_stream = stream.InputStream(player_file.read())
            p_data = nbt.parse_nbt(in_stream)

        self.pos = [c.get() for c in p_data.get("Pos").children]
        self.rot = [c.get() for c in p_data.get("Rotation").children]
        self.dim = p_data.get("Dimension").get()