use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class RegionCommands method line.
@Command(name = "/line", desc = "Draws line segments between cuboid selection corners or convex polyhedral selection vertices", descFooter = "Can only be used with a cuboid selection or a convex polyhedral selection")
@CommandPermissions("worldedit.region.line")
@Logging(REGION)
public int line(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "The pattern of blocks to place") Pattern pattern, @Arg(desc = "The thickness of the line", def = "0") int thickness, @Switch(name = 'h', desc = "Generate only a shell") boolean shell) throws WorldEditException {
if (!(region instanceof CuboidRegion)) {
actor.print(Caption.of("worldedit.line.cuboid-only"));
return 0;
}
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
CuboidRegion cuboidregion = (CuboidRegion) region;
BlockVector3 pos1 = cuboidregion.getPos1();
BlockVector3 pos2 = cuboidregion.getPos2();
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
actor.print(Caption.of("worldedit.line.changed", TextComponent.of(blocksChanged)));
return blocksChanged;
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class RegionCommands method lay.
@Command(name = "/lay", desc = "Set the top block in the region")
@CommandPermissions("worldedit.region.overlay")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public void lay(Actor actor, EditSession editSession, @Selection Region region, @Arg(name = "pattern", desc = "The pattern of blocks to lay") Pattern patternArg) throws WorldEditException {
// FAWE start - world min/maxY
int maxY = region.getMaximumY();
int minY = region.getMinimumY();
// FAWE end
Iterable<BlockVector2> flat = Regions.asFlatRegion(region).asFlatRegion();
Iterator<BlockVector2> iter = flat.iterator();
// FAWE start - world min/maxY
int y = minY;
// FAWE end
int affected = 0;
while (iter.hasNext()) {
BlockVector2 pos = iter.next();
int x = pos.getBlockX();
int z = pos.getBlockZ();
// FAWE start - world min/maxY
y = editSession.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
// FAWE end
editSession.setBlock(x, y, z, patternArg);
affected++;
}
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", affected));
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class RegionCommands method hollow.
@Command(name = "/hollow", desc = "Hollows out the object contained in this selection", descFooter = "Hollows out the object contained in this selection.\n" + "Optionally fills the hollowed out part with the given block.\n" + "Thickness is measured in manhattan distance.")
@CommandPermissions("worldedit.region.hollow")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int hollow(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "Thickness of the shell to leave", def = "0") int thickness, @Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air") Pattern pattern, @ArgFlag(name = 'm', desc = "Mask to hollow with") Mask mask) throws WorldEditException {
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
// FAWE start > the mask will have been initialised with a WorldWrapper extent (very bad/slow)
Mask finalMask;
if (mask != null) {
new MaskTraverser(mask).setNewExtent(editSession);
finalMask = mask;
} else {
finalMask = new SolidBlockMask(editSession);
}
// FAWE end
int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask);
actor.print(Caption.of("worldedit.hollow.changed", TextComponent.of(affected)));
return affected;
}
use of com.sk89q.worldedit.command.util.CommandPermissions 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.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class RegionCommands method snowSmooth.
@Command(name = "/snowsmooth", desc = "Smooth the elevation in the selection with snow layers", descFooter = "Example: '//snowsmooth 1 -m snow_block,snow' would only smooth snow terrain.")
@CommandPermissions("worldedit.region.snowsmooth")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int snowSmooth(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "# of iterations to perform", def = "1") int iterations, @ArgFlag(name = 'l', desc = "Set the amount of snow blocks under the snow", def = "1") int snowBlockCount, @ArgFlag(name = 'm', desc = "The mask of blocks to use as the height map") Mask mask) throws WorldEditException {
SnowHeightMap heightMap = new SnowHeightMap(editSession, region, mask);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
float[] changed = heightMap.applyFilter(filter, iterations);
int affected = heightMap.applyChanges(changed, snowBlockCount);
actor.print(Caption.of("worldedit.snowsmooth.changed", TextComponent.of(affected)));
return affected;
}
Aggregations