Search in sources :

Example 1 with FloraGenerator

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

the class RegionCommands method flora.

@Command(name = "/flora", desc = "Make flora within the region")
@CommandPermissions("worldedit.region.flora")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int flora(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "The density of the forest", def = "5") double density) throws WorldEditException {
    checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]");
    density = density / 100;
    FloraGenerator generator = new FloraGenerator(editSession);
    GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
    // FAWE start - provide extent for preloading
    LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
    // FAWE end
    visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));
    Operations.completeLegacy(visitor);
    int affected = ground.getAffected();
    actor.print(Caption.of("worldedit.flora.created", TextComponent.of(affected)));
    return affected;
}
Also used : FloraGenerator(com.sk89q.worldedit.function.generator.FloraGenerator) 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) NoiseFilter2D(com.sk89q.worldedit.function.mask.NoiseFilter2D) Logging(com.sk89q.worldedit.command.util.Logging) Preload(com.sk89q.worldedit.command.util.annotation.Preload) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)1 Logging (com.sk89q.worldedit.command.util.Logging)1 Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)1 Preload (com.sk89q.worldedit.command.util.annotation.Preload)1 GroundFunction (com.sk89q.worldedit.function.GroundFunction)1 FloraGenerator (com.sk89q.worldedit.function.generator.FloraGenerator)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 Command (org.enginehub.piston.annotation.Command)1