Search in sources :

Example 11 with Logging

use of com.sk89q.worldedit.command.util.Logging 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 12 with Logging

use of com.sk89q.worldedit.command.util.Logging 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 13 with Logging

use of com.sk89q.worldedit.command.util.Logging 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 14 with Logging

use of com.sk89q.worldedit.command.util.Logging 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;
}
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) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Logging(com.sk89q.worldedit.command.util.Logging) Preload(com.sk89q.worldedit.command.util.annotation.Preload) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 15 with Logging

use of com.sk89q.worldedit.command.util.Logging 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)

Aggregations

Logging (com.sk89q.worldedit.command.util.Logging)47 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)45 Command (org.enginehub.piston.annotation.Command)45 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)25 Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)17 Preload (com.sk89q.worldedit.command.util.annotation.Preload)15 Region (com.sk89q.worldedit.regions.Region)13 MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)10 ExistingBlockMask (com.sk89q.worldedit.function.mask.ExistingBlockMask)8 Mask (com.sk89q.worldedit.function.mask.Mask)7 Player (com.sk89q.worldedit.entity.Player)6 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)5 Locatable (com.sk89q.worldedit.extension.platform.Locatable)4 SolidBlockMask (com.sk89q.worldedit.function.mask.SolidBlockMask)4 Vector3 (com.sk89q.worldedit.math.Vector3)4 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)3 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)3 LocalConfiguration (com.sk89q.worldedit.LocalConfiguration)3 BlockArrayClipboard (com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard)3 RegionOperationException (com.sk89q.worldedit.regions.RegionOperationException)3