docs: def unlink_chunk(self, x, z):
          """
          Remove a chunk from the header of the region file.
          Fragmentation is not a problem, chunks are written to free sectors when possible.
          """
          # This function fails for an empty file. If that is the case, just return.
          if self.size < 2*SECTOR_LENGTH:
              return
  
          # zero the region header for the chunk (offset length and time)
          self.file.seek(4 * (x + 32*z))
          self.file.write(pack(">IB", 0, 0)[1:])
          self.file.seek(SECTOR_LENGTH + 4 * (x + 32*z))
          self.file.write(pack(">I", 0))
  
          # Check if file should be truncated:
          current = self.metadata[x, z]
          free_sectors = self._locate_free_sectors(ignore_chunk=current)
          truncate_count = list(reversed(free_sectors)).index(False)
          if truncate_count > 0:
              self.size = SECTOR_LENGTH * (len(free_sectors) - truncate_count)
              self.file.truncate(self.size)
              free_sectors = free_sectors[:-truncate_count]
          
          # Calculate freed sectors
          for s in range(current.blockstart, min(current.blockstart + current.blocklength, len(free_sectors))):
              if free_sectors[s]:
                  # zero sector s
                  self.file.seek(SECTOR_LENGTH*s)
                  self.file.write(SECTOR_LENGTH*b'\x00')
  
          # update the header
          self.metadata[x, z] = ChunkMetadata(x, z)