use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.
the class GenerationCommands method ore.
@Command(name = "/ore", desc = "Generates ores")
@CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public void ore(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask, @Arg(desc = "Pattern") Pattern material, @Arg(desc = "Ore vein size") @Range(from = 0, to = Integer.MAX_VALUE) int size, @Arg(desc = "Ore vein frequency (number of times to attempt to place ore)", def = "10") @Range(from = 0, to = Integer.MAX_VALUE) int freq, @Arg(desc = "Ore vein rarity (% chance each attempt is placed)", def = "100") @Range(from = 0, to = 100) int rarity, @Arg(desc = "Ore vein min y", def = "0") int minY, @Arg(desc = "Ore vein max y", def = "63") int maxY) throws WorldEditException {
new MaskTraverser(mask).setNewExtent(editSession);
checkCommandArgument(minY >= editSession.getMinY(), Caption.of("fawe.error.outside-range-lower", "miny", editSession.getMinY()));
checkCommandArgument(maxY <= editSession.getMaxY(), Caption.of("fawe.error.outside-range-upper", "maxy", editSession.getMaxY()));
checkCommandArgument(minY < maxY, Caption.of("fawe.error.argument-size-mismatch", "miny", "maxy"));
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
}
use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.
the class GenerationCommands method ores.
@Command(name = "/ores", desc = "Generates ores")
@CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public void ores(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask) throws WorldEditException {
new MaskTraverser(mask).setNewExtent(editSession);
editSession.addOres(region, mask);
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
}
use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.
the class UtilityCommands method replaceNear.
@Command(name = "replacenear", aliases = { "/replacenear" }, desc = "Replace nearby blocks")
@CommandPermissions("worldedit.replacenear")
@Logging(PLACEMENT)
public int replaceNear(Actor actor, World world, LocalSession session, EditSession editSession, @Arg(desc = "The radius of the square to remove in") int radius, @Arg(desc = "The mask matching blocks to remove", def = "") Mask from, @Arg(desc = "The pattern of blocks to replace with") Pattern to) throws WorldEditException {
// FAWE start > the mask will have been initialised with a WorldWrapper extent (very bad/slow)
new MaskTraverser(from).setNewExtent(editSession);
// FAWE end
radius = Math.max(1, radius);
we.checkMaxRadius(radius);
BlockVector3 base = session.getPlacementPosition(actor);
BlockVector3 min = base.subtract(radius, radius, radius);
BlockVector3 max = base.add(radius, radius, radius);
Region region = new CuboidRegion(world, min, max);
if (from == null) {
from = new ExistingBlockMask(editSession);
}
int affected = editSession.replaceBlocks(region, from, to);
actor.print(Caption.of("worldedit.replacenear.replaced", TextComponent.of(affected)));
return affected;
}
use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.
the class RegionCommands method replace.
@Command(name = "/replace", aliases = { "/re", "/rep" }, desc = "Replace all blocks in the selection with another")
@CommandPermissions("worldedit.region.replace")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int replace(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "The mask representing blocks to replace", def = "") Mask from, @Arg(desc = "The pattern of blocks to replace with") Pattern to) throws WorldEditException {
if (from == null) {
from = new ExistingBlockMask(editSession);
// FAWE start > the mask will have been initialised with a WorldWrapper extent (very bad/slow
} else {
new MaskTraverser(from).setNewExtent(editSession);
}
int affected = editSession.replaceBlocks(region, from, to);
actor.print(Caption.of("worldedit.replace.replaced", TextComponent.of(affected)));
return affected;
}
use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.
the class RegionCommands method stack.
@Command(name = "/stack", desc = "Repeat the contents of the selection")
@CommandPermissions("worldedit.region.stack")
@Preload(Preload.PreloadCheck.PRELOAD)
@Logging(ORIENTATION_REGION)
public int stack(Actor actor, World world, EditSession editSession, LocalSession session, @Selection Region region, @Arg(desc = "# of copies to stack", def = "1") @Confirm(Confirm.Processor.REGION) int count, @Arg(desc = "The direction to stack", def = Direction.AIM) @Direction(includeDiagonals = true) BlockVector3 direction, @Switch(name = 's', desc = "Shift the selection to the last stacked copy") boolean moveSelection, @Switch(name = 'a', desc = "Ignore air blocks") boolean ignoreAirBlocks, @Switch(name = 'e', desc = "Also copy entities") boolean copyEntities, @Switch(name = 'b', desc = "Also copy biomes") boolean copyBiomes, @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air") Mask mask) throws WorldEditException {
// FAWE start > the mask will have been initialised with a WorldWrapper extent (very bad/slow)
new MaskTraverser(mask).setNewExtent(editSession);
// FAWE end
Mask combinedMask;
if (ignoreAirBlocks) {
if (mask == null) {
combinedMask = new ExistingBlockMask(editSession);
} else {
combinedMask = new MaskIntersection(mask, new ExistingBlockMask(editSession));
}
} else {
combinedMask = mask;
}
int affected = editSession.stackCuboidRegion(region, direction, count, copyEntities, copyBiomes, combinedMask);
if (moveSelection) {
try {
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
final BlockVector3 shiftVector = direction.multiply(size).multiply(count);
region.shift(shiftVector);
session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session);
} catch (RegionOperationException e) {
actor.printError(TextComponent.of(e.getMessage()));
}
}
actor.print(Caption.of("worldedit.stack.changed", TextComponent.of(affected)));
return affected;
}
Aggregations