def set_chunk(self, chunk_in: object) -> None: region_index: tuple = anvil.cr_index(chunk_in.x, chunk_in.z) chunk_index: tuple = anvil.rc_index(chunk_in.x, chunk_in.z) region_path: str = os.path.join( os.path.join(self.world_dir, "region"), f"r.{region_index[0]}.{region_index[1]}.{self.region_file_extension}" ) reg: object = region(region_path) reg.put_chunk_data(chunk_index[0], chunk_index[1], anvil.to_anvil_chunk(chunk_in).nbt_serialize())
def get_chunk(self, x: int, z: int) -> object: region_index: tuple = anvil.cr_index(x, z) chunk_index: tuple = anvil.rc_index(x, z) region_path: str = os.path.join( os.path.join(self.world_dir, "region"), f"r.{region_index[0]}.{region_index[1]}.{self.region_file_extension}" ) reg: object = region(region_path) chunk_data: bytes = reg.get_chunk_data(chunk_index[0], chunk_index[1]) if len(chunk_data) > 0: result: object = chunk(x, z) result.nbt_deserialize(chunk_data) return result