use of com.sk89q.worldedit.math.noise.RandomNoise in project FastAsyncWorldEdit by IntellectualSites.
the class NoiseMaskParser method parseFromInput.
@Override
public Mask parseFromInput(String input, ParserContext context) {
if (!input.startsWith("%")) {
return null;
}
// FAWE start - richer parsing
if (input.charAt(1) == '[') {
int end = input.lastIndexOf(']');
if (end == -1) {
return null;
}
input = input.substring(2, end);
} else {
input = input.substring(1);
}
int i = Integer.parseInt(input);
return new NoiseFilter(new RandomNoise(), ((double) i) / 100);
}
use of com.sk89q.worldedit.math.noise.RandomNoise 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.math.noise.RandomNoise 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.math.noise.RandomNoise 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();
}
use of com.sk89q.worldedit.math.noise.RandomNoise 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();
}
Aggregations