Search in sources :

Example 1 with FlattenBrush

use of com.fastasyncworldedit.core.command.tool.brush.FlattenBrush 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)

Aggregations

FlattenBrush (com.fastasyncworldedit.core.command.tool.brush.FlattenBrush)1 HeightBrush (com.fastasyncworldedit.core.command.tool.brush.HeightBrush)1 EmptyClipboardException (com.sk89q.worldedit.EmptyClipboardException)1 Paint (com.sk89q.worldedit.function.factory.Paint)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1