new BlockPattern(replacement) :
new BlockPattern(new BaseBlock(BlockID.AIR));
BlockReplace remove = new BlockReplace(this, pattern);
// Copy to a buffer so we don't destroy our original before we can copy all the blocks from it
ForgetfulExtentBuffer buffer = new ForgetfulExtentBuffer(this, new RegionMask(region));
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, buffer, to);
copy.setTransform(new AffineTransform().translate(dir.multiply(distance)));
copy.setSourceFunction(remove); // Remove
copy.setRemovingEntities(true);
if (!copyAir) {
copy.setSourceMask(new ExistingBlockMask(this));
}
// Then we need to copy the buffer to the world
BlockReplace replace = new BlockReplace(this, buffer);
RegionVisitor visitor = new RegionVisitor(buffer.asRegion(), replace);
OperationQueue operation = new OperationQueue(copy, visitor);
Operations.completeLegacy(operation);
return copy.getAffected();