Search in sources :

Example 1 with Brush

use of com.sk89q.worldedit.command.tool.brush.Brush in project FastAsyncWorldEdit by IntellectualSites.

the class BrushCommands method scatterBrush.

@Command(name = "scatter", desc = "Scatter a pattern on a surface", descFooter = "Set a number of blocks randomly on a surface each a certain distance apart.\n" + "Video: https://youtu.be/RPZIaTbqoZw?t=34s")
@CommandPermissions("worldedit.brush.scatter")
public void scatterBrush(InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "radius", def = "5") Expression radius, @Arg(desc = "points", def = "5") double points, @Arg(desc = "distance", def = "1") double distance, @Switch(name = 'o', desc = "Overlay the block") boolean overlay) throws WorldEditException {
    worldEdit.checkMaxBrushRadius(radius);
    Brush brush;
    if (overlay) {
        brush = new ScatterOverlayBrush((int) points, (int) distance);
    } else {
        brush = new ScatterBrush((int) points, (int) distance);
    }
    set(context, brush, "worldedit.brush.scatter").setSize(radius).setFill(fill);
}
Also used : ScatterBrush(com.fastasyncworldedit.core.command.tool.brush.ScatterBrush) ScatterOverlayBrush(com.fastasyncworldedit.core.command.tool.brush.ScatterOverlayBrush) HollowSphereBrush(com.sk89q.worldedit.command.tool.brush.HollowSphereBrush) HeightBrush(com.fastasyncworldedit.core.command.tool.brush.HeightBrush) SphereBrush(com.sk89q.worldedit.command.tool.brush.SphereBrush) ScatterBrush(com.fastasyncworldedit.core.command.tool.brush.ScatterBrush) CopyPastaBrush(com.fastasyncworldedit.core.command.tool.brush.CopyPastaBrush) RaiseBrush(com.fastasyncworldedit.core.command.tool.brush.RaiseBrush) SnowSmoothBrush(com.sk89q.worldedit.command.tool.brush.SnowSmoothBrush) ClipboardBrush(com.sk89q.worldedit.command.tool.brush.ClipboardBrush) GravityBrush(com.sk89q.worldedit.command.tool.brush.GravityBrush) FlattenBrush(com.fastasyncworldedit.core.command.tool.brush.FlattenBrush) BlobBrush(com.fastasyncworldedit.core.command.tool.brush.BlobBrush) SweepBrush(com.fastasyncworldedit.core.command.tool.sweep.SweepBrush) CircleBrush(com.fastasyncworldedit.core.command.tool.brush.CircleBrush) SplatterBrush(com.fastasyncworldedit.core.command.tool.brush.SplatterBrush) CatenaryBrush(com.fastasyncworldedit.core.command.tool.brush.CatenaryBrush) RecurseBrush(com.fastasyncworldedit.core.command.tool.brush.RecurseBrush) CylinderBrush(com.sk89q.worldedit.command.tool.brush.CylinderBrush) ScatterOverlayBrush(com.fastasyncworldedit.core.command.tool.brush.ScatterOverlayBrush) StencilBrush(com.fastasyncworldedit.core.command.tool.brush.StencilBrush) LineBrush(com.fastasyncworldedit.core.command.tool.brush.LineBrush) Brush(com.sk89q.worldedit.command.tool.brush.Brush) ButcherBrush(com.sk89q.worldedit.command.tool.brush.ButcherBrush) ErodeBrush(com.fastasyncworldedit.core.command.tool.brush.ErodeBrush) SurfaceSphereBrush(com.fastasyncworldedit.core.command.tool.brush.SurfaceSphereBrush) SplineBrush(com.fastasyncworldedit.core.command.tool.brush.SplineBrush) HollowCylinderBrush(com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush) SmoothBrush(com.sk89q.worldedit.command.tool.brush.SmoothBrush) LayerBrush(com.fastasyncworldedit.core.command.tool.brush.LayerBrush) CommandBrush(com.fastasyncworldedit.core.command.tool.brush.CommandBrush) ImageBrush(com.fastasyncworldedit.core.command.tool.brush.ImageBrush) ShatterBrush(com.fastasyncworldedit.core.command.tool.brush.ShatterBrush) OperationFactoryBrush(com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush) ScatterCommand(com.fastasyncworldedit.core.command.tool.brush.ScatterCommand) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 2 with Brush

use of com.sk89q.worldedit.command.tool.brush.Brush in project FastAsyncWorldEdit by IntellectualSites.

the class BrushCommands method sphereBrush.

@Command(name = "sphere", aliases = { "s" }, desc = "Choose the sphere brush")
@CommandPermissions("worldedit.brush.sphere")
public void sphereBrush(Player player, InjectedValueAccess context, @Arg(desc = "The pattern of blocks to set") Pattern pattern, @Arg(desc = "The radius of the sphere", def = "2") Expression radius, @Switch(name = 'h', desc = "Create hollow spheres instead") boolean hollow, @Switch(name = 'f', desc = "Create falling spheres instead") boolean falling) throws WorldEditException {
    worldEdit.checkMaxBrushRadius(radius);
    Brush brush;
    if (hollow) {
        brush = new HollowSphereBrush();
    } else {
        // FAWE start - Suggest different brush material if sand or gravel is used
        if (pattern instanceof BlockStateHolder) {
            BlockType type = ((BlockStateHolder) pattern).getBlockType();
            switch(type.getId()) {
                case "minecraft:sand":
                case "minecraft:gravel":
                    player.print(Caption.of("fawe.worldedit.brush.brush.try.other"));
                    falling = true;
                    break;
                default:
                    break;
            }
        }
        if (falling) {
            brush = new FallingSphere();
        } else {
            brush = new SphereBrush();
        }
    }
    // FAWE end
    set(context, brush, "worldedit.brush.sphere").setSize(radius).setFill(pattern);
}
Also used : HollowSphereBrush(com.sk89q.worldedit.command.tool.brush.HollowSphereBrush) BlockType(com.sk89q.worldedit.world.block.BlockType) BlockStateHolder(com.sk89q.worldedit.world.block.BlockStateHolder) FallingSphere(com.fastasyncworldedit.core.command.tool.brush.FallingSphere) HollowSphereBrush(com.sk89q.worldedit.command.tool.brush.HollowSphereBrush) HeightBrush(com.fastasyncworldedit.core.command.tool.brush.HeightBrush) SphereBrush(com.sk89q.worldedit.command.tool.brush.SphereBrush) ScatterBrush(com.fastasyncworldedit.core.command.tool.brush.ScatterBrush) CopyPastaBrush(com.fastasyncworldedit.core.command.tool.brush.CopyPastaBrush) RaiseBrush(com.fastasyncworldedit.core.command.tool.brush.RaiseBrush) SnowSmoothBrush(com.sk89q.worldedit.command.tool.brush.SnowSmoothBrush) ClipboardBrush(com.sk89q.worldedit.command.tool.brush.ClipboardBrush) GravityBrush(com.sk89q.worldedit.command.tool.brush.GravityBrush) FlattenBrush(com.fastasyncworldedit.core.command.tool.brush.FlattenBrush) BlobBrush(com.fastasyncworldedit.core.command.tool.brush.BlobBrush) SweepBrush(com.fastasyncworldedit.core.command.tool.sweep.SweepBrush) CircleBrush(com.fastasyncworldedit.core.command.tool.brush.CircleBrush) SplatterBrush(com.fastasyncworldedit.core.command.tool.brush.SplatterBrush) CatenaryBrush(com.fastasyncworldedit.core.command.tool.brush.CatenaryBrush) RecurseBrush(com.fastasyncworldedit.core.command.tool.brush.RecurseBrush) CylinderBrush(com.sk89q.worldedit.command.tool.brush.CylinderBrush) ScatterOverlayBrush(com.fastasyncworldedit.core.command.tool.brush.ScatterOverlayBrush) StencilBrush(com.fastasyncworldedit.core.command.tool.brush.StencilBrush) LineBrush(com.fastasyncworldedit.core.command.tool.brush.LineBrush) Brush(com.sk89q.worldedit.command.tool.brush.Brush) ButcherBrush(com.sk89q.worldedit.command.tool.brush.ButcherBrush) ErodeBrush(com.fastasyncworldedit.core.command.tool.brush.ErodeBrush) SurfaceSphereBrush(com.fastasyncworldedit.core.command.tool.brush.SurfaceSphereBrush) SplineBrush(com.fastasyncworldedit.core.command.tool.brush.SplineBrush) HollowCylinderBrush(com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush) SmoothBrush(com.sk89q.worldedit.command.tool.brush.SmoothBrush) LayerBrush(com.fastasyncworldedit.core.command.tool.brush.LayerBrush) CommandBrush(com.fastasyncworldedit.core.command.tool.brush.CommandBrush) ImageBrush(com.fastasyncworldedit.core.command.tool.brush.ImageBrush) ShatterBrush(com.fastasyncworldedit.core.command.tool.brush.ShatterBrush) OperationFactoryBrush(com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush) HollowSphereBrush(com.sk89q.worldedit.command.tool.brush.HollowSphereBrush) SphereBrush(com.sk89q.worldedit.command.tool.brush.SphereBrush) SurfaceSphereBrush(com.fastasyncworldedit.core.command.tool.brush.SurfaceSphereBrush) ScatterCommand(com.fastasyncworldedit.core.command.tool.brush.ScatterCommand) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 3 with Brush

use of com.sk89q.worldedit.command.tool.brush.Brush in project FastAsyncWorldEdit by IntellectualSites.

the class BrushCommands method blobBrush.

@Command(name = "rock", aliases = { "blob" }, desc = "Creates a distorted sphere")
@CommandPermissions("worldedit.brush.rock")
public void blobBrush(InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "radii to multiply x,y,z by", def = "10") Vector3 radius, @Arg(name = "roundness", desc = "roundness", def = "100") double sphericity, @Arg(desc = "double", def = "30") double frequency, @Arg(desc = "double", def = "50") double amplitude) throws WorldEditException {
    double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ());
    worldEdit.checkMaxBrushRadius(max);
    Brush brush = new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100);
    set(context, brush, "worldedit.brush.rock").setSize(max).setFill(fill);
}
Also used : BlobBrush(com.fastasyncworldedit.core.command.tool.brush.BlobBrush) HollowSphereBrush(com.sk89q.worldedit.command.tool.brush.HollowSphereBrush) HeightBrush(com.fastasyncworldedit.core.command.tool.brush.HeightBrush) SphereBrush(com.sk89q.worldedit.command.tool.brush.SphereBrush) ScatterBrush(com.fastasyncworldedit.core.command.tool.brush.ScatterBrush) CopyPastaBrush(com.fastasyncworldedit.core.command.tool.brush.CopyPastaBrush) RaiseBrush(com.fastasyncworldedit.core.command.tool.brush.RaiseBrush) SnowSmoothBrush(com.sk89q.worldedit.command.tool.brush.SnowSmoothBrush) ClipboardBrush(com.sk89q.worldedit.command.tool.brush.ClipboardBrush) GravityBrush(com.sk89q.worldedit.command.tool.brush.GravityBrush) FlattenBrush(com.fastasyncworldedit.core.command.tool.brush.FlattenBrush) BlobBrush(com.fastasyncworldedit.core.command.tool.brush.BlobBrush) SweepBrush(com.fastasyncworldedit.core.command.tool.sweep.SweepBrush) CircleBrush(com.fastasyncworldedit.core.command.tool.brush.CircleBrush) SplatterBrush(com.fastasyncworldedit.core.command.tool.brush.SplatterBrush) CatenaryBrush(com.fastasyncworldedit.core.command.tool.brush.CatenaryBrush) RecurseBrush(com.fastasyncworldedit.core.command.tool.brush.RecurseBrush) CylinderBrush(com.sk89q.worldedit.command.tool.brush.CylinderBrush) ScatterOverlayBrush(com.fastasyncworldedit.core.command.tool.brush.ScatterOverlayBrush) StencilBrush(com.fastasyncworldedit.core.command.tool.brush.StencilBrush) LineBrush(com.fastasyncworldedit.core.command.tool.brush.LineBrush) Brush(com.sk89q.worldedit.command.tool.brush.Brush) ButcherBrush(com.sk89q.worldedit.command.tool.brush.ButcherBrush) ErodeBrush(com.fastasyncworldedit.core.command.tool.brush.ErodeBrush) SurfaceSphereBrush(com.fastasyncworldedit.core.command.tool.brush.SurfaceSphereBrush) SplineBrush(com.fastasyncworldedit.core.command.tool.brush.SplineBrush) HollowCylinderBrush(com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush) SmoothBrush(com.sk89q.worldedit.command.tool.brush.SmoothBrush) LayerBrush(com.fastasyncworldedit.core.command.tool.brush.LayerBrush) CommandBrush(com.fastasyncworldedit.core.command.tool.brush.CommandBrush) ImageBrush(com.fastasyncworldedit.core.command.tool.brush.ImageBrush) ShatterBrush(com.fastasyncworldedit.core.command.tool.brush.ShatterBrush) OperationFactoryBrush(com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush) ScatterCommand(com.fastasyncworldedit.core.command.tool.brush.ScatterCommand) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 4 with Brush

use of com.sk89q.worldedit.command.tool.brush.Brush in project FastAsyncWorldEdit by IntellectualSites.

the class BrushCommands method set.

public BrushSettings set(InjectedValueAccess context, Brush brush, String permission) throws InvalidToolBindException {
    Player player = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"));
    LocalSession session = player.getSession();
    BrushSettings bs = new BrushSettings();
    BrushTool tool = session.getBrushTool(player, false);
    if (tool != null) {
        BrushSettings currentContext = tool.getContext();
        if (currentContext != null) {
            Brush currentBrush = currentContext.getBrush();
            if (currentBrush != null && currentBrush.getClass() == brush.getClass()) {
                bs = currentContext;
            }
        }
    }
    Arguments arguments = context.injectedValue(Key.of(Arguments.class)).orElse(null);
    if (arguments != null) {
        String args = arguments.get();
        bs.addSetting(BrushSettings.SettingType.BRUSH, args.substring(args.indexOf(' ') + 1));
    }
    bs.addPermission(permission);
    bs.setBrush(brush);
    return process(player, arguments, bs);
}
Also used : BrushTool(com.sk89q.worldedit.command.tool.BrushTool) Player(com.sk89q.worldedit.entity.Player) LocalSession(com.sk89q.worldedit.LocalSession) Arguments(com.sk89q.worldedit.command.argument.Arguments) BrushSettings(com.fastasyncworldedit.core.command.tool.brush.BrushSettings) HollowSphereBrush(com.sk89q.worldedit.command.tool.brush.HollowSphereBrush) HeightBrush(com.fastasyncworldedit.core.command.tool.brush.HeightBrush) SphereBrush(com.sk89q.worldedit.command.tool.brush.SphereBrush) ScatterBrush(com.fastasyncworldedit.core.command.tool.brush.ScatterBrush) CopyPastaBrush(com.fastasyncworldedit.core.command.tool.brush.CopyPastaBrush) RaiseBrush(com.fastasyncworldedit.core.command.tool.brush.RaiseBrush) SnowSmoothBrush(com.sk89q.worldedit.command.tool.brush.SnowSmoothBrush) ClipboardBrush(com.sk89q.worldedit.command.tool.brush.ClipboardBrush) GravityBrush(com.sk89q.worldedit.command.tool.brush.GravityBrush) FlattenBrush(com.fastasyncworldedit.core.command.tool.brush.FlattenBrush) BlobBrush(com.fastasyncworldedit.core.command.tool.brush.BlobBrush) SweepBrush(com.fastasyncworldedit.core.command.tool.sweep.SweepBrush) CircleBrush(com.fastasyncworldedit.core.command.tool.brush.CircleBrush) SplatterBrush(com.fastasyncworldedit.core.command.tool.brush.SplatterBrush) CatenaryBrush(com.fastasyncworldedit.core.command.tool.brush.CatenaryBrush) RecurseBrush(com.fastasyncworldedit.core.command.tool.brush.RecurseBrush) CylinderBrush(com.sk89q.worldedit.command.tool.brush.CylinderBrush) ScatterOverlayBrush(com.fastasyncworldedit.core.command.tool.brush.ScatterOverlayBrush) StencilBrush(com.fastasyncworldedit.core.command.tool.brush.StencilBrush) LineBrush(com.fastasyncworldedit.core.command.tool.brush.LineBrush) Brush(com.sk89q.worldedit.command.tool.brush.Brush) ButcherBrush(com.sk89q.worldedit.command.tool.brush.ButcherBrush) ErodeBrush(com.fastasyncworldedit.core.command.tool.brush.ErodeBrush) SurfaceSphereBrush(com.fastasyncworldedit.core.command.tool.brush.SurfaceSphereBrush) SplineBrush(com.fastasyncworldedit.core.command.tool.brush.SplineBrush) HollowCylinderBrush(com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush) SmoothBrush(com.sk89q.worldedit.command.tool.brush.SmoothBrush) LayerBrush(com.fastasyncworldedit.core.command.tool.brush.LayerBrush) CommandBrush(com.fastasyncworldedit.core.command.tool.brush.CommandBrush) ImageBrush(com.fastasyncworldedit.core.command.tool.brush.ImageBrush) ShatterBrush(com.fastasyncworldedit.core.command.tool.brush.ShatterBrush) OperationFactoryBrush(com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush)

Example 5 with Brush

use of com.sk89q.worldedit.command.tool.brush.Brush in project FastAsyncWorldEdit by IntellectualSites.

the class BrushTool method act.

public boolean act(BrushAction action, Player player, LocalSession session) {
    switch(action) {
        case PRIMARY:
            setContext(primary);
            break;
        case SECONDARY:
            setContext(secondary);
            break;
        default:
            throw new IllegalStateException("Unexpected value: " + action);
    }
    BrushSettings current = getContext();
    Brush brush = current.getBrush();
    if (brush == null) {
        return false;
    }
    if (!current.canUse(player)) {
        player.print(Caption.of("fawe.error.no-perm", StringMan.join(current.getPermissions(), ",")));
        return false;
    }
    try (EditSession editSession = session.createEditSession(player, current.toString())) {
        Location target = player.getBlockTrace(getRange(), true, traceMask);
        if (target == null) {
            editSession.cancel();
            player.print(Caption.of("worldedit.tool.no-block"));
            return true;
        }
        BlockBag bag = session.getBlockBag(player);
        Request.request().setEditSession(editSession);
        Mask mask = current.getMask();
        if (mask != null) {
            Mask existingMask = editSession.getMask();
            if (existingMask == null) {
                editSession.setMask(mask);
            } else if (existingMask instanceof MaskIntersection) {
                ((MaskIntersection) existingMask).add(mask);
            } else {
                MaskIntersection newMask = new MaskIntersection(existingMask);
                newMask.add(mask);
                editSession.setMask(newMask);
            }
        }
        Mask sourceMask = current.getSourceMask();
        if (sourceMask != null) {
            editSession.addSourceMask(sourceMask);
        }
        ResettableExtent transform = current.getTransform();
        if (transform != null) {
            editSession.addTransform(transform);
        }
        try {
            new PatternTraverser(current).reset(editSession);
            double size = current.getSize();
            WorldEdit.getInstance().checkMaxBrushRadius(size);
            brush.build(editSession, target.toBlockPoint(), current.getMaterial(), size);
        } catch (MaxChangedBlocksException e) {
            player.print(Caption.of("worldedit.tool.max-block-changes"));
        } finally {
            session.remember(editSession);
            if (bag != null) {
                bag.flushChanges();
            }
        }
    } finally {
        Request.reset();
    }
    return true;
}
Also used : MaskIntersection(com.sk89q.worldedit.function.mask.MaskIntersection) BlockBag(com.sk89q.worldedit.extent.inventory.BlockBag) SolidBlockMask(com.sk89q.worldedit.function.mask.SolidBlockMask) Mask(com.sk89q.worldedit.function.mask.Mask) PatternTraverser(com.fastasyncworldedit.core.function.pattern.PatternTraverser) EditSession(com.sk89q.worldedit.EditSession) BrushSettings(com.fastasyncworldedit.core.command.tool.brush.BrushSettings) Brush(com.sk89q.worldedit.command.tool.brush.Brush) ResettableExtent(com.fastasyncworldedit.core.extent.ResettableExtent) Location(com.sk89q.worldedit.util.Location) MaxChangedBlocksException(com.sk89q.worldedit.MaxChangedBlocksException)

Aggregations

Brush (com.sk89q.worldedit.command.tool.brush.Brush)5 BlobBrush (com.fastasyncworldedit.core.command.tool.brush.BlobBrush)4 CatenaryBrush (com.fastasyncworldedit.core.command.tool.brush.CatenaryBrush)4 CircleBrush (com.fastasyncworldedit.core.command.tool.brush.CircleBrush)4 CommandBrush (com.fastasyncworldedit.core.command.tool.brush.CommandBrush)4 CopyPastaBrush (com.fastasyncworldedit.core.command.tool.brush.CopyPastaBrush)4 ErodeBrush (com.fastasyncworldedit.core.command.tool.brush.ErodeBrush)4 FlattenBrush (com.fastasyncworldedit.core.command.tool.brush.FlattenBrush)4 HeightBrush (com.fastasyncworldedit.core.command.tool.brush.HeightBrush)4 ImageBrush (com.fastasyncworldedit.core.command.tool.brush.ImageBrush)4 LayerBrush (com.fastasyncworldedit.core.command.tool.brush.LayerBrush)4 LineBrush (com.fastasyncworldedit.core.command.tool.brush.LineBrush)4 RaiseBrush (com.fastasyncworldedit.core.command.tool.brush.RaiseBrush)4 RecurseBrush (com.fastasyncworldedit.core.command.tool.brush.RecurseBrush)4 ScatterBrush (com.fastasyncworldedit.core.command.tool.brush.ScatterBrush)4 ScatterOverlayBrush (com.fastasyncworldedit.core.command.tool.brush.ScatterOverlayBrush)4 ShatterBrush (com.fastasyncworldedit.core.command.tool.brush.ShatterBrush)4 SplatterBrush (com.fastasyncworldedit.core.command.tool.brush.SplatterBrush)4 SplineBrush (com.fastasyncworldedit.core.command.tool.brush.SplineBrush)4 StencilBrush (com.fastasyncworldedit.core.command.tool.brush.StencilBrush)4