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;
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.boydti.fawe.FaweAPI;
|
|
|
|
import com.boydti.fawe.config.BBC;
|
|
|
|
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
|
|
|
import com.boydti.fawe.object.FaweLimit;
|
|
|
|
import com.boydti.fawe.object.FawePlayer;
|
|
|
|
import com.boydti.fawe.object.FaweQueue;
|
|
|
|
import com.boydti.fawe.object.exception.FaweException;
|
|
|
|
import com.boydti.fawe.object.visitor.Fast2DIterator;
|
|
|
|
import com.boydti.fawe.util.MathMan;
|
|
|
|
import com.sk89q.jnbt.CompoundTag;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.minecraft.util.commands.Command;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
|
|
|
import com.sk89q.minecraft.util.commands.Logging;
|
2018-08-10 10:29:06 +00:00
|
|
|
|
2018-12-23 16:19:33 +00:00
|
|
|
import com.sk89q.worldedit.EditSession;
|
|
|
|
import com.sk89q.worldedit.LocalSession;
|
|
|
|
import com.sk89q.worldedit.WorldEdit;
|
|
|
|
import com.sk89q.worldedit.WorldEditException;
|
2014-06-28 08:01:49 +00:00
|
|
|
import com.sk89q.worldedit.entity.Player;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.extension.platform.Capability;
|
2014-06-28 08:01:49 +00:00
|
|
|
import com.sk89q.worldedit.function.GroundFunction;
|
|
|
|
import com.sk89q.worldedit.function.generator.FloraGenerator;
|
|
|
|
import com.sk89q.worldedit.function.generator.ForestGenerator;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
2014-06-28 08:01:49 +00:00
|
|
|
import com.sk89q.worldedit.function.mask.Mask;
|
|
|
|
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.worldedit.function.operation.Operations;
|
2014-06-28 08:01:49 +00:00
|
|
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
|
|
|
import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
|
|
|
import com.sk89q.worldedit.internal.annotation.Direction;
|
|
|
|
import com.sk89q.worldedit.internal.annotation.Selection;
|
|
|
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
2019-04-03 13:25:16 +00:00
|
|
|
import com.sk89q.worldedit.math.BlockVector2;
|
2018-12-23 16:19:33 +00:00
|
|
|
import com.sk89q.worldedit.math.BlockVector3;
|
|
|
|
import com.sk89q.worldedit.math.Vector3;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
|
|
|
import com.sk89q.worldedit.math.convolution.HeightMap;
|
|
|
|
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
2014-06-28 08:01:49 +00:00
|
|
|
import com.sk89q.worldedit.math.noise.RandomNoise;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.regions.*;
|
|
|
|
import com.sk89q.worldedit.util.Location;
|
2014-06-28 08:01:49 +00:00
|
|
|
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
|
|
|
import com.sk89q.worldedit.util.command.binding.Range;
|
|
|
|
import com.sk89q.worldedit.util.command.binding.Switch;
|
|
|
|
import com.sk89q.worldedit.util.command.binding.Text;
|
|
|
|
import com.sk89q.worldedit.util.command.parametric.Optional;
|
2019-04-03 13:25:16 +00:00
|
|
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
|
|
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
|
|
|
import com.sk89q.worldedit.world.biome.Biomes;
|
|
|
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
|
|
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
2018-12-27 00:39:10 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
import java.util.ArrayList;
|
2019-04-05 04:15:10 +00:00
|
|
|
import java.util.Collection;
|
2018-08-12 14:03:07 +00:00
|
|
|
import java.util.Iterator;
|
2014-04-03 02:08:50 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
|
|
|
|
import static com.google.common.base.Preconditions.checkNotNull;
|
|
|
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
|
|
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ORIENTATION_REGION;
|
|
|
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
|
|
|
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
|
|
|
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
|
|
|
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
/**
|
2014-06-28 08:01:49 +00:00
|
|
|
* Commands that operate on regions.
|
2014-04-03 02:08:50 +00:00
|
|
|
*/
|
2018-08-12 14:03:07 +00:00
|
|
|
@Command(aliases = {}, desc = "Commands that operate on regions: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Region_operations)")
|
|
|
|
public class RegionCommands extends MethodCommands {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2014-06-28 08:01:49 +00:00
|
|
|
private final WorldEdit worldEdit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new instance.
|
|
|
|
*
|
|
|
|
* @param worldEdit reference to WorldEdit
|
|
|
|
*/
|
|
|
|
public RegionCommands(WorldEdit worldEdit) {
|
2018-08-12 14:03:07 +00:00
|
|
|
super(worldEdit);
|
2014-06-28 08:01:49 +00:00
|
|
|
checkNotNull(worldEdit);
|
|
|
|
this.worldEdit = worldEdit;
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"/fixlighting"},
|
|
|
|
desc = "Get the light at a position",
|
|
|
|
min = 0,
|
|
|
|
max = 0
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.light.fix")
|
|
|
|
public void fixlighting(Player player) throws WorldEditException {
|
|
|
|
FawePlayer fp = FawePlayer.wrap(player);
|
2019-06-06 01:17:34 +00:00
|
|
|
final Location loc = player.getLocation();
|
2018-08-12 14:03:07 +00:00
|
|
|
Region selection = fp.getSelection();
|
|
|
|
if (selection == null) {
|
2019-06-06 01:17:34 +00:00
|
|
|
final int cx = loc.getBlockX() >> 4;
|
|
|
|
final int cz = loc.getBlockZ() >> 4;
|
2018-10-19 20:13:32 +00:00
|
|
|
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
2019-06-06 01:17:34 +00:00
|
|
|
int count = FaweAPI.fixLighting(player.getWorld(), selection,null, FaweQueue.RelightMode.ALL);
|
2018-08-12 14:03:07 +00:00
|
|
|
BBC.LIGHTING_PROPOGATE_SELECTION.send(fp, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = {"/getlighting"},
|
|
|
|
desc = "Get the light at a position",
|
|
|
|
min = 0,
|
|
|
|
max = 0
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.light.fix")
|
|
|
|
public void getlighting(Player player) throws WorldEditException {
|
|
|
|
FawePlayer fp = FawePlayer.wrap(player);
|
2019-06-06 01:17:34 +00:00
|
|
|
final Location loc = player.getLocation();
|
2018-08-12 14:03:07 +00:00
|
|
|
FaweQueue queue = fp.getFaweQueue(false);
|
2019-06-06 01:17:34 +00:00
|
|
|
fp.sendMessage(BBC.getPrefix() + "Light: " + queue.getEmmittedLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()) + " | " + queue.getSkyLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = {"/removelight", "/removelighting"},
|
|
|
|
desc = "Removing lighting in a selection",
|
|
|
|
min = 0,
|
|
|
|
max = 0
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.light.remove")
|
|
|
|
public void removelighting(Player player) {
|
|
|
|
FawePlayer fp = FawePlayer.wrap(player);
|
|
|
|
Region selection = fp.getSelection();
|
|
|
|
if (selection == null) {
|
2019-06-06 01:17:34 +00:00
|
|
|
final int cx = player.getLocation().getBlockX() >> 4;
|
|
|
|
final int cz = player.getLocation().getBlockZ() >> 4;
|
2018-10-19 20:13:32 +00:00
|
|
|
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
2019-06-06 01:17:34 +00:00
|
|
|
int count = FaweAPI.fixLighting(player.getWorld(), selection, null, FaweQueue.RelightMode.NONE);
|
2018-08-12 14:03:07 +00:00
|
|
|
BBC.UPDATED_LIGHTING_SELECTION.send(fp, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = {"/nbtinfo", "/nbt"},
|
|
|
|
desc = "View nbt info for a block"
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.nbtinfo")
|
|
|
|
public void nbtinfo(Player player, EditSession editSession) {
|
|
|
|
Location pos = player.getBlockTrace(128);
|
|
|
|
if (pos == null) {
|
|
|
|
BBC.NO_BLOCK.send(player);
|
|
|
|
return;
|
|
|
|
}
|
2019-03-31 16:09:20 +00:00
|
|
|
CompoundTag nbt = editSession.getFullBlock(pos.toBlockPoint()).getNbtData();
|
2018-08-12 14:03:07 +00:00
|
|
|
if (nbt != null) {
|
|
|
|
player.print(nbt.getValue().toString());
|
|
|
|
} else {
|
|
|
|
BBC.NO_BLOCK.send(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = {"/setblocklight", "/setlight"},
|
|
|
|
desc = "Set block lighting in a selection",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.light.set")
|
|
|
|
public void setlighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
|
|
|
|
FawePlayer fp = FawePlayer.wrap(player);
|
|
|
|
final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) fp.getFaweQueue(false);
|
2019-01-09 07:13:44 +00:00
|
|
|
for (BlockVector3 pt : region) {
|
2019-06-06 01:17:34 +00:00
|
|
|
queue.setBlockLight(pt.getX(), pt.getY(), pt.getZ(), value);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
int count = 0;
|
2019-01-09 07:13:44 +00:00
|
|
|
for (BlockVector2 chunk : region.getChunks()) {
|
2018-08-12 14:03:07 +00:00
|
|
|
queue.sendChunk(queue.getFaweChunk(chunk.getBlockX(), chunk.getBlockZ()));
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
BBC.UPDATED_LIGHTING_SELECTION.send(fp, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = {"/setskylight"},
|
|
|
|
desc = "Set sky lighting in a selection",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.light.set")
|
|
|
|
public void setskylighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
|
|
|
|
FawePlayer fp = FawePlayer.wrap(player);
|
|
|
|
final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) fp.getFaweQueue(false);
|
2019-01-09 07:13:44 +00:00
|
|
|
for (BlockVector3 pt : region) {
|
2019-06-06 01:17:34 +00:00
|
|
|
queue.setSkyLight(pt.getX(), pt.getY(), pt.getZ(), value);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
int count = 0;
|
2019-01-09 07:13:44 +00:00
|
|
|
for (BlockVector2 chunk : region.getChunks()) {
|
2018-08-12 14:03:07 +00:00
|
|
|
queue.sendChunk(queue.getFaweChunk(chunk.getBlockX(), chunk.getBlockZ()));
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
BBC.UPDATED_LIGHTING_SELECTION.send(fp, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-06-12 13:45:41 +00:00
|
|
|
aliases = {"/line"},
|
2018-08-12 14:03:07 +00:00
|
|
|
usage = "<pattern> [thickness]",
|
2014-04-03 02:08:50 +00:00
|
|
|
desc = "Draws a line segment between cuboid selection corners",
|
|
|
|
help =
|
2019-06-12 13:45:41 +00:00
|
|
|
"Draws a line segment between cuboid selection corners.\n" +
|
|
|
|
"Can only be used with cuboid selections.\n" +
|
|
|
|
"Flags:\n" +
|
|
|
|
" -h generates only a shell",
|
2014-04-03 02:08:50 +00:00
|
|
|
flags = "h",
|
|
|
|
min = 1,
|
|
|
|
max = 2
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.line")
|
|
|
|
@Logging(REGION)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void line(Player player, EditSession editSession,
|
|
|
|
@Selection Region region,
|
|
|
|
Pattern pattern,
|
|
|
|
@Optional("0") @Range(min = 0) int thickness,
|
|
|
|
@Switch('h') boolean shell) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
if (!(region instanceof CuboidRegion)) {
|
2019-06-12 13:45:41 +00:00
|
|
|
player.printError(BBC.getPrefix() + "//line only works with cuboid selections");
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CuboidRegion cuboidregion = (CuboidRegion) region;
|
2018-12-23 16:19:33 +00:00
|
|
|
BlockVector3 pos1 = cuboidregion.getPos1();
|
|
|
|
BlockVector3 pos2 = cuboidregion.getPos2();
|
2018-06-15 05:41:37 +00:00
|
|
|
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
BBC.VISITOR_BLOCK.send(player, blocksChanged);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-06-12 13:45:41 +00:00
|
|
|
aliases = {"/curve", "/spline"},
|
2018-08-12 14:03:07 +00:00
|
|
|
usage = "<pattern> [thickness]",
|
2014-04-03 02:08:50 +00:00
|
|
|
desc = "Draws a spline through selected points",
|
|
|
|
help =
|
2019-06-12 13:45:41 +00:00
|
|
|
"Draws a spline through selected points.\n" +
|
|
|
|
"Can only be used with convex polyhedral selections.\n" +
|
|
|
|
"Flags:\n" +
|
|
|
|
" -h generates only a shell",
|
2014-04-03 02:08:50 +00:00
|
|
|
flags = "h",
|
|
|
|
min = 1,
|
|
|
|
max = 2
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.curve")
|
|
|
|
@Logging(REGION)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void curve(FawePlayer player, EditSession editSession,
|
2014-06-28 08:01:49 +00:00
|
|
|
@Selection Region region,
|
|
|
|
Pattern pattern,
|
|
|
|
@Optional("0") @Range(min = 0) int thickness,
|
2018-08-12 14:03:07 +00:00
|
|
|
@Switch('h') boolean shell,
|
|
|
|
CommandContext context) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
if (!(region instanceof ConvexPolyhedralRegion)) {
|
2019-06-12 13:45:41 +00:00
|
|
|
player.sendMessage(BBC.getPrefix() + "//curve only works with convex polyhedral selections");
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-08-12 14:03:07 +00:00
|
|
|
worldEdit.checkMaxRadius(thickness);
|
|
|
|
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
2018-12-23 16:19:33 +00:00
|
|
|
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
|
|
|
|
List<BlockVector3> vectors = new ArrayList<>(cpregion.getVertices());
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-09-07 15:09:31 +00:00
|
|
|
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-09-07 15:09:31 +00:00
|
|
|
BBC.VISITOR_BLOCK.send(player, blocksChanged);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-04-02 20:26:51 +00:00
|
|
|
aliases = { "/replace", "/re", "/rep" },
|
2019-04-05 04:48:41 +00:00
|
|
|
usage = "[from-mask] <to-pattern>",
|
2019-06-12 13:45:41 +00:00
|
|
|
desc = "Replace all blocks in the selection with another",
|
|
|
|
flags = "f",
|
|
|
|
min = 1,
|
|
|
|
max = 2
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.replace")
|
|
|
|
@Logging(REGION)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void replace(FawePlayer player, EditSession editSession, @Selection Region region, @Optional Mask from, Pattern to, CommandContext context) throws WorldEditException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
|
|
|
int affected = editSession.replaceBlocks(region, from == null ? new ExistingBlockMask(editSession) : from, to);
|
|
|
|
BBC.VISITOR_BLOCK.send(player, affected);
|
|
|
|
if (!player.hasPermission("fawe.tips"))
|
|
|
|
BBC.TIP_REPLACE_ID.or(BBC.TIP_REPLACE_LIGHT, BBC.TIP_REPLACE_MARKER, BBC.TIP_TAB_COMPLETE, BBC.TIP_REPLACE_REGEX, BBC.TIP_REPLACE_REGEX_2, BBC.TIP_REPLACE_REGEX_3, BBC.TIP_REPLACE_REGEX_4, BBC.TIP_REPLACE_REGEX_5).send(player);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Compatibility for SKCompat
|
|
|
|
@Deprecated
|
|
|
|
public void set(Player player, LocalSession session, EditSession editSession, Pattern pattern) throws WorldEditException {
|
|
|
|
set(FawePlayer.wrap(player), session, editSession, session.getSelection(player.getWorld()), pattern, null);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"/set", "/s"},
|
|
|
|
usage = "[pattern]",
|
|
|
|
desc = "Set all blocks within selection",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.set")
|
|
|
|
@Logging(REGION)
|
|
|
|
public void set(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region selection, Pattern to, CommandContext context) throws WorldEditException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
2019-02-27 13:09:04 +00:00
|
|
|
int affected = editSession.setBlocks(selection, to);
|
2018-09-07 15:09:31 +00:00
|
|
|
if (affected != 0) {
|
|
|
|
BBC.OPERATION.send(player, affected);
|
|
|
|
if (!player.hasPermission("fawe.tips"))
|
|
|
|
BBC.TIP_FAST.or(BBC.TIP_CANCEL, BBC.TIP_MASK, BBC.TIP_MASK_ANGLE, BBC.TIP_SET_LINEAR, BBC.TIP_SURFACE_SPREAD, BBC.TIP_SET_HAND).send(player);
|
|
|
|
}
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), selection, context);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-06-12 13:45:41 +00:00
|
|
|
aliases = {"/overlay"},
|
|
|
|
usage = "<pattern>",
|
|
|
|
desc = "Set a block on top of blocks in the region",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.overlay")
|
|
|
|
@Logging(REGION)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void overlay(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
|
|
|
int affected = editSession.overlayCuboidBlocks(region, pattern);
|
|
|
|
BBC.VISITOR_BLOCK.send(player, affected);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"/lay"},
|
|
|
|
usage = "<pattern>",
|
|
|
|
desc = "Set the top block in the region",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.overlay")
|
|
|
|
@Logging(REGION)
|
|
|
|
public void lay(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
2019-01-09 07:13:44 +00:00
|
|
|
BlockVector3 min = region.getMinimumPoint();
|
|
|
|
BlockVector3 max = region.getMaximumPoint();
|
2018-09-07 15:09:31 +00:00
|
|
|
int maxY = max.getBlockY();
|
|
|
|
int width = region.getWidth();
|
|
|
|
int height = region.getLength();
|
|
|
|
int bx = min.getBlockX();
|
|
|
|
int bz = min.getBlockZ();
|
2019-01-09 07:13:44 +00:00
|
|
|
Iterable<BlockVector2> flat = Regions.asFlatRegion(region).asFlatRegion();
|
|
|
|
Iterator<BlockVector2> iter = new Fast2DIterator(flat, editSession).iterator();
|
2018-09-07 15:09:31 +00:00
|
|
|
int y = 0;
|
|
|
|
int affected = 0;
|
|
|
|
while (iter.hasNext()) {
|
2019-01-09 07:13:44 +00:00
|
|
|
BlockVector2 pos = iter.next();
|
2018-09-07 15:09:31 +00:00
|
|
|
int x = pos.getBlockX();
|
|
|
|
int z = pos.getBlockZ();
|
|
|
|
y = editSession.getNearestSurfaceTerrainBlock(x, z, y, 0, maxY);
|
|
|
|
editSession.setBlock(x, y, z, pattern);
|
|
|
|
affected++;
|
|
|
|
}
|
|
|
|
BBC.VISITOR_BLOCK.send(player, affected);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-06-12 13:45:41 +00:00
|
|
|
aliases = {"/center", "/middle"},
|
|
|
|
usage = "<pattern>",
|
|
|
|
desc = "Set the center block(s)",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@Logging(REGION)
|
|
|
|
@CommandPermissions("worldedit.region.center")
|
2014-06-28 08:01:49 +00:00
|
|
|
public void center(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
2018-06-15 05:41:37 +00:00
|
|
|
int affected = editSession.center(region, pattern);
|
2018-08-12 14:03:07 +00:00
|
|
|
BBC.VISITOR_BLOCK.send(player, affected);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-06-12 13:45:41 +00:00
|
|
|
aliases = {"/naturalize"},
|
|
|
|
usage = "",
|
|
|
|
desc = "3 layers of dirt on top then rock below",
|
|
|
|
min = 0,
|
|
|
|
max = 0
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.naturalize")
|
|
|
|
@Logging(REGION)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void naturalize(FawePlayer player, EditSession editSession, @Selection Region region, CommandContext context) throws WorldEditException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
|
|
|
int affected = editSession.naturalizeCuboidBlocks(region);
|
|
|
|
BBC.VISITOR_BLOCK.send(player, affected);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-06-12 13:45:41 +00:00
|
|
|
aliases = {"/walls"},
|
|
|
|
usage = "<pattern>",
|
|
|
|
desc = "Build the four sides of the selection",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.walls")
|
|
|
|
@Logging(REGION)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void walls(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
|
|
|
int affected = editSession.makeWalls(region, pattern);
|
|
|
|
BBC.VISITOR_BLOCK.send(player, affected);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-06-12 13:45:41 +00:00
|
|
|
aliases = {"/faces", "/outline"},
|
|
|
|
usage = "<pattern>",
|
|
|
|
desc = "Build the walls, ceiling, and floor of a selection",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.faces")
|
|
|
|
@Logging(REGION)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void faces(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
|
|
|
int affected = editSession.makeCuboidFaces(region, pattern);
|
|
|
|
BBC.VISITOR_BLOCK.send(player, affected);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/smooth" },
|
2019-02-26 23:15:35 +00:00
|
|
|
usage = "[iterations] [filter]",
|
2014-04-03 02:08:50 +00:00
|
|
|
desc = "Smooth the elevation in the selection",
|
|
|
|
help =
|
2019-02-26 23:15:35 +00:00
|
|
|
"Smooths the elevation in the selection.\n" +
|
|
|
|
"Optionally, restricts the height map to a set of blocks specified with mask syntax.\n" +
|
|
|
|
"For example, '//smooth 1 grass_block,dirt,stone' would only smooth natural surface terrain.",
|
2014-04-03 02:08:50 +00:00
|
|
|
min = 0,
|
2019-02-26 23:15:35 +00:00
|
|
|
max = 2
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
2019-06-12 13:45:41 +00:00
|
|
|
@CommandPermissions("worldedit.region.smoothsnow")
|
2014-04-03 02:08:50 +00:00
|
|
|
@Logging(REGION)
|
2019-04-03 05:53:34 +00:00
|
|
|
public void smooth(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Optional Mask mask, @Switch('s') boolean snow, CommandContext context) throws WorldEditException {
|
2019-01-09 07:13:44 +00:00
|
|
|
BlockVector3 min = region.getMinimumPoint();
|
|
|
|
BlockVector3 max = region.getMaximumPoint();
|
2018-09-07 15:31:30 +00:00
|
|
|
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
|
|
|
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
|
|
|
if (volume >= limit.MAX_CHECKS) {
|
|
|
|
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
|
|
|
}
|
|
|
|
player.checkConfirmationRegion(() -> {
|
|
|
|
try {
|
2019-04-03 05:53:34 +00:00
|
|
|
HeightMap heightMap = new HeightMap(editSession, region, mask, snow);
|
|
|
|
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
2018-09-07 15:09:31 +00:00
|
|
|
int affected = heightMap.applyFilter(filter, iterations);
|
|
|
|
BBC.VISITOR_BLOCK.send(player, affected);
|
2018-09-07 15:31:30 +00:00
|
|
|
} catch (Throwable e) {
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
@Command(
|
|
|
|
aliases = {"/wea", "wea", "worldeditanywhere", "/worldeditanywhere", "/weanywhere"},
|
|
|
|
desc = "Bypass region restrictions",
|
|
|
|
help = "Bypass region restrictions"
|
|
|
|
)
|
|
|
|
@CommandPermissions("fawe.admin")
|
|
|
|
public void wea(Player player) throws WorldEditException {
|
|
|
|
FawePlayer<Object> fp = FawePlayer.wrap(player);
|
|
|
|
if (fp.toggle("fawe.bypass")) {
|
|
|
|
BBC.WORLDEDIT_BYPASSED.send(fp);
|
|
|
|
} else {
|
|
|
|
BBC.WORLDEDIT_RESTRICTED.send(fp);
|
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"/wer", "wer", "worldeditregion", "/worldeditregion", "select", "/select"},
|
|
|
|
desc = "Select your current allowed region",
|
|
|
|
help = "Select your current allowed region"
|
|
|
|
)
|
|
|
|
@CommandPermissions("fawe.worldeditregion")
|
|
|
|
public void wer(Player player) throws WorldEditException {
|
|
|
|
FawePlayer<Object> fp = FawePlayer.wrap(player);
|
|
|
|
final Region region = fp.getLargestRegion();
|
|
|
|
if (region == null) {
|
|
|
|
BBC.NO_REGION.send(fp);
|
|
|
|
} else {
|
|
|
|
fp.setSelection(region);
|
|
|
|
BBC.SET_REGION.send(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Command(
|
2019-06-12 13:45:41 +00:00
|
|
|
aliases = {"/move"},
|
|
|
|
usage = "[count] [direction] [leave-id]",
|
|
|
|
flags = "sbea",
|
|
|
|
desc = "Move the contents of the selection",
|
|
|
|
help =
|
|
|
|
"Moves the contents of the selection.\n" +
|
|
|
|
"The -s flag shifts the selection to the target location.\n" +
|
|
|
|
" -b also copies biomes\n" +
|
|
|
|
" -e ignores entities\n" +
|
|
|
|
" -a ignores air\n" +
|
|
|
|
"Optionally fills the old location with <leave-id>.",
|
|
|
|
min = 0,
|
|
|
|
max = 3
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.move")
|
|
|
|
@Logging(ORIENTATION_REGION)
|
2019-06-12 13:45:41 +00:00
|
|
|
public void move(FawePlayer player, LocalSession session, EditSession editSession,
|
2014-06-28 08:01:49 +00:00
|
|
|
@Selection Region region,
|
|
|
|
@Optional("1") @Range(min = 1) int count,
|
2018-11-12 02:38:13 +00:00
|
|
|
@Optional(Direction.AIM) @Direction(includeDiagonals = true) BlockVector3 direction,
|
2018-08-12 14:03:07 +00:00
|
|
|
@Optional("air") Pattern replace,
|
|
|
|
@Switch('b') boolean copyBiomes,
|
|
|
|
@Switch('e') boolean skipEntities,
|
|
|
|
@Switch('a') boolean skipAir,
|
|
|
|
@Switch('s') boolean moveSelection,
|
|
|
|
CommandContext context) throws WorldEditException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
|
|
|
int affected = editSession.moveRegion(region, direction, count, !skipAir, !skipEntities, copyBiomes, replace);
|
|
|
|
|
|
|
|
if (moveSelection) {
|
|
|
|
try {
|
|
|
|
region.shift(direction.multiply(count));
|
|
|
|
|
|
|
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
|
|
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
|
|
|
|
} catch (RegionOperationException e) {
|
2019-06-12 13:45:41 +00:00
|
|
|
player.sendMessage(BBC.getPrefix() + e.getMessage());
|
2018-09-07 15:09:31 +00:00
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2018-09-07 15:09:31 +00:00
|
|
|
BBC.VISITOR_BLOCK.send(player, affected);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"/fall"},
|
|
|
|
usage = "[replace]",
|
|
|
|
flags = "m",
|
|
|
|
desc = "Have the blocks in the selection fall",
|
|
|
|
help =
|
|
|
|
"Make the blocks in the selection fall\n" +
|
|
|
|
"The -m flag will only fall within the vertical selection.",
|
|
|
|
min = 0,
|
|
|
|
max = 2
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.fall")
|
|
|
|
@Logging(ORIENTATION_REGION)
|
|
|
|
public void fall(FawePlayer player, EditSession editSession, LocalSession session,
|
|
|
|
@Selection Region region,
|
|
|
|
@Optional("air") BlockStateHolder replace,
|
|
|
|
@Switch('m') boolean notFullHeight,
|
|
|
|
CommandContext context) throws WorldEditException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
|
|
|
int affected = editSession.fall(region, !notFullHeight, replace);
|
|
|
|
BBC.VISITOR_BLOCK.send(player, affected);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-06-12 13:45:41 +00:00
|
|
|
aliases = {"/stack"},
|
|
|
|
usage = "[count] [direction]",
|
|
|
|
flags = "sam",
|
|
|
|
desc = "Repeat the contents of the selection",
|
|
|
|
help =
|
|
|
|
"Repeats the contents of the selection.\n" +
|
|
|
|
"Flags:\n" +
|
|
|
|
" -s shifts the selection to the last stacked copy\n" +
|
|
|
|
" -a skips air blocks",
|
|
|
|
min = 0,
|
|
|
|
max = 2
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.stack")
|
|
|
|
@Logging(ORIENTATION_REGION)
|
2019-06-12 13:45:41 +00:00
|
|
|
public void stack(FawePlayer player, LocalSession session, EditSession editSession,
|
2014-06-28 08:01:49 +00:00
|
|
|
@Selection Region region,
|
|
|
|
@Optional("1") @Range(min = 1) int count,
|
2018-11-12 02:38:13 +00:00
|
|
|
@Optional(Direction.AIM) @Direction(includeDiagonals = true) BlockVector3 direction,
|
2014-06-28 08:01:49 +00:00
|
|
|
@Switch('s') boolean moveSelection,
|
2018-08-12 14:03:07 +00:00
|
|
|
@Switch('b') boolean copyBiomes,
|
|
|
|
@Switch('e') boolean skipEntities,
|
|
|
|
@Switch('a') boolean ignoreAirBlocks, @Switch('m') Mask sourceMask, CommandContext context) throws WorldEditException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationStack(() -> {
|
|
|
|
if (sourceMask != null) {
|
|
|
|
editSession.addSourceMask(sourceMask);
|
|
|
|
}
|
|
|
|
int affected = editSession.stackCuboidRegion(region, direction, count, !ignoreAirBlocks, !skipEntities, copyBiomes);
|
|
|
|
|
|
|
|
if (moveSelection) {
|
|
|
|
try {
|
2019-01-09 07:13:44 +00:00
|
|
|
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
2019-04-02 20:26:51 +00:00
|
|
|
final BlockVector3 shiftVector = BlockVector3.at(direction.getX() * size.getX() * count, direction.getY() * size.getY() * count, direction.getZ() * size.getZ() * count);
|
2018-09-07 15:09:31 +00:00
|
|
|
region.shift(shiftVector);
|
|
|
|
|
|
|
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
|
|
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
|
|
|
|
} catch (RegionOperationException e) {
|
2019-06-12 13:45:41 +00:00
|
|
|
player.sendMessage(BBC.getPrefix() + e.getMessage());
|
2018-09-07 15:09:31 +00:00
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2018-09-07 15:09:31 +00:00
|
|
|
BBC.VISITOR_BLOCK.send(player, affected);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, count, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-06-12 13:45:41 +00:00
|
|
|
aliases = {"/deform"},
|
2014-04-03 02:08:50 +00:00
|
|
|
usage = "<expression>",
|
|
|
|
desc = "Deforms a selected region with an expression",
|
|
|
|
help =
|
2019-06-12 13:45:41 +00:00
|
|
|
"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.",
|
2014-04-03 02:08:50 +00:00
|
|
|
flags = "ro",
|
|
|
|
min = 1,
|
|
|
|
max = -1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.deform")
|
|
|
|
@Logging(ALL)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void deform(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
2014-06-28 08:01:49 +00:00
|
|
|
@Selection Region region,
|
|
|
|
@Text String expression,
|
|
|
|
@Switch('r') boolean useRawCoords,
|
2019-06-12 13:45:41 +00:00
|
|
|
@Switch('o') boolean offset,
|
|
|
|
CommandContext context) throws WorldEditException {
|
2018-12-23 16:19:33 +00:00
|
|
|
final Vector3 zero;
|
|
|
|
Vector3 unit;
|
2018-09-07 15:31:30 +00:00
|
|
|
if (useRawCoords) {
|
2018-12-23 16:19:33 +00:00
|
|
|
zero = Vector3.ZERO;
|
|
|
|
unit = Vector3.ONE;
|
2018-09-07 15:31:30 +00:00
|
|
|
} else if (offset) {
|
2018-12-23 16:19:33 +00:00
|
|
|
zero = session.getPlacementPosition(player).toVector3();
|
|
|
|
unit = Vector3.ONE;
|
2018-09-07 15:31:30 +00:00
|
|
|
} else {
|
2018-12-23 16:19:33 +00:00
|
|
|
final Vector3 min = region.getMinimumPoint().toVector3();
|
|
|
|
final Vector3 max = region.getMaximumPoint().toVector3();
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-12-23 16:19:33 +00:00
|
|
|
zero = max.add(min).divide(2);
|
2018-09-07 15:31:30 +00:00
|
|
|
unit = max.subtract(zero);
|
|
|
|
|
2018-12-23 16:19:33 +00:00
|
|
|
if (unit.getX() == 0) unit = unit.withX(1.0);
|
|
|
|
if (unit.getY() == 0) unit = unit.withY(1.0);
|
|
|
|
if (unit.getZ() == 0) unit = unit.withZ(1.0);
|
2018-09-07 15:31:30 +00:00
|
|
|
}
|
2019-06-06 01:17:34 +00:00
|
|
|
|
2019-01-09 07:13:44 +00:00
|
|
|
final Vector3 unit1 = unit;
|
2018-09-07 15:31:30 +00:00
|
|
|
fp.checkConfirmationRegion(() -> {
|
2018-09-07 15:09:31 +00:00
|
|
|
try {
|
2019-01-09 07:13:44 +00:00
|
|
|
final int affected = editSession.deformRegion(region, zero, unit1, expression);
|
2018-09-07 15:09:31 +00:00
|
|
|
player.findFreePosition();
|
|
|
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
|
|
|
} catch (ExpressionException e) {
|
2019-06-12 13:45:41 +00:00
|
|
|
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
2018-09-07 15:09:31 +00:00
|
|
|
}
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = {"/regen"},
|
|
|
|
usage = "[biome] [seed]",
|
|
|
|
desc = "Regenerates the contents of the selection",
|
|
|
|
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.",
|
|
|
|
min = 0,
|
|
|
|
max = 2
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.regen")
|
|
|
|
@Logging(REGION)
|
2018-09-07 23:10:36 +00:00
|
|
|
public void regenerateChunk(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, CommandContext context) throws WorldEditException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
|
|
|
Mask mask = session.getMask();
|
|
|
|
Mask sourceMask = session.getSourceMask();
|
|
|
|
session.setMask((Mask) null);
|
|
|
|
session.setSourceMask((Mask) null);
|
2019-04-03 05:53:34 +00:00
|
|
|
BiomeType biome = null;
|
2018-09-07 23:10:36 +00:00
|
|
|
if (context.argsLength() >= 1) {
|
2018-09-07 15:09:31 +00:00
|
|
|
BiomeRegistry biomeRegistry = worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
2019-04-05 04:15:10 +00:00
|
|
|
Collection<BiomeType> knownBiomes = BiomeTypes.values();
|
2018-09-07 23:10:36 +00:00
|
|
|
biome = Biomes.findBiomeByName(knownBiomes, context.getString(0), biomeRegistry);
|
2018-09-07 15:09:31 +00:00
|
|
|
}
|
2018-09-07 23:10:36 +00:00
|
|
|
Long seed = context.argsLength() != 2 || !MathMan.isInteger(context.getString(1)) ? null : Long.parseLong(context.getString(1));
|
2018-09-07 15:09:31 +00:00
|
|
|
editSession.regenerate(region, biome, seed);
|
|
|
|
session.setMask(mask);
|
|
|
|
session.setSourceMask(mask);
|
|
|
|
if (!player.hasPermission("fawe.tips")) {
|
|
|
|
BBC.COMMAND_REGEN_2.send(player);
|
|
|
|
} else if (biome == null) {
|
|
|
|
BBC.COMMAND_REGEN_0.send(player);
|
2019-06-06 01:17:34 +00:00
|
|
|
if (!player.hasPermission("fawe.tips")) BBC.TIP_REGEN_0.send(player);
|
2018-09-07 15:09:31 +00:00
|
|
|
} else if (seed == null) {
|
|
|
|
BBC.COMMAND_REGEN_1.send(player);
|
2019-06-06 01:17:34 +00:00
|
|
|
if (!player.hasPermission("fawe.tips")) BBC.TIP_REGEN_1.send(player);
|
2018-09-07 15:09:31 +00:00
|
|
|
} else {
|
|
|
|
BBC.COMMAND_REGEN_2.send(player);
|
|
|
|
}
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2018-09-07 15:09:31 +00:00
|
|
|
|
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-06-12 13:45:41 +00:00
|
|
|
aliases = {"/hollow"},
|
|
|
|
usage = "[<thickness>[ <pattern>]]",
|
|
|
|
desc = "Hollows out the object contained in this selection",
|
|
|
|
help =
|
|
|
|
"Hollows out the object contained in this selection.\n" +
|
|
|
|
"Optionally fills the hollowed out part with the given block.\n" +
|
|
|
|
"Thickness is measured in manhattan distance.",
|
|
|
|
min = 0,
|
|
|
|
max = 2
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.hollow")
|
|
|
|
@Logging(REGION)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void hollow(FawePlayer player, EditSession editSession,
|
2014-06-28 08:01:49 +00:00
|
|
|
@Selection Region region,
|
|
|
|
@Optional("0") @Range(min = 0) int thickness,
|
2018-08-12 14:03:07 +00:00
|
|
|
@Optional("air") Pattern pattern,
|
|
|
|
CommandContext context) throws WorldEditException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
|
|
|
int affected = editSession.hollowOutRegion(region, thickness, pattern);
|
|
|
|
BBC.VISITOR_BLOCK.send(player, affected);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-06-12 13:45:41 +00:00
|
|
|
aliases = {"/forest"},
|
2014-04-03 02:08:50 +00:00
|
|
|
usage = "[type] [density]",
|
|
|
|
desc = "Make a forest within the region",
|
|
|
|
min = 0,
|
|
|
|
max = 2
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.forest")
|
|
|
|
@Logging(REGION)
|
2014-07-07 00:34:08 +00:00
|
|
|
public void forest(Player player, EditSession editSession, @Selection Region region, @Optional("tree") TreeType type,
|
|
|
|
@Optional("5") @Range(min = 0, max = 100) double density) throws WorldEditException {
|
2019-03-21 01:05:11 +00:00
|
|
|
int affected = editSession.makeForest(region, density / 100, type);
|
2019-04-06 23:13:23 +00:00
|
|
|
BBC.COMMAND_TREE.send(player, affected);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-06-12 13:45:41 +00:00
|
|
|
aliases = {"/flora"},
|
2014-04-03 02:08:50 +00:00
|
|
|
usage = "[density]",
|
|
|
|
desc = "Make flora within the region",
|
|
|
|
min = 0,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.region.flora")
|
|
|
|
@Logging(REGION)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void flora(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("10") @Range(min = 0, max = 100) double density, CommandContext context) throws WorldEditException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
2019-06-12 13:45:41 +00:00
|
|
|
FloraGenerator generator = new FloraGenerator(editSession);
|
|
|
|
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
|
|
|
|
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
|
|
|
visitor.setMask(new NoiseFilter2D(new RandomNoise(), density / 100));
|
|
|
|
Operations.completeLegacy(visitor);
|
2018-09-07 15:09:31 +00:00
|
|
|
|
|
|
|
BBC.COMMAND_FLORA.send(player, ground.getAffected());
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2019-06-12 13:45:41 +00:00
|
|
|
|
2019-04-02 20:26:51 +00:00
|
|
|
}
|