2014-04-03 02:08:50 +00:00
|
|
|
/*
|
2014-04-04 22:03:18 +00:00
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
2014-04-03 02:08:50 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or
|
2014-04-03 02:08:50 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* 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 Lesser General Public License
|
|
|
|
* for more details.
|
2014-04-03 02:08:50 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2014-04-03 02:08:50 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-04-04 22:03:18 +00:00
|
|
|
*/
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
package com.sk89q.worldedit.command;
|
|
|
|
|
2015-10-27 06:14:30 +00:00
|
|
|
import com.sk89q.worldedit.LocalConfiguration;
|
|
|
|
import com.sk89q.worldedit.LocalSession;
|
|
|
|
import com.sk89q.worldedit.WorldEdit;
|
|
|
|
import com.sk89q.worldedit.WorldEditException;
|
2019-04-26 08:18:02 +00:00
|
|
|
import com.sk89q.worldedit.command.factory.ReplaceFactory;
|
|
|
|
import com.sk89q.worldedit.command.factory.TreeGeneratorFactory;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.worldedit.command.tool.BrushTool;
|
2014-06-30 00:47:08 +00:00
|
|
|
import com.sk89q.worldedit.command.tool.brush.ButcherBrush;
|
|
|
|
import com.sk89q.worldedit.command.tool.brush.ClipboardBrush;
|
|
|
|
import com.sk89q.worldedit.command.tool.brush.CylinderBrush;
|
|
|
|
import com.sk89q.worldedit.command.tool.brush.GravityBrush;
|
|
|
|
import com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush;
|
|
|
|
import com.sk89q.worldedit.command.tool.brush.HollowSphereBrush;
|
2019-04-26 08:18:02 +00:00
|
|
|
import com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush;
|
2014-06-30 00:47:08 +00:00
|
|
|
import com.sk89q.worldedit.command.tool.brush.SmoothBrush;
|
|
|
|
import com.sk89q.worldedit.command.tool.brush.SphereBrush;
|
2019-04-15 09:01:25 +00:00
|
|
|
import com.sk89q.worldedit.command.util.CommandPermissions;
|
2019-04-17 06:02:23 +00:00
|
|
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
2014-07-16 02:47:47 +00:00
|
|
|
import com.sk89q.worldedit.command.util.CreatureButcher;
|
2014-06-28 02:55:38 +00:00
|
|
|
import com.sk89q.worldedit.entity.Player;
|
2014-06-30 00:47:08 +00:00
|
|
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
2019-04-26 08:18:02 +00:00
|
|
|
import com.sk89q.worldedit.function.Contextual;
|
|
|
|
import com.sk89q.worldedit.function.factory.Apply;
|
|
|
|
import com.sk89q.worldedit.function.factory.Deform;
|
|
|
|
import com.sk89q.worldedit.function.factory.Paint;
|
2018-08-20 05:57:42 +00:00
|
|
|
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
2019-02-26 23:15:35 +00:00
|
|
|
import com.sk89q.worldedit.function.mask.Mask;
|
2019-04-26 08:18:02 +00:00
|
|
|
import com.sk89q.worldedit.function.operation.Operation;
|
2014-06-28 02:55:38 +00:00
|
|
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
|
|
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
2018-10-14 10:40:53 +00:00
|
|
|
import com.sk89q.worldedit.math.BlockVector3;
|
2019-04-26 08:18:02 +00:00
|
|
|
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
2014-07-02 09:56:21 +00:00
|
|
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
2019-03-16 04:49:21 +00:00
|
|
|
import com.sk89q.worldedit.session.request.RequestExtent;
|
2018-06-17 07:50:04 +00:00
|
|
|
import com.sk89q.worldedit.util.HandSide;
|
2019-04-26 08:18:02 +00:00
|
|
|
import com.sk89q.worldedit.util.TreeGenerator;
|
2018-07-30 13:26:06 +00:00
|
|
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
2019-04-15 09:01:25 +00:00
|
|
|
import org.enginehub.piston.annotation.Command;
|
|
|
|
import org.enginehub.piston.annotation.CommandContainer;
|
|
|
|
import org.enginehub.piston.annotation.param.Arg;
|
2019-04-26 08:25:42 +00:00
|
|
|
import org.enginehub.piston.annotation.param.ArgFlag;
|
2019-04-15 09:01:25 +00:00
|
|
|
import org.enginehub.piston.annotation.param.Switch;
|
|
|
|
|
|
|
|
import static com.google.common.base.Preconditions.checkNotNull;
|
2014-06-28 02:55:38 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
/**
|
2014-06-28 02:55:38 +00:00
|
|
|
* Commands to set brush shape.
|
2014-04-03 02:08:50 +00:00
|
|
|
*/
|
2019-04-17 06:02:23 +00:00
|
|
|
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
2014-04-03 02:08:50 +00:00
|
|
|
public class BrushCommands {
|
2014-06-28 02:55:38 +00:00
|
|
|
|
|
|
|
private final WorldEdit worldEdit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new instance.
|
|
|
|
*
|
|
|
|
* @param worldEdit reference to WorldEdit
|
|
|
|
*/
|
|
|
|
public BrushCommands(WorldEdit worldEdit) {
|
|
|
|
checkNotNull(worldEdit);
|
|
|
|
this.worldEdit = worldEdit;
|
2014-04-04 21:11:48 +00:00
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
@Command(
|
2019-04-15 09:01:25 +00:00
|
|
|
name = "sphere",
|
|
|
|
aliases = { "s" },
|
|
|
|
desc = "Choose the sphere brush"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.sphere")
|
2019-04-29 04:42:45 +00:00
|
|
|
public void sphereBrush(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The pattern of blocks to set")
|
|
|
|
Pattern fill,
|
2019-04-15 09:01:25 +00:00
|
|
|
@Arg(desc = "The radius of the sphere", def = "2")
|
|
|
|
double radius,
|
|
|
|
@Switch(name = 'h', desc = "Create hollow spheres instead")
|
|
|
|
boolean hollow) throws WorldEditException {
|
2014-06-28 02:55:38 +00:00
|
|
|
worldEdit.checkMaxBrushRadius(radius);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-06-17 07:50:04 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
2014-04-03 02:08:50 +00:00
|
|
|
tool.setFill(fill);
|
|
|
|
tool.setSize(radius);
|
|
|
|
|
2014-06-28 02:55:38 +00:00
|
|
|
if (hollow) {
|
2014-04-03 02:08:50 +00:00
|
|
|
tool.setBrush(new HollowSphereBrush(), "worldedit.brush.sphere");
|
|
|
|
} else {
|
|
|
|
tool.setBrush(new SphereBrush(), "worldedit.brush.sphere");
|
|
|
|
}
|
|
|
|
|
2014-06-28 02:55:38 +00:00
|
|
|
player.print(String.format("Sphere brush shape equipped (%.0f).", radius));
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-04-15 09:01:25 +00:00
|
|
|
name = "cylinder",
|
|
|
|
aliases = { "cyl", "c" },
|
|
|
|
desc = "Choose the cylinder brush"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.cylinder")
|
2019-04-29 04:42:45 +00:00
|
|
|
public void cylinderBrush(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The pattern of blocks to set")
|
|
|
|
Pattern fill,
|
2019-04-15 09:01:25 +00:00
|
|
|
@Arg(desc = "The radius of the cylinder", def = "2")
|
|
|
|
double radius,
|
|
|
|
@Arg(desc = "The height of the cylinder", def = "1")
|
|
|
|
int height,
|
|
|
|
@Switch(name = 'h', desc = "Create hollow cylinders instead")
|
|
|
|
boolean hollow) throws WorldEditException {
|
2014-06-28 02:55:38 +00:00
|
|
|
worldEdit.checkMaxBrushRadius(radius);
|
|
|
|
worldEdit.checkMaxBrushRadius(height);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-06-17 07:50:04 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
2014-04-03 02:08:50 +00:00
|
|
|
tool.setFill(fill);
|
|
|
|
tool.setSize(radius);
|
|
|
|
|
2014-06-28 02:55:38 +00:00
|
|
|
if (hollow) {
|
2014-04-03 02:08:50 +00:00
|
|
|
tool.setBrush(new HollowCylinderBrush(height), "worldedit.brush.cylinder");
|
|
|
|
} else {
|
|
|
|
tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder");
|
|
|
|
}
|
|
|
|
|
2014-06-28 02:55:38 +00:00
|
|
|
player.print(String.format("Cylinder brush shape equipped (%.0f by %d).", radius, height));
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-04-15 09:01:25 +00:00
|
|
|
name = "clipboard",
|
|
|
|
aliases = { "copy" },
|
|
|
|
desc = "Choose the clipboard brush"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.clipboard")
|
2019-04-15 09:01:25 +00:00
|
|
|
public void clipboardBrush(Player player, LocalSession session,
|
|
|
|
@Switch(name = 'a', desc = "Don't paste air from the clipboard")
|
|
|
|
boolean ignoreAir,
|
2019-04-26 08:25:42 +00:00
|
|
|
@Switch(name = 'o', desc = "Paste using clipboard origin, instead of being centered at the target location")
|
|
|
|
boolean usingOrigin,
|
|
|
|
@Switch(name = 'e', desc = "Paste entities if available")
|
|
|
|
boolean pasteEntities,
|
|
|
|
@Switch(name = 'b', desc = "Paste biomes if available")
|
|
|
|
boolean pasteBiomes,
|
2019-04-29 04:42:45 +00:00
|
|
|
@ArgFlag(name = 'm', desc = "Skip blocks matching this mask in the clipboard", def = "")
|
2019-04-26 08:25:42 +00:00
|
|
|
Mask sourceMask) throws WorldEditException {
|
2014-07-02 09:56:21 +00:00
|
|
|
ClipboardHolder holder = session.getClipboard();
|
|
|
|
Clipboard clipboard = holder.getClipboard();
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-10-14 10:40:53 +00:00
|
|
|
BlockVector3 size = clipboard.getDimensions();
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2019-02-23 16:57:15 +00:00
|
|
|
worldEdit.checkMaxBrushRadius(size.getBlockX() / 2D - 1);
|
|
|
|
worldEdit.checkMaxBrushRadius(size.getBlockY() / 2D - 1);
|
|
|
|
worldEdit.checkMaxBrushRadius(size.getBlockZ() / 2D - 1);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-06-17 07:50:04 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
2019-04-26 00:48:15 +00:00
|
|
|
tool.setBrush(new ClipboardBrush(holder, ignoreAir, usingOrigin, pasteEntities, pasteBiomes, sourceMask), "worldedit.brush.clipboard");
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
player.print("Clipboard brush shape equipped.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-04-15 09:01:25 +00:00
|
|
|
name = "smooth",
|
2014-04-03 02:08:50 +00:00
|
|
|
desc = "Choose the terrain softener brush",
|
2019-04-15 09:01:25 +00:00
|
|
|
descFooter = "Example: '/brush smooth 2 4 grass_block,dirt,stone'"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.smooth")
|
2019-03-16 04:49:21 +00:00
|
|
|
public void smoothBrush(Player player, LocalSession session,
|
2019-04-15 09:01:25 +00:00
|
|
|
@Arg(desc = "The radius to sample for softening", def = "2")
|
|
|
|
double radius,
|
|
|
|
@Arg(desc = "The number of iterations to perform", def = "4")
|
|
|
|
int iterations,
|
|
|
|
@Arg(desc = "The mask of blocks to use for the heightmap", def = "")
|
|
|
|
Mask mask) throws WorldEditException {
|
2014-06-28 02:55:38 +00:00
|
|
|
worldEdit.checkMaxBrushRadius(radius);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-06-17 07:50:04 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
2014-04-03 02:08:50 +00:00
|
|
|
tool.setSize(radius);
|
2019-02-26 23:15:35 +00:00
|
|
|
tool.setBrush(new SmoothBrush(iterations, mask), "worldedit.brush.smooth");
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2019-02-26 23:15:35 +00:00
|
|
|
player.print(String.format("Smooth brush equipped (%.0f x %dx, using %s).", radius, iterations, mask == null ? "any block" : "filter"));
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-04-15 09:01:25 +00:00
|
|
|
name = "extinguish",
|
|
|
|
aliases = { "ex" },
|
|
|
|
desc = "Shortcut fire extinguisher brush"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.ex")
|
2019-04-15 09:01:25 +00:00
|
|
|
public void extinguishBrush(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The radius to extinguish", def = "5")
|
|
|
|
double radius) throws WorldEditException {
|
2014-06-28 02:55:38 +00:00
|
|
|
worldEdit.checkMaxBrushRadius(radius);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-06-17 07:50:04 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
2018-06-19 01:55:35 +00:00
|
|
|
Pattern fill = new BlockPattern(BlockTypes.AIR.getDefaultState());
|
2014-04-03 02:08:50 +00:00
|
|
|
tool.setFill(fill);
|
|
|
|
tool.setSize(radius);
|
2019-03-16 04:49:21 +00:00
|
|
|
tool.setMask(new BlockTypeMask(new RequestExtent(), BlockTypes.FIRE));
|
2014-04-03 02:08:50 +00:00
|
|
|
tool.setBrush(new SphereBrush(), "worldedit.brush.ex");
|
|
|
|
|
2014-06-28 02:55:38 +00:00
|
|
|
player.print(String.format("Extinguisher equipped (%.0f).", radius));
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-04-15 09:01:25 +00:00
|
|
|
name = "gravity",
|
|
|
|
aliases = { "grav" },
|
|
|
|
desc = "Gravity brush, simulates the effect of gravity"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.gravity")
|
2019-04-15 09:01:25 +00:00
|
|
|
public void gravityBrush(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The radius to apply gravity in", def = "5")
|
|
|
|
double radius,
|
|
|
|
@Switch(name = 'h', desc = "Affect blocks starting at max Y, rather than the target location Y + radius")
|
|
|
|
boolean fromMaxY) throws WorldEditException {
|
2014-06-28 02:55:38 +00:00
|
|
|
worldEdit.checkMaxBrushRadius(radius);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-06-17 07:50:04 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
2014-04-03 02:08:50 +00:00
|
|
|
tool.setSize(radius);
|
2014-06-28 02:55:38 +00:00
|
|
|
tool.setBrush(new GravityBrush(fromMaxY), "worldedit.brush.gravity");
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
player.print(String.format("Gravity brush equipped (%.0f).",
|
|
|
|
radius));
|
|
|
|
}
|
2019-04-26 08:18:02 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
@Command(
|
2019-04-15 09:01:25 +00:00
|
|
|
name = "butcher",
|
|
|
|
aliases = { "kill" },
|
|
|
|
desc = "Butcher brush, kills mobs within a radius"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.butcher")
|
2019-04-15 09:01:25 +00:00
|
|
|
public void butcherBrush(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "Radius to kill mobs in", def = "5")
|
|
|
|
double radius,
|
|
|
|
@Switch(name = 'p', desc = "Also kill pets")
|
|
|
|
boolean killPets,
|
|
|
|
@Switch(name = 'n', desc = "Also kill NPCs")
|
|
|
|
boolean killNpcs,
|
|
|
|
@Switch(name = 'g', desc = "Also kill golems")
|
|
|
|
boolean killGolems,
|
|
|
|
@Switch(name = 'a', desc = "Also kill animals")
|
|
|
|
boolean killAnimals,
|
|
|
|
@Switch(name = 'b', desc = "Also kill ambient mobs")
|
|
|
|
boolean killAmbient,
|
|
|
|
@Switch(name = 't', desc = "Also kill mobs with name tags")
|
|
|
|
boolean killWithName,
|
|
|
|
@Switch(name = 'f', desc = "Also kill all friendly mobs (Applies the flags `-abgnpt`)")
|
|
|
|
boolean killFriendly,
|
|
|
|
@Switch(name = 'r', desc = "Also destroy armor stands")
|
2019-04-26 13:42:57 +00:00
|
|
|
boolean killArmorStands) throws WorldEditException {
|
2014-06-28 02:55:38 +00:00
|
|
|
LocalConfiguration config = worldEdit.getConfiguration();
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
double maxRadius = config.maxBrushRadius;
|
|
|
|
// hmmmm not horribly worried about this because -1 is still rather efficient,
|
|
|
|
// the problem arises when butcherMaxRadius is some really high number but not infinite
|
|
|
|
// - original idea taken from https://github.com/sk89q/worldedit/pull/198#issuecomment-6463108
|
|
|
|
if (player.hasPermission("worldedit.butcher")) {
|
|
|
|
maxRadius = Math.max(config.maxBrushRadius, config.butcherMaxRadius);
|
|
|
|
}
|
|
|
|
if (radius > maxRadius) {
|
|
|
|
player.printError("Maximum allowed brush radius: " + maxRadius);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-16 02:47:47 +00:00
|
|
|
CreatureButcher flags = new CreatureButcher(player);
|
2019-04-15 09:01:25 +00:00
|
|
|
flags.or(CreatureButcher.Flags.FRIENDLY , killFriendly); // No permission check here. Flags will instead be filtered by the subsequent calls.
|
|
|
|
flags.or(CreatureButcher.Flags.PETS , killPets, "worldedit.butcher.pets");
|
|
|
|
flags.or(CreatureButcher.Flags.NPCS , killNpcs, "worldedit.butcher.npcs");
|
|
|
|
flags.or(CreatureButcher.Flags.GOLEMS , killGolems, "worldedit.butcher.golems");
|
|
|
|
flags.or(CreatureButcher.Flags.ANIMALS , killAnimals, "worldedit.butcher.animals");
|
|
|
|
flags.or(CreatureButcher.Flags.AMBIENT , killAmbient, "worldedit.butcher.ambient");
|
|
|
|
flags.or(CreatureButcher.Flags.TAGGED , killWithName, "worldedit.butcher.tagged");
|
|
|
|
flags.or(CreatureButcher.Flags.ARMOR_STAND , killArmorStands, "worldedit.butcher.armorstands");
|
|
|
|
|
2018-06-17 07:50:04 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
2014-04-03 02:08:50 +00:00
|
|
|
tool.setSize(radius);
|
2014-07-16 02:47:47 +00:00
|
|
|
tool.setBrush(new ButcherBrush(flags), "worldedit.brush.butcher");
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2014-07-16 02:47:47 +00:00
|
|
|
player.print(String.format("Butcher brush equipped (%.0f).", radius));
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
2019-04-26 08:18:02 +00:00
|
|
|
|
|
|
|
@Command(
|
|
|
|
name = "deform",
|
|
|
|
desc = "Deform brush, applies an expression to an area"
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.deform")
|
|
|
|
public void deform(Player player, LocalSession localSession,
|
|
|
|
@Arg(desc = "The shape of the region")
|
2019-04-29 00:30:58 +00:00
|
|
|
RegionFactory shape,
|
2019-04-26 08:18:02 +00:00
|
|
|
@Arg(desc = "The size of the brush", def = "5")
|
|
|
|
double radius,
|
|
|
|
@Arg(desc = "Expression to apply", def = "y-=0.2")
|
|
|
|
String expression,
|
|
|
|
@Switch(name = 'r', desc = "Use the game's coordinate origin")
|
|
|
|
boolean useRawCoords,
|
|
|
|
@Switch(name = 'o', desc = "Use the placement position as the origin")
|
|
|
|
boolean usePlacement) throws WorldEditException {
|
|
|
|
Deform deform = new Deform(expression);
|
|
|
|
if (useRawCoords) {
|
|
|
|
deform.setMode(Deform.Mode.RAW_COORD);
|
|
|
|
} else if (usePlacement) {
|
|
|
|
deform.setMode(Deform.Mode.OFFSET);
|
|
|
|
deform.setOffset(localSession.getPlacementPosition(player).toVector3());
|
|
|
|
}
|
|
|
|
setOperationBasedBrush(player, localSession, radius,
|
2019-04-29 00:30:58 +00:00
|
|
|
deform, shape, "worldedit.brush.deform");
|
2019-04-26 08:18:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
name = "set",
|
|
|
|
desc = "Set brush, sets all blocks in the area"
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.set")
|
|
|
|
public void set(Player player, LocalSession localSession,
|
|
|
|
@Arg(desc = "The shape of the region")
|
2019-04-29 00:30:58 +00:00
|
|
|
RegionFactory shape,
|
2019-04-26 08:18:02 +00:00
|
|
|
@Arg(desc = "The size of the brush", def = "5")
|
|
|
|
double radius,
|
|
|
|
@Arg(desc = "The pattern of blocks to set")
|
|
|
|
Pattern pattern) throws WorldEditException {
|
|
|
|
setOperationBasedBrush(player, localSession, radius,
|
2019-04-29 00:30:58 +00:00
|
|
|
new Apply(new ReplaceFactory(pattern)), shape, "worldedit.brush.set");
|
2019-04-26 08:18:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
name = "forest",
|
|
|
|
desc = "Forest brush, creates a forest in the area"
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.forest")
|
|
|
|
public void forest(Player player, LocalSession localSession,
|
|
|
|
@Arg(desc = "The shape of the region")
|
2019-04-29 00:30:58 +00:00
|
|
|
RegionFactory shape,
|
2019-04-26 08:18:02 +00:00
|
|
|
@Arg(desc = "The size of the brush", def = "5")
|
|
|
|
double radius,
|
|
|
|
@Arg(desc = "The density of the brush", def = "20")
|
|
|
|
double density,
|
|
|
|
@Arg(desc = "The type of tree to use")
|
|
|
|
TreeGenerator.TreeType type) throws WorldEditException {
|
|
|
|
setOperationBasedBrush(player, localSession, radius,
|
2019-04-29 00:30:58 +00:00
|
|
|
new Paint(new TreeGeneratorFactory(type), density / 100), shape, "worldedit.brush.forest");
|
2019-04-26 08:18:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
name = "raise",
|
|
|
|
desc = "Raise brush, raise all blocks by one"
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.raise")
|
|
|
|
public void raise(Player player, LocalSession localSession,
|
|
|
|
@Arg(desc = "The shape of the region")
|
2019-04-29 00:30:58 +00:00
|
|
|
RegionFactory shape,
|
2019-04-26 08:18:02 +00:00
|
|
|
@Arg(desc = "The size of the brush", def = "5")
|
|
|
|
double radius) throws WorldEditException {
|
|
|
|
setOperationBasedBrush(player, localSession, radius,
|
2019-04-29 00:30:58 +00:00
|
|
|
new Deform("y-=1"), shape, "worldedit.brush.raise");
|
2019-04-26 08:18:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
name = "lower",
|
|
|
|
desc = "Lower brush, lower all blocks by one"
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.lower")
|
|
|
|
public void lower(Player player, LocalSession localSession,
|
|
|
|
@Arg(desc = "The shape of the region")
|
2019-04-29 00:30:58 +00:00
|
|
|
RegionFactory shape,
|
2019-04-26 08:18:02 +00:00
|
|
|
@Arg(desc = "The size of the brush", def = "5")
|
|
|
|
double radius) throws WorldEditException {
|
|
|
|
setOperationBasedBrush(player, localSession, radius,
|
2019-04-29 00:30:58 +00:00
|
|
|
new Deform("y+=1"), shape, "worldedit.brush.lower");
|
2019-04-26 08:18:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setOperationBasedBrush(Player player, LocalSession session, double radius,
|
|
|
|
Contextual<? extends Operation> factory,
|
2019-04-29 00:30:58 +00:00
|
|
|
RegionFactory shape,
|
2019-04-26 08:18:02 +00:00
|
|
|
String permission) throws WorldEditException {
|
|
|
|
WorldEdit.getInstance().checkMaxBrushRadius(radius);
|
|
|
|
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
|
|
|
tool.setSize(radius);
|
|
|
|
tool.setFill(null);
|
2019-04-29 00:30:58 +00:00
|
|
|
tool.setBrush(new OperationFactoryBrush(factory, shape, session), permission);
|
2019-04-26 08:18:02 +00:00
|
|
|
|
|
|
|
player.print("Set brush to " + factory);
|
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|