2011-01-30 08:34:13 +00:00
|
|
|
// $Id$
|
|
|
|
/*
|
|
|
|
* WorldEdit
|
|
|
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.sk89q.worldedit.commands;
|
|
|
|
|
2011-02-18 06:53:44 +00:00
|
|
|
import com.sk89q.minecraft.util.commands.Command;
|
|
|
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
|
|
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
2011-01-30 08:34:13 +00:00
|
|
|
import com.sk89q.worldedit.CuboidClipboard;
|
|
|
|
import com.sk89q.worldedit.EditSession;
|
|
|
|
import com.sk89q.worldedit.LocalConfiguration;
|
|
|
|
import com.sk89q.worldedit.LocalPlayer;
|
|
|
|
import com.sk89q.worldedit.LocalSession;
|
|
|
|
import com.sk89q.worldedit.Vector;
|
|
|
|
import com.sk89q.worldedit.WorldEdit;
|
|
|
|
import com.sk89q.worldedit.WorldEditException;
|
2011-03-12 08:49:35 +00:00
|
|
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
|
|
import com.sk89q.worldedit.blocks.BlockID;
|
|
|
|
import com.sk89q.worldedit.masks.BlockTypeMask;
|
2011-02-18 23:14:43 +00:00
|
|
|
import com.sk89q.worldedit.patterns.Pattern;
|
2011-03-12 08:49:35 +00:00
|
|
|
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
2011-02-19 07:36:08 +00:00
|
|
|
import com.sk89q.worldedit.tools.BrushTool;
|
2011-02-18 23:14:43 +00:00
|
|
|
import com.sk89q.worldedit.tools.brushes.ClipboardBrush;
|
|
|
|
import com.sk89q.worldedit.tools.brushes.CylinderBrush;
|
|
|
|
import com.sk89q.worldedit.tools.brushes.HollowCylinderBrush;
|
|
|
|
import com.sk89q.worldedit.tools.brushes.HollowSphereBrush;
|
2011-02-19 07:48:27 +00:00
|
|
|
import com.sk89q.worldedit.tools.brushes.SmoothBrush;
|
2011-02-18 23:14:43 +00:00
|
|
|
import com.sk89q.worldedit.tools.brushes.SphereBrush;
|
2011-01-30 08:34:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Brush shape commands.
|
|
|
|
*
|
|
|
|
* @author sk89q
|
|
|
|
*/
|
2011-02-18 23:14:43 +00:00
|
|
|
public class BrushCommands {
|
2011-01-30 08:34:13 +00:00
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "sphere", "s" },
|
2011-01-30 08:34:13 +00:00
|
|
|
usage = "<block> [radius]",
|
|
|
|
flags = "h",
|
|
|
|
desc = "Choose the sphere brush",
|
Added help text for most commands that take flags.
//generate, //regen, //deform, //[h]cyl, //[h]sphere, //chunk, //outset, //inset, //stack, //move, //smooth, //paste, //flip, /search //distr /butcher, //brush sphere/cyl/clipboard/smooth
Only //replace and /replacenear are still missing.
2011-12-05 10:21:40 +00:00
|
|
|
help =
|
|
|
|
"Chooses the sphere brush.\n" +
|
|
|
|
"The -h flag creates hollow spheres instead.",
|
2011-01-30 08:34:13 +00:00
|
|
|
min = 1,
|
|
|
|
max = 2
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.brush.sphere")
|
2011-01-30 08:34:13 +00:00
|
|
|
public static void sphereBrush(CommandContext args, WorldEdit we,
|
|
|
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
|
|
|
throws WorldEditException {
|
|
|
|
|
|
|
|
LocalConfiguration config = we.getConfiguration();
|
|
|
|
|
2011-08-07 03:19:55 +00:00
|
|
|
double radius = args.argsLength() > 1 ? args.getDouble(1) : 2;
|
2011-01-30 08:34:13 +00:00
|
|
|
if (radius > config.maxBrushRadius) {
|
|
|
|
player.printError("Maximum allowed brush radius: "
|
|
|
|
+ config.maxBrushRadius);
|
|
|
|
return;
|
|
|
|
}
|
2011-02-18 23:14:43 +00:00
|
|
|
|
2011-02-19 07:36:08 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
2011-02-18 23:14:43 +00:00
|
|
|
Pattern fill = we.getBlockPattern(player, args.getString(0));
|
|
|
|
tool.setFill(fill);
|
|
|
|
tool.setSize(radius);
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-01-30 08:34:13 +00:00
|
|
|
if (args.hasFlag('h')) {
|
2011-05-02 00:06:40 +00:00
|
|
|
tool.setBrush(new HollowSphereBrush(), "worldedit.brush.sphere");
|
2011-01-30 08:34:13 +00:00
|
|
|
} else {
|
2011-05-02 00:06:40 +00:00
|
|
|
tool.setBrush(new SphereBrush(), "worldedit.brush.sphere");
|
2011-01-30 08:34:13 +00:00
|
|
|
}
|
2011-02-18 23:14:43 +00:00
|
|
|
|
2011-08-08 00:22:29 +00:00
|
|
|
player.print(String.format("Sphere brush shape equipped (%.0f).",
|
2011-02-18 23:14:43 +00:00
|
|
|
radius));
|
2011-01-30 08:34:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "cylinder", "cyl", "c" },
|
2011-01-30 08:34:13 +00:00
|
|
|
usage = "<block> [radius] [height]",
|
|
|
|
flags = "h",
|
|
|
|
desc = "Choose the cylinder brush",
|
Added help text for most commands that take flags.
//generate, //regen, //deform, //[h]cyl, //[h]sphere, //chunk, //outset, //inset, //stack, //move, //smooth, //paste, //flip, /search //distr /butcher, //brush sphere/cyl/clipboard/smooth
Only //replace and /replacenear are still missing.
2011-12-05 10:21:40 +00:00
|
|
|
help =
|
|
|
|
"Chooses the cylinder brush.\n" +
|
|
|
|
"The -h flag creates hollow cylinders instead.",
|
2011-01-30 08:34:13 +00:00
|
|
|
min = 1,
|
2011-02-18 23:14:43 +00:00
|
|
|
max = 3
|
2011-01-30 08:34:13 +00:00
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.brush.cylinder")
|
2011-01-30 08:34:13 +00:00
|
|
|
public static void cylinderBrush(CommandContext args, WorldEdit we,
|
|
|
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
|
|
|
throws WorldEditException {
|
|
|
|
|
|
|
|
LocalConfiguration config = we.getConfiguration();
|
|
|
|
|
2011-08-07 03:19:55 +00:00
|
|
|
double radius = args.argsLength() > 1 ? args.getDouble(1) : 2;
|
2011-01-30 08:34:13 +00:00
|
|
|
if (radius > config.maxBrushRadius) {
|
|
|
|
player.printError("Maximum allowed brush radius: "
|
|
|
|
+ config.maxBrushRadius);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-18 23:14:43 +00:00
|
|
|
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
|
2011-01-30 08:34:13 +00:00
|
|
|
if (height > config.maxBrushRadius) {
|
|
|
|
player.printError("Maximum allowed brush radius/height: "
|
|
|
|
+ config.maxBrushRadius);
|
|
|
|
return;
|
|
|
|
}
|
2011-02-18 23:14:43 +00:00
|
|
|
|
2011-02-19 07:36:08 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
2011-02-18 23:14:43 +00:00
|
|
|
Pattern fill = we.getBlockPattern(player, args.getString(0));
|
|
|
|
tool.setFill(fill);
|
|
|
|
tool.setSize(radius);
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-01-30 08:34:13 +00:00
|
|
|
if (args.hasFlag('h')) {
|
2011-05-02 00:06:40 +00:00
|
|
|
tool.setBrush(new HollowCylinderBrush(height), "worldedit.brush.cylinder");
|
2011-01-30 08:34:13 +00:00
|
|
|
} else {
|
2011-05-02 00:06:40 +00:00
|
|
|
tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder");
|
2011-01-30 08:34:13 +00:00
|
|
|
}
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-08-08 00:22:29 +00:00
|
|
|
player.print(String.format("Cylinder brush shape equipped (%.0f by %d).",
|
2011-02-18 23:14:43 +00:00
|
|
|
radius, height));
|
2011-01-30 08:34:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "clipboard", "copy" },
|
2011-01-30 08:34:13 +00:00
|
|
|
usage = "",
|
|
|
|
flags = "a",
|
|
|
|
desc = "Choose the clipboard brush",
|
Added help text for most commands that take flags.
//generate, //regen, //deform, //[h]cyl, //[h]sphere, //chunk, //outset, //inset, //stack, //move, //smooth, //paste, //flip, /search //distr /butcher, //brush sphere/cyl/clipboard/smooth
Only //replace and /replacenear are still missing.
2011-12-05 10:21:40 +00:00
|
|
|
help =
|
|
|
|
"Chooses the clipboard brush.\n" +
|
|
|
|
"The -a flag makes it not paste air.",
|
2011-01-30 08:34:13 +00:00
|
|
|
min = 0,
|
|
|
|
max = 0
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.brush.clipboard")
|
2011-01-30 08:34:13 +00:00
|
|
|
public static void clipboardBrush(CommandContext args, WorldEdit we,
|
|
|
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
|
|
|
throws WorldEditException {
|
|
|
|
|
|
|
|
LocalConfiguration config = we.getConfiguration();
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-01-30 08:34:13 +00:00
|
|
|
CuboidClipboard clipboard = session.getClipboard();
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-01-30 08:34:13 +00:00
|
|
|
if (clipboard == null) {
|
|
|
|
player.printError("Copy something first.");
|
|
|
|
return;
|
|
|
|
}
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-01-30 08:34:13 +00:00
|
|
|
Vector size = clipboard.getSize();
|
|
|
|
|
|
|
|
if (size.getBlockX() > config.maxBrushRadius
|
|
|
|
|| size.getBlockY() > config.maxBrushRadius
|
|
|
|
|| size.getBlockZ() > config.maxBrushRadius) {
|
|
|
|
player.printError("Maximum allowed brush radius/height: "
|
|
|
|
+ config.maxBrushRadius);
|
|
|
|
return;
|
|
|
|
}
|
2011-02-18 23:14:43 +00:00
|
|
|
|
2011-02-19 07:36:08 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
2011-05-02 00:06:40 +00:00
|
|
|
tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')), "worldedit.brush.clipboard");
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-01-30 08:34:13 +00:00
|
|
|
player.print("Clipboard brush shape equipped.");
|
|
|
|
}
|
2011-02-19 07:48:27 +00:00
|
|
|
|
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "smooth" },
|
2011-02-19 07:48:27 +00:00
|
|
|
usage = "[size] [iterations]",
|
2011-08-17 07:33:46 +00:00
|
|
|
flags = "n",
|
2011-02-19 07:48:27 +00:00
|
|
|
desc = "Choose the terrain softener brush",
|
Added help text for most commands that take flags.
//generate, //regen, //deform, //[h]cyl, //[h]sphere, //chunk, //outset, //inset, //stack, //move, //smooth, //paste, //flip, /search //distr /butcher, //brush sphere/cyl/clipboard/smooth
Only //replace and /replacenear are still missing.
2011-12-05 10:21:40 +00:00
|
|
|
help =
|
|
|
|
"Chooses the terrain softener brush.\n" +
|
|
|
|
"The -n flag makes it only consider naturally occuring blocks.",
|
2011-02-19 07:48:27 +00:00
|
|
|
min = 0,
|
|
|
|
max = 2
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.brush.smooth")
|
2011-02-19 07:48:27 +00:00
|
|
|
public static void smoothBrush(CommandContext args, WorldEdit we,
|
|
|
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
|
|
|
throws WorldEditException {
|
|
|
|
|
|
|
|
LocalConfiguration config = we.getConfiguration();
|
|
|
|
|
2011-08-08 00:22:29 +00:00
|
|
|
double radius = args.argsLength() > 0 ? args.getDouble(0) : 2;
|
2011-02-19 07:48:27 +00:00
|
|
|
if (radius > config.maxBrushRadius) {
|
|
|
|
player.printError("Maximum allowed brush radius: "
|
|
|
|
+ config.maxBrushRadius);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int iterations = args.argsLength() > 1 ? args.getInteger(1) : 4;
|
|
|
|
|
|
|
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
|
|
|
tool.setSize(radius);
|
2011-08-17 07:33:46 +00:00
|
|
|
tool.setBrush(new SmoothBrush(iterations, args.hasFlag('n')), "worldedit.brush.smooth");
|
2011-02-19 07:48:27 +00:00
|
|
|
|
2011-08-17 07:33:46 +00:00
|
|
|
player.print(String.format("Smooth brush equipped (%.0f x %dx, using " + (args.hasFlag('n') ? "natural blocks only" : "any block") + ").",
|
2011-02-19 07:48:27 +00:00
|
|
|
radius, iterations));
|
|
|
|
}
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-03-12 08:49:35 +00:00
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "ex", "extinguish" },
|
2011-03-12 08:49:35 +00:00
|
|
|
usage = "[radius]",
|
|
|
|
desc = "Shortcut fire extinguisher brush",
|
|
|
|
min = 0,
|
|
|
|
max = 1
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.brush.ex")
|
2011-03-12 08:49:35 +00:00
|
|
|
public static void extinguishBrush(CommandContext args, WorldEdit we,
|
|
|
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
|
|
|
throws WorldEditException {
|
|
|
|
|
|
|
|
LocalConfiguration config = we.getConfiguration();
|
|
|
|
|
2011-08-08 00:22:29 +00:00
|
|
|
double radius = args.argsLength() > 1 ? args.getDouble(1) : 5;
|
2011-03-12 08:49:35 +00:00
|
|
|
if (radius > config.maxBrushRadius) {
|
|
|
|
player.printError("Maximum allowed brush radius: "
|
|
|
|
+ config.maxBrushRadius);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
|
|
|
Pattern fill = new SingleBlockPattern(new BaseBlock(0));
|
|
|
|
tool.setFill(fill);
|
|
|
|
tool.setSize(radius);
|
|
|
|
tool.setMask(new BlockTypeMask(BlockID.FIRE));
|
2011-05-02 00:06:40 +00:00
|
|
|
tool.setBrush(new SphereBrush(), "worldedit.brush.ex");
|
2011-03-12 08:49:35 +00:00
|
|
|
|
2011-08-08 00:22:29 +00:00
|
|
|
player.print(String.format("Extinguisher equipped (%.0f).",
|
2011-03-12 08:49:35 +00:00
|
|
|
radius));
|
|
|
|
}
|
2011-01-30 08:34:13 +00:00
|
|
|
}
|