Search in sources :

Example 1 with HeightBrush

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

the class BrushCommands method terrainBrush.

private void terrainBrush(Player player, LocalSession session, Expression radius, String image, int rotation, double yscale, boolean flat, boolean randomRotate, boolean layers, boolean smooth, Shape shape, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
    worldEdit.checkMaxBrushRadius(radius);
    InputStream stream = getHeightmapStream(image);
    HeightBrush brush;
    int minY = player.getWorld().getMinY();
    int maxY = player.getWorld().getMaxY();
    if (flat) {
        try {
            brush = new FlattenBrush(stream, rotation, yscale, layers, smooth, "#clipboard".equalsIgnoreCase(image) ? session.getClipboard().getClipboard() : null, shape, minY, maxY);
        } catch (EmptyClipboardException ignored) {
            brush = new FlattenBrush(stream, rotation, yscale, layers, smooth, null, shape, minY, maxY);
        }
    } else {
        try {
            brush = new HeightBrush(stream, rotation, yscale, layers, smooth, "#clipboard".equalsIgnoreCase(image) ? session.getClipboard().getClipboard() : null, minY, maxY);
        } catch (EmptyClipboardException ignored) {
            brush = new HeightBrush(stream, rotation, yscale, layers, smooth, null, minY, maxY);
        }
    }
    if (randomRotate) {
        brush.setRandomRotate(true);
    }
    set(context, brush, "worldedit.brush.height").setSize(radius);
}
Also used : EmptyClipboardException(com.sk89q.worldedit.EmptyClipboardException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FlattenBrush(com.fastasyncworldedit.core.command.tool.brush.FlattenBrush) HeightBrush(com.fastasyncworldedit.core.command.tool.brush.HeightBrush) Paint(com.sk89q.worldedit.function.factory.Paint)

Example 2 with HeightBrush

use of com.fastasyncworldedit.core.command.tool.brush.HeightBrush 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)2 EmptyClipboardException (com.sk89q.worldedit.EmptyClipboardException)2 Paint (com.sk89q.worldedit.function.factory.Paint)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 FlattenBrush (com.fastasyncworldedit.core.command.tool.brush.FlattenBrush)1 ScatterCommand (com.fastasyncworldedit.core.command.tool.brush.ScatterCommand)1 StencilBrush (com.fastasyncworldedit.core.command.tool.brush.StencilBrush)1 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)1 Command (org.enginehub.piston.annotation.Command)1