use of com.sk89q.worldedit.function.visitor.DownwardVisitor in project FastAsyncWorldEdit by IntellectualSites.
the class EditSession method fillXZ.
/**
* Fills an area recursively in the X/Z directions.
*
* @param origin the origin to start the fill from
* @param pattern the pattern to fill with
* @param radius the radius of the spherical area to fill, with 0 as the smallest radius
* @param depth the maximum depth, starting from the origin, with 1 as the smallest depth
* @param recursive whether a breadth-first search should be performed
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int fillXZ(BlockVector3 origin, Pattern pattern, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
checkNotNull(origin);
checkNotNull(pattern);
checkArgument(radius >= 0, "radius >= 0");
checkArgument(depth >= 1, "depth >= 1");
Mask mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), new BoundedHeightMask(Math.max(origin.getBlockY() - depth + 1, minY), Math.min(maxY, origin.getBlockY())), Masks.negate(new ExistingBlockMask(this)));
// Want to replace blocks
BlockReplace replace = new BlockReplace(this, pattern);
// Pick how we're going to visit blocks
RecursiveVisitor visitor;
// FAWE start - provide extent for preloading, min/max y
if (recursive) {
visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1), minY, maxY, this);
} else {
visitor = new DownwardVisitor(mask, replace, origin.getBlockY(), (int) (radius * 2 + 1), minY, maxY, this);
}
// FAWE end
// Start at the origin
visitor.visit(origin);
// Execute
Operations.completeLegacy(visitor);
// FAWE start
return this.changes = visitor.getAffected();
// FAWE end
}
Aggregations