2011-01-29 10:05:22 +00:00
|
|
|
// $Id$
|
|
|
|
/*
|
|
|
|
* WorldEdit
|
|
|
|
* Copyright (C) 2010 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;
|
|
|
|
|
|
|
|
import java.util.Set;
|
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-08-08 12:40:02 +00:00
|
|
|
import com.sk89q.minecraft.util.commands.Logging;
|
|
|
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*;
|
2011-01-29 10:05:22 +00:00
|
|
|
import com.sk89q.worldedit.*;
|
|
|
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
2011-09-03 16:54:20 +00:00
|
|
|
import com.sk89q.worldedit.blocks.BlockID;
|
2011-11-01 14:23:42 +00:00
|
|
|
import com.sk89q.worldedit.expression.ExpressionException;
|
2011-02-18 23:14:43 +00:00
|
|
|
import com.sk89q.worldedit.filtering.GaussianKernel;
|
|
|
|
import com.sk89q.worldedit.filtering.HeightMapFilter;
|
2011-08-10 02:16:54 +00:00
|
|
|
import com.sk89q.worldedit.masks.Mask;
|
2011-01-29 10:05:22 +00:00
|
|
|
import com.sk89q.worldedit.patterns.*;
|
|
|
|
import com.sk89q.worldedit.regions.Region;
|
2011-05-16 19:49:35 +00:00
|
|
|
import com.sk89q.worldedit.regions.RegionOperationException;
|
2011-01-29 10:05:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Region related commands.
|
|
|
|
*
|
|
|
|
* @author sk89q
|
|
|
|
*/
|
|
|
|
public class RegionCommands {
|
2011-12-18 07:45:12 +00:00
|
|
|
private final WorldEdit we;
|
|
|
|
|
|
|
|
public RegionCommands(WorldEdit we) {
|
|
|
|
this.we = we;
|
|
|
|
}
|
|
|
|
|
2011-01-29 10:05:22 +00:00
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "/set" },
|
2011-01-29 10:05:22 +00:00
|
|
|
usage = "<block>",
|
|
|
|
desc = "Set all the blocks inside the selection to a block",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.region.set")
|
2011-08-08 12:40:02 +00:00
|
|
|
@Logging(REGION)
|
2011-12-18 07:45:12 +00:00
|
|
|
public void set(CommandContext args, LocalSession session, LocalPlayer player,
|
|
|
|
EditSession editSession) throws WorldEditException {
|
2011-01-29 10:05:22 +00:00
|
|
|
|
|
|
|
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-01-29 10:05:22 +00:00
|
|
|
int affected;
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-01-29 10:05:22 +00:00
|
|
|
if (pattern instanceof SingleBlockPattern) {
|
2011-02-20 01:44:39 +00:00
|
|
|
affected = editSession.setBlocks(session.getSelection(player.getWorld()),
|
2011-09-24 19:24:10 +00:00
|
|
|
((SingleBlockPattern) pattern).getBlock());
|
2011-01-29 10:05:22 +00:00
|
|
|
} else {
|
2011-02-20 01:44:39 +00:00
|
|
|
affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern);
|
2011-01-29 10:05:22 +00:00
|
|
|
}
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-01-29 10:05:22 +00:00
|
|
|
player.print(affected + " block(s) have been changed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "/replace" },
|
2011-01-29 10:05:22 +00:00
|
|
|
usage = "[from-block] <to-block>",
|
|
|
|
desc = "Replace all blocks in the selection with another",
|
2011-09-18 04:50:06 +00:00
|
|
|
flags = "f",
|
2011-01-29 10:05:22 +00:00
|
|
|
min = 1,
|
|
|
|
max = 2
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.region.replace")
|
2011-08-08 12:40:02 +00:00
|
|
|
@Logging(REGION)
|
2011-12-18 07:45:12 +00:00
|
|
|
public void replace(CommandContext args, LocalSession session, LocalPlayer player,
|
|
|
|
EditSession editSession) throws WorldEditException {
|
2011-01-29 10:05:22 +00:00
|
|
|
|
2011-08-29 06:57:07 +00:00
|
|
|
Set<BaseBlock> from;
|
2011-01-29 10:05:22 +00:00
|
|
|
Pattern to;
|
|
|
|
if (args.argsLength() == 1) {
|
|
|
|
from = null;
|
|
|
|
to = we.getBlockPattern(player, args.getString(0));
|
|
|
|
} else {
|
2011-09-18 04:50:06 +00:00
|
|
|
from = we.getBlocks(player, args.getString(0), true, !args.hasFlag('f'));
|
2011-01-29 10:05:22 +00:00
|
|
|
to = we.getBlockPattern(player, args.getString(1));
|
|
|
|
}
|
|
|
|
|
|
|
|
int affected = 0;
|
|
|
|
if (to instanceof SingleBlockPattern) {
|
2011-02-20 01:44:39 +00:00
|
|
|
affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from,
|
2011-09-24 19:24:10 +00:00
|
|
|
((SingleBlockPattern) to).getBlock());
|
2011-01-29 10:05:22 +00:00
|
|
|
} else {
|
2011-02-20 01:44:39 +00:00
|
|
|
affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, to);
|
2011-01-29 10:05:22 +00:00
|
|
|
}
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-01-29 10:05:22 +00:00
|
|
|
player.print(affected + " block(s) have been replaced.");
|
|
|
|
}
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-01-29 10:05:22 +00:00
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "/overlay" },
|
2011-01-29 10:05:22 +00:00
|
|
|
usage = "<block>",
|
|
|
|
desc = "Set a block on top of blocks in the region",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.region.overlay")
|
2011-08-08 12:40:02 +00:00
|
|
|
@Logging(REGION)
|
2011-12-18 07:45:12 +00:00
|
|
|
public void overlay(CommandContext args, LocalSession session, LocalPlayer player,
|
|
|
|
EditSession editSession) throws WorldEditException {
|
2011-01-29 10:05:22 +00:00
|
|
|
|
2011-01-30 08:47:02 +00:00
|
|
|
Pattern pat = we.getBlockPattern(player, args.getString(0));
|
2011-01-29 10:05:22 +00:00
|
|
|
|
2011-02-20 01:44:39 +00:00
|
|
|
Region region = session.getSelection(player.getWorld());
|
2011-01-30 08:47:02 +00:00
|
|
|
int affected = 0;
|
|
|
|
if (pat instanceof SingleBlockPattern) {
|
|
|
|
affected = editSession.overlayCuboidBlocks(region,
|
2011-09-24 19:24:10 +00:00
|
|
|
((SingleBlockPattern) pat).getBlock());
|
2011-01-30 08:47:02 +00:00
|
|
|
} else {
|
|
|
|
affected = editSession.overlayCuboidBlocks(region, pat);
|
|
|
|
}
|
2011-01-29 10:05:22 +00:00
|
|
|
player.print(affected + " block(s) have been overlayed.");
|
|
|
|
}
|
|
|
|
|
2011-08-02 22:46:11 +00:00
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "/naturalize" },
|
2011-08-02 22:46:11 +00:00
|
|
|
usage = "",
|
|
|
|
desc = "3 layers of dirt on top then rock below",
|
|
|
|
min = 0,
|
|
|
|
max = 0
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.region.naturalize")
|
2011-08-08 12:40:02 +00:00
|
|
|
@Logging(REGION)
|
2011-12-18 07:45:12 +00:00
|
|
|
public void naturalize(CommandContext args, LocalSession session, LocalPlayer player,
|
|
|
|
EditSession editSession) throws WorldEditException {
|
2011-08-02 22:46:11 +00:00
|
|
|
|
|
|
|
Region region = session.getSelection(player.getWorld());
|
|
|
|
int affected = editSession.naturalizeCuboidBlocks(region);
|
|
|
|
player.print(affected + " block(s) have been naturalized.");
|
|
|
|
}
|
|
|
|
|
2011-01-29 10:05:22 +00:00
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "/walls" },
|
2011-01-29 10:05:22 +00:00
|
|
|
usage = "<block>",
|
|
|
|
desc = "Build the four sides of the selection",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.region.walls")
|
2011-08-08 12:40:02 +00:00
|
|
|
@Logging(REGION)
|
2011-12-18 07:45:12 +00:00
|
|
|
public void walls(CommandContext args, LocalSession session, LocalPlayer player,
|
|
|
|
EditSession editSession) throws WorldEditException {
|
2011-01-29 10:05:22 +00:00
|
|
|
|
2011-08-22 06:55:50 +00:00
|
|
|
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
|
|
|
int affected;
|
|
|
|
if (pattern instanceof SingleBlockPattern) {
|
|
|
|
affected = editSession.makeCuboidWalls(session.getSelection(player.getWorld()), ((SingleBlockPattern) pattern).getBlock());
|
|
|
|
} else {
|
|
|
|
affected = editSession.makeCuboidWalls(session.getSelection(player.getWorld()), pattern);
|
|
|
|
}
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-01-29 10:05:22 +00:00
|
|
|
player.print(affected + " block(s) have been changed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "/faces", "/outline" },
|
2011-01-29 10:05:22 +00:00
|
|
|
usage = "<block>",
|
2011-08-08 07:20:55 +00:00
|
|
|
desc = "Build the walls, ceiling, and floor of a selection",
|
2011-01-29 10:05:22 +00:00
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.region.faces")
|
2011-08-08 12:40:02 +00:00
|
|
|
@Logging(REGION)
|
2011-12-18 07:45:12 +00:00
|
|
|
public void faces(CommandContext args, LocalSession session, LocalPlayer player,
|
|
|
|
EditSession editSession) throws WorldEditException {
|
2011-08-22 06:55:50 +00:00
|
|
|
|
|
|
|
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
|
|
|
int affected;
|
|
|
|
if (pattern instanceof SingleBlockPattern) {
|
|
|
|
affected = editSession.makeCuboidFaces(session.getSelection(player.getWorld()), ((SingleBlockPattern) pattern).getBlock());
|
|
|
|
} else {
|
|
|
|
affected = editSession.makeCuboidFaces(session.getSelection(player.getWorld()), pattern);
|
|
|
|
}
|
2011-01-29 10:05:22 +00:00
|
|
|
|
|
|
|
player.print(affected + " block(s) have been changed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "/smooth" },
|
2011-01-29 10:05:22 +00:00
|
|
|
usage = "[iterations]",
|
2011-08-17 07:33:46 +00:00
|
|
|
flags = "n",
|
2011-01-29 10:05:22 +00:00
|
|
|
desc = "Smooth the elevation in the selection",
|
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 =
|
2011-12-06 12:59:41 +00:00
|
|
|
"Smooths the elevation in the selection.\n" +
|
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
|
|
|
"The -n flag makes it only consider naturally occuring blocks.",
|
2011-01-29 10:05:22 +00:00
|
|
|
min = 0,
|
|
|
|
max = 1
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.region.smooth")
|
2011-08-08 12:40:02 +00:00
|
|
|
@Logging(REGION)
|
2011-12-18 07:45:12 +00:00
|
|
|
public void smooth(CommandContext args, LocalSession session, LocalPlayer player,
|
|
|
|
EditSession editSession) throws WorldEditException {
|
2011-01-29 10:05:22 +00:00
|
|
|
|
|
|
|
int iterations = 1;
|
|
|
|
if (args.argsLength() > 0) {
|
|
|
|
iterations = args.getInteger(0);
|
|
|
|
}
|
|
|
|
|
2011-08-17 07:33:46 +00:00
|
|
|
HeightMap heightMap = new HeightMap(editSession, session.getSelection(player.getWorld()), args.hasFlag('n'));
|
2011-01-29 10:05:22 +00:00
|
|
|
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
|
|
|
int affected = heightMap.applyFilter(filter, iterations);
|
|
|
|
player.print("Terrain's height map smoothed. " + affected + " block(s) changed.");
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-01-29 10:05:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "/move" },
|
2011-01-29 20:03:50 +00:00
|
|
|
usage = "[count] [direction] [leave-id]",
|
2011-05-16 19:49:35 +00:00
|
|
|
flags = "s",
|
2011-01-29 10:05:22 +00:00
|
|
|
desc = "Move the contents of the selection",
|
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 =
|
2011-12-06 12:59:41 +00:00
|
|
|
"Moves the contents of the selection.\n" +
|
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
|
|
|
"The -s flag shifts the selection to the target location.\n" +
|
|
|
|
"Optionally fills the old location with <leave-id>.",
|
2011-01-29 10:05:22 +00:00
|
|
|
min = 0,
|
|
|
|
max = 3
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.region.move")
|
2011-08-08 23:18:50 +00:00
|
|
|
@Logging(ORIENTATION_REGION)
|
2011-12-18 07:45:12 +00:00
|
|
|
public void move(CommandContext args, LocalSession session, LocalPlayer player,
|
|
|
|
EditSession editSession) throws WorldEditException {
|
2011-01-29 10:05:22 +00:00
|
|
|
|
|
|
|
int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
|
|
|
|
Vector dir = we.getDirection(player,
|
|
|
|
args.argsLength() > 1 ? args.getString(1).toLowerCase() : "me");
|
|
|
|
BaseBlock replace;
|
|
|
|
|
|
|
|
// Replacement block argument
|
|
|
|
if (args.argsLength() > 2) {
|
|
|
|
replace = we.getBlock(player, args.getString(2));
|
|
|
|
} else {
|
2011-09-03 16:54:20 +00:00
|
|
|
replace = new BaseBlock(BlockID.AIR);
|
2011-01-29 10:05:22 +00:00
|
|
|
}
|
|
|
|
|
2011-02-20 01:44:39 +00:00
|
|
|
int affected = editSession.moveCuboidRegion(session.getSelection(player.getWorld()),
|
2011-01-29 10:05:22 +00:00
|
|
|
dir, count, true, replace);
|
2011-05-16 19:49:35 +00:00
|
|
|
|
|
|
|
if (args.hasFlag('s')) {
|
|
|
|
try {
|
|
|
|
Region region = session.getSelection(player.getWorld());
|
|
|
|
region.expand(dir.multiply(count));
|
|
|
|
region.contract(dir.multiply(count));
|
|
|
|
|
2011-12-13 03:20:31 +00:00
|
|
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
|
|
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
2011-05-16 19:49:35 +00:00
|
|
|
} catch (RegionOperationException e) {
|
|
|
|
player.printError(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 10:05:22 +00:00
|
|
|
player.print(affected + " blocks moved.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "/stack" },
|
2011-01-29 20:03:50 +00:00
|
|
|
usage = "[count] [direction]",
|
2011-05-16 19:49:35 +00:00
|
|
|
flags = "sa",
|
2011-01-29 10:05:22 +00:00
|
|
|
desc = "Repeat the contents of the selection",
|
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 =
|
|
|
|
"Repeats the contents of the selection.\n" +
|
|
|
|
"Flags:\n" +
|
|
|
|
" -s shifts the selection to the last stacked copy\n" +
|
|
|
|
" -a skips air blocks",
|
2011-01-29 10:05:22 +00:00
|
|
|
min = 0,
|
|
|
|
max = 2
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.region.stack")
|
2011-08-08 23:18:50 +00:00
|
|
|
@Logging(ORIENTATION_REGION)
|
2011-12-18 07:45:12 +00:00
|
|
|
public void stack(CommandContext args, LocalSession session, LocalPlayer player,
|
|
|
|
EditSession editSession) throws WorldEditException {
|
2011-01-29 10:05:22 +00:00
|
|
|
|
|
|
|
int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
|
2011-03-21 14:01:15 +00:00
|
|
|
Vector dir = we.getDiagonalDirection(player,
|
2011-01-29 10:05:22 +00:00
|
|
|
args.argsLength() > 1 ? args.getString(1).toLowerCase() : "me");
|
|
|
|
|
2011-02-20 01:44:39 +00:00
|
|
|
int affected = editSession.stackCuboidRegion(session.getSelection(player.getWorld()),
|
2011-01-29 20:03:50 +00:00
|
|
|
dir, count, !args.hasFlag('a'));
|
2011-05-16 19:49:35 +00:00
|
|
|
|
|
|
|
if (args.hasFlag('s')) {
|
|
|
|
try {
|
2011-12-05 22:21:51 +00:00
|
|
|
final Region region = session.getSelection(player.getWorld());
|
|
|
|
final Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint());
|
|
|
|
|
2011-12-18 21:43:08 +00:00
|
|
|
final Vector shiftVector = dir.multiply(count * (Math.abs(dir.dot(size))+1));
|
2011-12-05 22:21:51 +00:00
|
|
|
region.expand(shiftVector);
|
|
|
|
region.contract(shiftVector);
|
2011-05-16 19:49:35 +00:00
|
|
|
|
2011-12-13 03:20:31 +00:00
|
|
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
|
|
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
2011-05-16 19:49:35 +00:00
|
|
|
} catch (RegionOperationException e) {
|
|
|
|
player.printError(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 10:05:22 +00:00
|
|
|
player.print(affected + " blocks changed. Undo with //undo");
|
|
|
|
}
|
2011-03-13 00:37:07 +00:00
|
|
|
|
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "/regen" },
|
2011-03-13 00:37:07 +00:00
|
|
|
usage = "",
|
|
|
|
desc = "Regenerates the contents of the selection",
|
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 =
|
|
|
|
"Regenerates the contents of the current selection.\n" +
|
|
|
|
"This command might affect things outside the selection,\n" +
|
|
|
|
"if they are within the same chunk.",
|
2011-03-13 00:37:07 +00:00
|
|
|
min = 0,
|
|
|
|
max = 0
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.regen")
|
2011-08-08 12:40:02 +00:00
|
|
|
@Logging(REGION)
|
2011-12-18 07:45:12 +00:00
|
|
|
public void regenerateChunk(CommandContext args, LocalSession session, LocalPlayer player,
|
|
|
|
EditSession editSession) throws WorldEditException {
|
2011-03-13 00:37:07 +00:00
|
|
|
|
|
|
|
Region region = session.getSelection(player.getWorld());
|
2011-08-10 02:16:54 +00:00
|
|
|
Mask mask = session.getMask();
|
|
|
|
session.setMask(null);
|
2011-03-13 00:37:07 +00:00
|
|
|
player.getWorld().regenerate(region, editSession);
|
2011-08-10 02:16:54 +00:00
|
|
|
session.setMask(mask);
|
2011-03-13 00:37:07 +00:00
|
|
|
player.print("Region regenerated.");
|
|
|
|
}
|
2011-11-01 14:23:42 +00:00
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/deform" },
|
|
|
|
usage = "<expression>",
|
|
|
|
desc = "Deforms a selected region with an expression",
|
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 =
|
|
|
|
"Deforms a selected region with an expression\n" +
|
|
|
|
"The expression is executed for each block and is expected\n" +
|
|
|
|
"to modify the variables x, y and z to point to a new block\n" +
|
|
|
|
"to fetch. See also tinyurl.com/wesyntax.",
|
2011-11-01 14:23:42 +00:00
|
|
|
flags = "ro",
|
|
|
|
min = 1,
|
|
|
|
max = -1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.deform")
|
|
|
|
@Logging(ALL)
|
2011-12-18 07:45:12 +00:00
|
|
|
public void deform(CommandContext args, LocalSession session, LocalPlayer player,
|
|
|
|
EditSession editSession) throws WorldEditException {
|
2011-11-01 14:23:42 +00:00
|
|
|
|
|
|
|
final Region region = session.getSelection(player.getWorld());
|
|
|
|
|
|
|
|
final String expression = args.getJoinedStrings(0);
|
|
|
|
|
|
|
|
final Vector zero;
|
2011-11-01 15:32:56 +00:00
|
|
|
Vector unit;
|
2011-11-01 14:23:42 +00:00
|
|
|
|
|
|
|
if (args.hasFlag('r')) {
|
2011-11-02 02:41:22 +00:00
|
|
|
zero = new Vector(0, 0, 0);
|
|
|
|
unit = new Vector(1, 1, 1);
|
2011-11-01 14:23:42 +00:00
|
|
|
} else if (args.hasFlag('o')) {
|
|
|
|
zero = session.getPlacementPosition(player);
|
2011-11-02 02:41:22 +00:00
|
|
|
unit = new Vector(1, 1, 1);
|
2011-11-01 14:23:42 +00:00
|
|
|
} else {
|
|
|
|
final Vector min = region.getMinimumPoint();
|
|
|
|
final Vector max = region.getMaximumPoint();
|
|
|
|
|
|
|
|
zero = max.add(min).multiply(0.5);
|
|
|
|
unit = max.subtract(zero);
|
2011-11-01 15:32:56 +00:00
|
|
|
|
|
|
|
if (unit.getX() == 0) unit = unit.setX(1.0);
|
|
|
|
if (unit.getY() == 0) unit = unit.setY(1.0);
|
|
|
|
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
2011-11-01 14:23:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
final int affected = editSession.deformRegion(region, zero, unit, expression);
|
|
|
|
player.findFreePosition();
|
|
|
|
player.print(affected + " block(s) have been deformed.");
|
|
|
|
} catch (ExpressionException e) {
|
|
|
|
player.printError(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
2011-12-08 09:31:12 +00:00
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/hollow" },
|
|
|
|
usage = "",
|
|
|
|
desc = "Hollows out the object contained in this selection",
|
|
|
|
min = 0,
|
|
|
|
max = 0
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.hollow")
|
|
|
|
@Logging(REGION)
|
2011-12-18 07:45:12 +00:00
|
|
|
public void hollow(CommandContext args, LocalSession session, LocalPlayer player,
|
|
|
|
EditSession editSession) throws WorldEditException {
|
2011-12-08 09:31:12 +00:00
|
|
|
|
|
|
|
int affected = editSession.hollowOutRegion(session.getSelection(player.getWorld()));
|
|
|
|
|
|
|
|
player.print(affected + " block(s) have been changed.");
|
|
|
|
}
|
2011-01-29 10:05:22 +00:00
|
|
|
}
|