Search in sources :

Example 1 with RegionOffset

use of com.sk89q.worldedit.function.util.RegionOffset in project FastAsyncWorldEdit by IntellectualSites.

the class EditSession method overlayCuboidBlocks.

/**
 * Places a layer of blocks on top of ground blocks in the given region
 * (as if it were a cuboid).
 *
 * @param region  the region
 * @param pattern the placed block pattern
 * @return number of blocks affected
 * @throws MaxChangedBlocksException thrown if too many blocks are changed
 */
public int overlayCuboidBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
    checkNotNull(region);
    checkNotNull(pattern);
    BlockReplace replace = new BlockReplace(this, pattern);
    RegionOffset offset = new RegionOffset(BlockVector3.UNIT_Y, replace);
    // FAWE start
    int minY = region.getMinimumPoint().getBlockY();
    int maxY = Math.min(getMaximumPoint().getBlockY(), region.getMaximumPoint().getBlockY() + 1);
    SurfaceRegionFunction surface = new SurfaceRegionFunction(this, offset, minY, maxY);
    FlatRegionVisitor visitor = new FlatRegionVisitor(asFlatRegion(region), surface, this);
    // FAWE end
    Operations.completeBlindly(visitor);
    return this.changes = visitor.getAffected();
}
Also used : SurfaceRegionFunction(com.fastasyncworldedit.core.function.SurfaceRegionFunction) FlatRegionVisitor(com.sk89q.worldedit.function.visitor.FlatRegionVisitor) RegionOffset(com.sk89q.worldedit.function.util.RegionOffset) BlockReplace(com.sk89q.worldedit.function.block.BlockReplace)

Aggregations

SurfaceRegionFunction (com.fastasyncworldedit.core.function.SurfaceRegionFunction)1 BlockReplace (com.sk89q.worldedit.function.block.BlockReplace)1 RegionOffset (com.sk89q.worldedit.function.util.RegionOffset)1 FlatRegionVisitor (com.sk89q.worldedit.function.visitor.FlatRegionVisitor)1