Search in sources :

Example 6 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm in project FastAsyncWorldEdit by IntellectualSites.

the class RegionCommands method curve.

@Command(name = "/curve", desc = "Draws a spline through selected points", descFooter = "Can only be used with a convex polyhedral selection")
@CommandPermissions("worldedit.region.curve")
@Logging(REGION)
@Confirm(Confirm.Processor.REGION)
public int curve(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "The pattern of blocks to place") Pattern pattern, @Arg(desc = "The thickness of the curve", def = "0") int thickness, @Switch(name = 'h', desc = "Generate only a shell") boolean shell) throws WorldEditException {
    if (!(region instanceof ConvexPolyhedralRegion)) {
        actor.print(Caption.of("worldedit.curve.invalid-type"));
        return 0;
    }
    checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
    ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
    List<BlockVector3> vectors = new ArrayList<>(cpregion.getVertices());
    int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
    actor.print(Caption.of("worldedit.curve.changed", TextComponent.of(blocksChanged)));
    return blocksChanged;
}
Also used : ConvexPolyhedralRegion(com.sk89q.worldedit.regions.ConvexPolyhedralRegion) ArrayList(java.util.ArrayList) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 7 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm 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;
    }
}
Also used : Player(com.sk89q.worldedit.entity.Player) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Vector3(com.sk89q.worldedit.math.Vector3) ExpressionException(com.sk89q.worldedit.internal.expression.ExpressionException) 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 8 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm 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;
}
Also used : MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) 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 9 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm 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;
}
Also used : MaskIntersection(com.sk89q.worldedit.function.mask.MaskIntersection) SolidBlockMask(com.sk89q.worldedit.function.mask.SolidBlockMask) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) Mask(com.sk89q.worldedit.function.mask.Mask) RegionOperationException(com.sk89q.worldedit.regions.RegionOperationException) MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) 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 10 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm in project FastAsyncWorldEdit by IntellectualSites.

the class ConsumeBindings method radiusVec3.

@Binding
@Confirm(Confirm.Processor.RADIUS)
public BlockVector3 radiusVec3(Actor actor, InjectedValueAccess context, String argument) {
    BlockVector3 radius = manager.parseConverter(argument, context, BlockVector3.class);
    double length = radius.length();
    Confirm.Processor.RADIUS.check(actor, context, length);
    return radius;
}
Also used : BlockVector3(com.sk89q.worldedit.math.BlockVector3) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm)

Aggregations

Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)22 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)20 Command (org.enginehub.piston.annotation.Command)20 Logging (com.sk89q.worldedit.command.util.Logging)17 Preload (com.sk89q.worldedit.command.util.annotation.Preload)15 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)10 MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)8 Mask (com.sk89q.worldedit.function.mask.Mask)6 ExistingBlockMask (com.sk89q.worldedit.function.mask.ExistingBlockMask)5 FaweLimit (com.fastasyncworldedit.core.limit.FaweLimit)3 SolidBlockMask (com.sk89q.worldedit.function.mask.SolidBlockMask)3 ExpressionException (com.sk89q.worldedit.internal.expression.ExpressionException)3 Vector3 (com.sk89q.worldedit.math.Vector3)3 Region (com.sk89q.worldedit.regions.Region)3 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)2 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)2 RollbackOptimizedHistory (com.fastasyncworldedit.core.history.RollbackOptimizedHistory)2 Player (com.sk89q.worldedit.entity.Player)2 BlockArrayClipboard (com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard)2 RegionMask (com.sk89q.worldedit.function.mask.RegionMask)2