Search in sources :

Example 1 with Regions.asFlatRegion

use of com.sk89q.worldedit.regions.Regions.asFlatRegion in project FastAsyncWorldEdit by IntellectualSites.

the class EditSession method naturalizeCuboidBlocks.

/**
 * Turns the first 3 layers into dirt/grass and the bottom layers
 * into rock, like a natural Minecraft mountain.
 *
 * @param region the region to affect
 * @return number of blocks affected
 * @throws MaxChangedBlocksException thrown if too many blocks are changed
 */
public int naturalizeCuboidBlocks(Region region) throws MaxChangedBlocksException {
    checkNotNull(region);
    Naturalizer naturalizer = new Naturalizer(this);
    FlatRegion flatRegion = Regions.asFlatRegion(region);
    // FAWE start - provide extent for preloading
    LayerVisitor visitor = new LayerVisitor(flatRegion, minimumBlockY(region), maximumBlockY(region), naturalizer, this);
    // FAWE end
    Operations.completeBlindly(visitor);
    return this.changes = naturalizer.getAffected();
}
Also used : LayerVisitor(com.sk89q.worldedit.function.visitor.LayerVisitor) FlatRegion(com.sk89q.worldedit.regions.FlatRegion) Regions.asFlatRegion(com.sk89q.worldedit.regions.Regions.asFlatRegion) Naturalizer(com.sk89q.worldedit.function.block.Naturalizer)

Aggregations

Naturalizer (com.sk89q.worldedit.function.block.Naturalizer)1 LayerVisitor (com.sk89q.worldedit.function.visitor.LayerVisitor)1 FlatRegion (com.sk89q.worldedit.regions.FlatRegion)1 Regions.asFlatRegion (com.sk89q.worldedit.regions.Regions.asFlatRegion)1