Search in sources :

Example 1 with LayerVisitor

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;
}
Also used : RandomNoise(com.sk89q.worldedit.math.noise.RandomNoise) GroundFunction(com.sk89q.worldedit.function.GroundFunction) NullExtent(com.sk89q.worldedit.extent.NullExtent) Extent(com.sk89q.worldedit.extent.Extent) LayerVisitor(com.sk89q.worldedit.function.visitor.LayerVisitor) Regions.asFlatRegion(com.sk89q.worldedit.regions.Regions.asFlatRegion) NullRegion(com.sk89q.worldedit.regions.NullRegion) Region(com.sk89q.worldedit.regions.Region) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) NoiseFilter2D(com.sk89q.worldedit.function.mask.NoiseFilter2D)

Example 2 with LayerVisitor

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();
}
Also used : LayerVisitor(com.sk89q.worldedit.function.visitor.LayerVisitor) FlatRegion(com.sk89q.worldedit.regions.FlatRegion) Regions.asFlatRegion(com.sk89q.worldedit.regions.Regions.asFlatRegion) Naturalizer(com.sk89q.worldedit.function.block.Naturalizer)

Example 3 with LayerVisitor

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();
}
Also used : LayerVisitor(com.sk89q.worldedit.function.visitor.LayerVisitor) SnowSimulator(com.sk89q.worldedit.function.block.SnowSimulator)

Example 4 with LayerVisitor

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

Example 5 with LayerVisitor

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();
}
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

LayerVisitor (com.sk89q.worldedit.function.visitor.LayerVisitor)6 GroundFunction (com.sk89q.worldedit.function.GroundFunction)4 ExistingBlockMask (com.sk89q.worldedit.function.mask.ExistingBlockMask)4 NoiseFilter2D (com.sk89q.worldedit.function.mask.NoiseFilter2D)4 RandomNoise (com.sk89q.worldedit.math.noise.RandomNoise)4 Regions.asFlatRegion (com.sk89q.worldedit.regions.Regions.asFlatRegion)3 FlatRegion (com.sk89q.worldedit.regions.FlatRegion)2 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 Extent (com.sk89q.worldedit.extent.Extent)1 NullExtent (com.sk89q.worldedit.extent.NullExtent)1 Naturalizer (com.sk89q.worldedit.function.block.Naturalizer)1 SnowSimulator (com.sk89q.worldedit.function.block.SnowSimulator)1 FloraGenerator (com.sk89q.worldedit.function.generator.FloraGenerator)1 ForestGenerator (com.sk89q.worldedit.function.generator.ForestGenerator)1 GardenPatchGenerator (com.sk89q.worldedit.function.generator.GardenPatchGenerator)1 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)1 NullRegion (com.sk89q.worldedit.regions.NullRegion)1