Search in sources :

Example 1 with GardenPatchGenerator

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

the class EditSession method makePumpkinPatches.

// FAWE start - support density
public int makePumpkinPatches(BlockVector3 position, int apothem, double density) throws MaxChangedBlocksException {
    // We want to generate pumpkins
    GardenPatchGenerator generator = new GardenPatchGenerator(this);
    generator.setPlant(GardenPatchGenerator.getPumpkinPattern());
    // In a region of the given radius
    FlatRegion region = new CuboidRegion(// Causes clamping of Y range
    getWorld(), position.add(-apothem, -5, -apothem), position.add(apothem, 10, apothem));
    GroundFunction ground = new GroundFunction(new ExistingBlockMask(this), generator);
    LayerVisitor visitor = new LayerVisitor(region, minimumBlockY(region), maximumBlockY(region), ground, this);
    visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));
    Operations.completeLegacy(visitor);
    return this.changes = ground.getAffected();
}
Also used : RandomNoise(com.sk89q.worldedit.math.noise.RandomNoise) GroundFunction(com.sk89q.worldedit.function.GroundFunction) LayerVisitor(com.sk89q.worldedit.function.visitor.LayerVisitor) FlatRegion(com.sk89q.worldedit.regions.FlatRegion) Regions.asFlatRegion(com.sk89q.worldedit.regions.Regions.asFlatRegion) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) GardenPatchGenerator(com.sk89q.worldedit.function.generator.GardenPatchGenerator) NoiseFilter2D(com.sk89q.worldedit.function.mask.NoiseFilter2D)

Aggregations

GroundFunction (com.sk89q.worldedit.function.GroundFunction)1 GardenPatchGenerator (com.sk89q.worldedit.function.generator.GardenPatchGenerator)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 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)1 FlatRegion (com.sk89q.worldedit.regions.FlatRegion)1 Regions.asFlatRegion (com.sk89q.worldedit.regions.Regions.asFlatRegion)1