use of com.sk89q.worldedit.function.visitor.NonRisingVisitor in project FastAsyncWorldEdit by IntellectualSites.
the class EditSession method fixLiquid.
/**
* Fix liquids so that they turn into stationary blocks and extend outward.
*
* @param origin the original position
* @param radius the radius to fix
* @param fluid the type of the fluid
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int fixLiquid(BlockVector3 origin, double radius, BlockType fluid) throws MaxChangedBlocksException {
checkNotNull(origin);
checkArgument(radius >= 0, "radius >= 0 required");
// Our origins can only be liquids
Mask liquidMask = new SingleBlockTypeMask(this, fluid);
// But we will also visit air blocks
MaskIntersection blockMask = new MaskUnion(liquidMask, Masks.negate(new ExistingBlockMask(this)));
// There are boundaries that the routine needs to stay in
Mask mask = new MaskIntersection(new BoundedHeightMask(minY, Math.min(origin.getBlockY(), maxY)), new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), blockMask);
BlockReplace replace = new BlockReplace(this, fluid.getDefaultState());
// FAWE start - provide extent for preloading, world min/maxY
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace, Integer.MAX_VALUE, minY, maxY, this);
// Around the origin in a 3x3 block
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
if (liquidMask.test(position)) {
visitor.visit(position);
}
}
Operations.completeLegacy(visitor);
return visitor.getAffected();
}
Aggregations