use of com.sk89q.worldedit.function.visitor.LayerVisitor in project FastAsyncWorldEdit by IntellectualSites.
the class Paint method createFromContext.
@Override
public Operation createFromContext(EditContext context) {
Extent destination = firstNonNull(context.getDestination(), this.destination);
Region region = firstNonNull(context.getRegion(), this.region);
GroundFunction ground = new GroundFunction(new ExistingBlockMask(destination), function.createFromContext(context));
// FAWE start - provide extent for preloading
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground, destination);
// FAWE end
visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));
return visitor;
}
use of com.sk89q.worldedit.function.visitor.LayerVisitor 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();
}
use of com.sk89q.worldedit.function.visitor.LayerVisitor in project FastAsyncWorldEdit by IntellectualSites.
the class EditSession method simulateSnow.
/**
* Make snow in a region.
*
* @param region the region to simulate snow in
* @param stack whether it should stack existing snow
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int simulateSnow(FlatRegion region, boolean stack) throws MaxChangedBlocksException {
checkNotNull(region);
SnowSimulator snowSimulator = new SnowSimulator(this, stack);
// FAWE start - provide extent for preloading
LayerVisitor layerVisitor = new LayerVisitor(region, region.getMinimumY(), region.getMaximumY(), snowSimulator, this);
// FAWE end
Operations.completeLegacy(layerVisitor);
return snowSimulator.getAffected();
}
use of com.sk89q.worldedit.function.visitor.LayerVisitor 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;
}
use of com.sk89q.worldedit.function.visitor.LayerVisitor 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();
}
Aggregations