use of com.fastasyncworldedit.core.command.tool.brush.ImageBrush in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCommands method imageBrush.
@Command(name = "image", desc = "Use a height map to paint a surface", descFooter = "Use a height map to paint any surface.\n")
@CommandPermissions("worldedit.brush.image")
public void imageBrush(LocalSession session, InjectedValueAccess context, @Arg(desc = "Image URL (imgur only)") String imageURL, @Arg(desc = "The size of the brush", def = "5") Expression radius, @Arg(def = "1", desc = "scale height") double yscale, @Switch(name = 'a', desc = "Use image Alpha") boolean alpha, @Switch(name = 'f', desc = "Blend the image with existing terrain") boolean fadeOut) throws WorldEditException, IOException {
URL url = new URL(imageURL);
if (!url.getHost().equalsIgnoreCase("i.imgur.com")) {
throw new IOException("Only i.imgur.com links are allowed!");
}
BufferedImage image = MainUtil.readImage(url);
worldEdit.checkMaxBrushRadius(radius);
if (yscale != 1) {
ImageUtil.scaleAlpha(image, yscale);
alpha = true;
}
if (fadeOut) {
ImageUtil.fadeAlpha(image);
alpha = true;
}
ImageBrush brush = new ImageBrush(image, session, alpha);
set(context, brush, "worldedit.brush.image").setSize(radius);
}
Aggregations