Search in sources :

Example 1 with StencilBrush

use of com.fastasyncworldedit.core.command.tool.brush.StencilBrush in project FastAsyncWorldEdit by IntellectualSites.

the class BrushCommands method stencilBrush.

@Command(name = "stencil", desc = "Use a height map to paint a surface", descFooter = "Use a height map to paint any surface.")
@CommandPermissions("worldedit.brush.stencil")
public void stencilBrush(Player player, LocalSession session, InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "Expression", def = "5") Expression radius, @Arg(desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Range(from = 0, to = 360) int rotation, @Arg(desc = "double", def = "1") double yscale, @Switch(name = 'w', desc = "Apply at maximum saturation") boolean onlyWhite, @Switch(name = 'r', desc = "Apply random rotation") boolean randomRotate) throws WorldEditException, FileNotFoundException {
    worldEdit.checkMaxBrushRadius(radius);
    InputStream stream = getHeightmapStream(image);
    HeightBrush brush;
    int minY = player.getWorld().getMinY();
    int maxY = player.getWorld().getMaxY();
    try {
        brush = new StencilBrush(stream, rotation, yscale, onlyWhite, "#clipboard".equalsIgnoreCase(image) ? session.getClipboard().getClipboard() : null, minY, maxY);
    } catch (EmptyClipboardException ignored) {
        brush = new StencilBrush(stream, rotation, yscale, onlyWhite, null, minY, maxY);
    }
    if (randomRotate) {
        brush.setRandomRotate(true);
    }
    set(context, brush, "worldedit.brush.stencil").setSize(radius).setFill(fill);
}
Also used : EmptyClipboardException(com.sk89q.worldedit.EmptyClipboardException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) HeightBrush(com.fastasyncworldedit.core.command.tool.brush.HeightBrush) Paint(com.sk89q.worldedit.function.factory.Paint) StencilBrush(com.fastasyncworldedit.core.command.tool.brush.StencilBrush) ScatterCommand(com.fastasyncworldedit.core.command.tool.brush.ScatterCommand) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

HeightBrush (com.fastasyncworldedit.core.command.tool.brush.HeightBrush)1 ScatterCommand (com.fastasyncworldedit.core.command.tool.brush.ScatterCommand)1 StencilBrush (com.fastasyncworldedit.core.command.tool.brush.StencilBrush)1 EmptyClipboardException (com.sk89q.worldedit.EmptyClipboardException)1 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)1 Paint (com.sk89q.worldedit.function.factory.Paint)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Command (org.enginehub.piston.annotation.Command)1