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;
}
Aggregations