use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class RegionCommands method deform.
@Command(name = "/deform", desc = "Deforms a selected region with an expression", descFooter = "The expression is executed for each block and is expected\n" + "to modify the variables x, y and z to point to a new block\n" + "to fetch. For details, see https://ehub.to/we/expr")
@CommandPermissions("worldedit.region.deform")
@Logging(ALL)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int deform(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "The expression to use", variable = true) List<String> expression, @Switch(name = 'r', desc = "Use the game's coordinate origin") boolean useRawCoords, @Switch(name = 'o', desc = "Use the placement's coordinate origin") boolean offset, @Switch(name = 'c', desc = "Use the selection's center as origin") boolean offsetCenter) throws WorldEditException {
final Vector3 zero;
Vector3 unit;
if (useRawCoords) {
zero = Vector3.ZERO;
unit = Vector3.ONE;
} else if (offsetCenter) {
final Vector3 min = region.getMinimumPoint().toVector3();
final Vector3 max = region.getMaximumPoint().toVector3();
zero = max.add(min).multiply(0.5);
unit = Vector3.ONE;
} else if (offset) {
zero = session.getPlacementPosition(actor).toVector3();
unit = Vector3.ONE;
} else {
final Vector3 min = region.getMinimumPoint().toVector3();
final Vector3 max = region.getMaximumPoint().toVector3();
zero = max.add(min).divide(2);
unit = max.subtract(zero);
if (unit.getX() == 0) {
unit = unit.withX(1.0);
}
if (unit.getY() == 0) {
unit = unit.withY(1.0);
}
if (unit.getZ() == 0) {
unit = unit.withZ(1.0);
}
}
final Vector3 unit1 = unit;
try {
final int affected = editSession.deformRegion(region, zero, unit1, String.join(" ", expression), session.getTimeout());
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
actor.print(Caption.of("worldedit.deform.deformed", TextComponent.of(affected)));
return affected;
} catch (ExpressionException e) {
actor.printError(TextComponent.of(e.getMessage()));
return 0;
}
}
use of com.sk89q.worldedit.command.util.CommandPermissions 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.sk89q.worldedit.command.util.CommandPermissions 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;
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class RegionCommands method move.
@Command(name = "/move", aliases = { "/mv" }, desc = "Move the contents of the selection")
@CommandPermissions("worldedit.region.move")
@Logging(ORIENTATION_REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int move(Actor actor, World world, EditSession editSession, LocalSession session, @Selection Region region, @Arg(desc = "# of blocks to move", def = "1") int count, @Arg(desc = "The direction to move", def = Direction.AIM) @Direction(includeDiagonals = true) BlockVector3 direction, @Arg(desc = "The pattern of blocks to leave", def = "air") Pattern replace, @Switch(name = 's', desc = "Shift the selection to the target location") 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 {
checkCommandArgument(count >= 1, "Count must be >= 1");
// 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.moveRegion(region, direction, count, copyEntities, copyBiomes, combinedMask, replace);
if (moveSelection) {
try {
region.shift(direction.multiply(count));
session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session);
} catch (RegionOperationException e) {
actor.printError(TextComponent.of(e.getMessage()));
}
}
actor.print(Caption.of("worldedit.move.moved", TextComponent.of(affected)));
return affected;
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class RegionCommands method nbtinfo.
@Command(name = "/nbtinfo", aliases = "/nbt", desc = "View nbt info for a block")
@CommandPermissions("worldedit.nbtinfo")
public void nbtinfo(Player player, EditSession editSession) {
Location pos = player.getBlockTrace(128);
if (pos == null) {
player.print(Caption.of("fawe.navigation.no.block"));
return;
}
CompoundTag nbt = editSession.getFullBlock(pos.toBlockPoint()).getNbtData();
if (nbt != null) {
player.print(TextComponent.of(nbt.getValue().toString()));
} else {
player.print(Caption.of("fawe.navigation.no.block"));
}
}
Aggregations