Search in sources :

Example 1 with ForestGenerator

use of com.sk89q.worldedit.function.generator.ForestGenerator in project FastAsyncWorldEdit by IntellectualSites.

the class EditSession method makeForest.

/**
 * Makes a forest.
 *
 * @param region   the region to generate trees in
 * @param density  between 0 and 1, inclusive
 * @param treeType the tree type
 * @return number of trees created
 * @throws MaxChangedBlocksException thrown if too many blocks are changed
 */
public int makeForest(Region region, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException {
    ForestGenerator generator = new ForestGenerator(this, treeType);
    GroundFunction ground = new GroundFunction(new ExistingBlockMask(this), generator);
    // FAWE start - provide extent for preloading
    LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground, this);
    // FAWE end
    visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));
    Operations.completeLegacy(visitor);
    return ground.getAffected();
}
Also used : RandomNoise(com.sk89q.worldedit.math.noise.RandomNoise) GroundFunction(com.sk89q.worldedit.function.GroundFunction) LayerVisitor(com.sk89q.worldedit.function.visitor.LayerVisitor) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) ForestGenerator(com.sk89q.worldedit.function.generator.ForestGenerator) NoiseFilter2D(com.sk89q.worldedit.function.mask.NoiseFilter2D)

Aggregations

GroundFunction (com.sk89q.worldedit.function.GroundFunction)1 ForestGenerator (com.sk89q.worldedit.function.generator.ForestGenerator)1 ExistingBlockMask (com.sk89q.worldedit.function.mask.ExistingBlockMask)1 NoiseFilter2D (com.sk89q.worldedit.function.mask.NoiseFilter2D)1 LayerVisitor (com.sk89q.worldedit.function.visitor.LayerVisitor)1 RandomNoise (com.sk89q.worldedit.math.noise.RandomNoise)1