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.Fawe;
|
|
|
|
import com.boydti.fawe.config.BBC;
|
|
|
|
import com.boydti.fawe.jnbt.anvil.generator.CavesGen;
|
|
|
|
import com.boydti.fawe.object.FawePlayer;
|
|
|
|
import com.boydti.fawe.util.MainUtil;
|
|
|
|
import com.boydti.fawe.util.MathMan;
|
|
|
|
import com.boydti.fawe.util.TextureUtil;
|
|
|
|
import com.boydti.fawe.util.image.ImageUtil;
|
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-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.*;
|
|
|
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
|
|
import com.sk89q.worldedit.world.block.BlockState;
|
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.function.RegionFunction;
|
|
|
|
import com.sk89q.worldedit.function.mask.Mask;
|
|
|
|
import com.sk89q.worldedit.function.operation.Operations;
|
2014-06-28 08:01:49 +00:00
|
|
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
2014-06-28 08:01:49 +00:00
|
|
|
import com.sk89q.worldedit.internal.annotation.Selection;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.worldedit.regions.Region;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.util.TreeGenerator;
|
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;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.util.command.parametric.ParameterException;
|
2014-07-17 07:21:13 +00:00
|
|
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.world.block.BlockType;
|
|
|
|
|
|
|
|
import java.awt.RenderingHints;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.net.URL;
|
|
|
|
|
|
|
|
|
|
|
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
|
|
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
|
|
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
2014-06-28 08:01:49 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
/**
|
2014-06-28 08:01:49 +00:00
|
|
|
* Commands for the generation of shapes and other objects.
|
2014-04-03 02:08:50 +00:00
|
|
|
*/
|
2018-08-12 14:03:07 +00:00
|
|
|
@Command(aliases = {}, desc = "Create structures and features: [More Info](https://goo.gl/KuLFRW)")
|
|
|
|
public class GenerationCommands extends MethodCommands {
|
2014-06-28 08:01:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new instance.
|
|
|
|
*
|
|
|
|
* @param worldEdit reference to WorldEdit
|
|
|
|
*/
|
|
|
|
public GenerationCommands(WorldEdit worldEdit) {
|
2018-08-12 14:03:07 +00:00
|
|
|
super(worldEdit);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"/caves"},
|
|
|
|
usage = "[size=8] [freq=40] [rarity=7] [minY=8] [maxY=127] [sysFreq=1] [sysRarity=25] [pocketRarity=0] [pocketMin=0] [pocketMax=3]",
|
|
|
|
desc = "Generates caves",
|
|
|
|
help = "Generates a cave network"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
2018-08-12 14:03:07 +00:00
|
|
|
@CommandPermissions("worldedit.generation.caves")
|
2014-04-03 02:08:50 +00:00
|
|
|
@Logging(PLACEMENT)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void caves(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, @Optional("8") int size, @Optional("40") int frequency, @Optional("7") int rarity, @Optional("8") int minY, @Optional("127") int maxY, @Optional("1") int systemFrequency, @Optional("25") int individualRarity, @Optional("0") int pocketChance, @Optional("0") int pocketMin, @Optional("3") int pocketMax, CommandContext context) throws WorldEditException, ParameterException {
|
2018-09-07 15:09:31 +00:00
|
|
|
fp.checkConfirmationRegion(() -> {
|
|
|
|
CavesGen gen = new CavesGen(size, frequency, rarity, minY, maxY, systemFrequency, individualRarity, pocketChance, pocketMin, pocketMax);
|
|
|
|
editSession.generate(region, gen);
|
|
|
|
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
// public void addOre(Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"/ores"},
|
|
|
|
desc = "Generates ores",
|
|
|
|
help = "Generates ores",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
2018-08-12 14:03:07 +00:00
|
|
|
@CommandPermissions("worldedit.generation.ore")
|
|
|
|
@Logging(PLACEMENT)
|
|
|
|
public void ores(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, CommandContext context) throws WorldEditException, ParameterException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
|
|
|
editSession.addOres(region, mask);
|
|
|
|
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = {"/image", "/img"},
|
|
|
|
desc = "Generate an image",
|
|
|
|
usage = "<imgur> [randomize=true] [complexity=100] [dimensions=100,100]",
|
|
|
|
min = 1,
|
|
|
|
max = 4
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.generation.image")
|
2014-04-03 02:08:50 +00:00
|
|
|
@Logging(PLACEMENT)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void image(Player player, LocalSession session, EditSession editSession, String arg, @Optional("true") boolean randomize, @Optional("100") int threshold, @Optional Vector2D dimensions) throws WorldEditException, ParameterException, IOException {
|
|
|
|
TextureUtil tu = Fawe.get().getCachedTextureUtil(randomize, 0, threshold);
|
|
|
|
URL url = new URL(arg);
|
|
|
|
if (!url.getHost().equalsIgnoreCase("i.imgur.com") && !url.getHost().equalsIgnoreCase("empcraft.com")) {
|
|
|
|
throw new IOException("Only i.imgur.com or empcraft.com/ui links are allowed!");
|
|
|
|
}
|
|
|
|
FawePlayer<Object> fp = FawePlayer.wrap(player);
|
|
|
|
BufferedImage image = MainUtil.readImage(url);
|
|
|
|
if (dimensions != null) {
|
|
|
|
image = ImageUtil.getScaledInstance(image, dimensions.getBlockX(), dimensions.getBlockZ(), RenderingHints.VALUE_INTERPOLATION_BILINEAR, false);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
MutableBlockVector pos1 = new MutableBlockVector(player.getLocation().toVector());
|
|
|
|
MutableBlockVector pos2 = new MutableBlockVector(pos1.add(image.getWidth() - 1, 0, image.getHeight() - 1));
|
|
|
|
CuboidRegion region = new CuboidRegion(pos1, pos2);
|
|
|
|
int[] count = new int[1];
|
|
|
|
final BufferedImage finalImage = image;
|
|
|
|
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
|
|
|
@Override
|
|
|
|
public boolean apply(Vector pos) throws WorldEditException {
|
|
|
|
try {
|
|
|
|
int x = pos.getBlockX() - pos1.getBlockX();
|
|
|
|
int z = pos.getBlockZ() - pos1.getBlockZ();
|
|
|
|
int color = finalImage.getRGB(x, z);
|
|
|
|
BlockType block = tu.getNearestBlock(color);
|
|
|
|
count[0]++;
|
|
|
|
if (block != null) return editSession.setBlock(pos, block.getDefaultState());
|
|
|
|
return false;
|
|
|
|
} catch (Throwable e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}, editSession);
|
|
|
|
Operations.completeBlindly(visitor);
|
|
|
|
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
|
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
@Command(
|
|
|
|
aliases = {"/ore"},
|
|
|
|
usage = "<mask> <pattern> <size> <freq> <rarity> <minY> <maxY>",
|
|
|
|
desc = "Generates ores",
|
|
|
|
help = "Generates ores",
|
|
|
|
min = 7,
|
|
|
|
max = 7
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.generation.ore")
|
|
|
|
@Logging(PLACEMENT)
|
|
|
|
public void ore(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, @Range(min = 0) int size, int freq, @Range(min = 0, max = 100) int rarity, @Range(min = 0, max = 255) int minY, @Range(min = 0, max = 255) int maxY, CommandContext context) throws WorldEditException, ParameterException {
|
2018-09-07 15:09:31 +00:00
|
|
|
player.checkConfirmationRegion(() -> {
|
|
|
|
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
|
|
|
|
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = {"/hcyl"},
|
|
|
|
usage = "<pattern> <radius>[,<radius>] [height]",
|
|
|
|
desc = "Generates a hollow cylinder.",
|
|
|
|
help =
|
|
|
|
"Generates a hollow cylinder.\n" +
|
|
|
|
"By specifying 2 radii, separated by a comma,\n" +
|
|
|
|
"you can generate elliptical cylinders.\n" +
|
|
|
|
"The 1st radius is north/south, the 2nd radius is east/west.",
|
|
|
|
min = 2,
|
|
|
|
max = 4
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.generation.cylinder")
|
|
|
|
@Logging(PLACEMENT)
|
|
|
|
public void hcyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector2D radius, @Optional("1") int height, @Range(min = 1) @Optional("1") double thickness, CommandContext context) throws WorldEditException, ParameterException {
|
|
|
|
double max = MathMan.max(radius.getBlockX(), radius.getBlockZ());
|
|
|
|
worldEdit.checkMaxRadius(max);
|
2014-04-03 02:08:50 +00:00
|
|
|
Vector pos = session.getPlacementPosition(player);
|
2018-09-07 15:09:31 +00:00
|
|
|
fp.checkConfirmationRadius(() -> {
|
|
|
|
int affected = editSession.makeHollowCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), thickness - 1);
|
|
|
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), (int) max, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"/cyl"},
|
|
|
|
usage = "<pattern> <radius>[,<radius>] [height]",
|
|
|
|
flags = "h",
|
|
|
|
desc = "Generates a cylinder.",
|
|
|
|
help =
|
|
|
|
"Generates a cylinder.\n" +
|
|
|
|
"By specifying 2 radii, separated by a comma,\n" +
|
|
|
|
"you can generate elliptical cylinders.\n" +
|
|
|
|
"The 1st radius is north/south, the 2nd radius is east/west.",
|
|
|
|
min = 2,
|
|
|
|
max = 3
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
2018-08-12 14:03:07 +00:00
|
|
|
@CommandPermissions("worldedit.generation.cylinder")
|
2014-04-03 02:08:50 +00:00
|
|
|
@Logging(PLACEMENT)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void cyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector2D radius, @Optional("1") int height, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
|
|
|
|
double max = MathMan.max(radius.getBlockX(), radius.getBlockZ());
|
|
|
|
worldEdit.checkMaxRadius(max);
|
|
|
|
Vector pos = session.getPlacementPosition(player);
|
2018-09-07 15:09:31 +00:00
|
|
|
fp.checkConfirmationRadius(() -> {
|
|
|
|
int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), !hollow);
|
|
|
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), (int) max, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"/hsphere"},
|
|
|
|
usage = "<pattern> <radius>[,<radius>,<radius>] [raised?]",
|
|
|
|
desc = "Generates a hollow sphere.",
|
|
|
|
help =
|
|
|
|
"Generates a hollow sphere.\n" +
|
|
|
|
"By specifying 3 radii, separated by commas,\n" +
|
|
|
|
"you can generate an ellipsoid. The order of the ellipsoid radii\n" +
|
|
|
|
"is north/south, up/down, east/west.",
|
|
|
|
min = 2,
|
|
|
|
max = 3
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.generation.sphere")
|
|
|
|
@Logging(PLACEMENT)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void hsphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector radius, @Optional("false") boolean raised, CommandContext context) throws WorldEditException, ParameterException {
|
|
|
|
sphere(fp, player, session, editSession, pattern, radius, raised, true, context);
|
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
@Command(
|
|
|
|
aliases = {"/sphere"},
|
|
|
|
usage = "<pattern> <radius>[,<radius>,<radius>] [raised?]",
|
|
|
|
flags = "h",
|
|
|
|
desc = "Generates a filled sphere.",
|
|
|
|
help =
|
|
|
|
"Generates a filled sphere.\n" +
|
|
|
|
"By specifying 3 radii, separated by commas,\n" +
|
|
|
|
"you can generate an ellipsoid. The order of the ellipsoid radii\n" +
|
|
|
|
"is north/south, up/down, east/west.",
|
|
|
|
min = 2,
|
|
|
|
max = 3
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.generation.sphere")
|
|
|
|
@Logging(PLACEMENT)
|
|
|
|
public void sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector radius, @Optional("false") boolean raised, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
|
|
|
|
double max = MathMan.max(radius.getBlockX(), radius.getBlockY(), radius.getBlockZ());
|
|
|
|
worldEdit.checkMaxRadius(max);
|
2014-04-03 02:08:50 +00:00
|
|
|
Vector pos = session.getPlacementPosition(player);
|
2018-09-07 15:09:31 +00:00
|
|
|
Vector finalPos = raised ? pos.add(0, radius.getY(), 0) : pos;
|
|
|
|
fp.checkConfirmationRadius(() -> {
|
|
|
|
int affected = editSession.makeSphere(finalPos, pattern, radius.getX(), radius.getY(), radius.getZ(), !hollow);
|
|
|
|
player.findFreePosition();
|
|
|
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), (int) max, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"forestgen"},
|
|
|
|
usage = "[size] [tree-type] [density]",
|
|
|
|
desc = "Generate a forest",
|
|
|
|
min = 0,
|
|
|
|
max = 3
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.generation.forest")
|
|
|
|
@Logging(POSITION)
|
2018-08-12 14:03:07 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public void forestGen(Player player, LocalSession session, EditSession editSession, @Optional("10") int size, @Optional("tree") TreeType type, @Optional("5") double density) throws WorldEditException, ParameterException {
|
2014-06-28 08:01:49 +00:00
|
|
|
density = density / 100;
|
2018-06-19 07:03:09 +00:00
|
|
|
int affected = editSession.makeForest(session.getPlacementPosition(player), size, density, type);
|
2018-08-17 08:27:48 +00:00
|
|
|
player.print(BBC.getPrefix() + affected + " trees created.");
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"pumpkins"},
|
2018-08-17 08:27:48 +00:00
|
|
|
usage = "[size=10] [density=0.02]",
|
2018-08-12 14:03:07 +00:00
|
|
|
desc = "Generate pumpkin patches",
|
|
|
|
min = 0,
|
2018-08-17 08:27:48 +00:00
|
|
|
max = 2
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.generation.pumpkins")
|
|
|
|
@Logging(POSITION)
|
2018-08-17 08:27:48 +00:00
|
|
|
public void pumpkins(Player player, LocalSession session, EditSession editSession, @Optional("10") int apothem, @Optional("0.02") double density) throws WorldEditException, ParameterException {
|
|
|
|
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), apothem, density);
|
2018-08-12 14:03:07 +00:00
|
|
|
BBC.COMMAND_PUMPKIN.send(player, affected);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"/hpyramid"},
|
|
|
|
usage = "<pattern> <size>",
|
2014-06-28 08:01:49 +00:00
|
|
|
desc = "Generate a hollow pyramid",
|
|
|
|
min = 2,
|
|
|
|
max = 2
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.generation.pyramid")
|
|
|
|
@Logging(PLACEMENT)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void hollowPyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, CommandContext context) throws WorldEditException, ParameterException {
|
|
|
|
pyramid(fp, player, session, editSession, pattern, size, true, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"/pyramid"},
|
|
|
|
usage = "<pattern> <size>",
|
|
|
|
flags = "h",
|
|
|
|
desc = "Generate a filled pyramid",
|
|
|
|
min = 2,
|
|
|
|
max = 2
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.generation.pyramid")
|
|
|
|
@Logging(PLACEMENT)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void pyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
|
2014-06-28 08:01:49 +00:00
|
|
|
worldEdit.checkMaxRadius(size);
|
2018-09-07 15:09:31 +00:00
|
|
|
Vector pos = session.getPlacementPosition(player);
|
|
|
|
fp.checkConfirmationRadius(() -> {
|
|
|
|
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
|
|
|
|
player.findFreePosition();
|
|
|
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), size, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2018-08-12 14:03:07 +00:00
|
|
|
aliases = {"/generate", "/gen", "/g"},
|
|
|
|
usage = "<pattern> <expression>",
|
|
|
|
desc = "Generates a shape according to a formula.",
|
|
|
|
help =
|
|
|
|
"Generates a shape according to a formula that is expected to\n" +
|
|
|
|
"return positive numbers (true) if the point is inside the shape\n" +
|
|
|
|
"Optionally set type/data to the desired block.\n" +
|
|
|
|
"Flags:\n" +
|
|
|
|
" -h to generate a hollow shape\n" +
|
|
|
|
" -r to use raw minecraft coordinates\n" +
|
|
|
|
" -o is like -r, except offset from placement.\n" +
|
|
|
|
" -c is like -r, except offset selection center.\n" +
|
|
|
|
"If neither -r nor -o is given, the selection is mapped to -1..1\n" +
|
|
|
|
"See also tinyurl.com/wesyntax.",
|
|
|
|
flags = "hroc",
|
|
|
|
min = 2,
|
|
|
|
max = -1
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.generation.shape")
|
|
|
|
@Logging(ALL)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void generate(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
2014-06-28 08:01:49 +00:00
|
|
|
@Selection Region region,
|
|
|
|
Pattern pattern,
|
|
|
|
@Text String expression,
|
|
|
|
@Switch('h') boolean hollow,
|
|
|
|
@Switch('r') boolean useRawCoords,
|
|
|
|
@Switch('o') boolean offset,
|
2018-08-12 14:03:07 +00:00
|
|
|
@Switch('c') boolean offsetCenter,
|
|
|
|
CommandContext context) throws WorldEditException, ParameterException {
|
2018-09-07 15:31:30 +00:00
|
|
|
final Vector zero;
|
|
|
|
Vector unit;
|
|
|
|
|
|
|
|
if (useRawCoords) {
|
|
|
|
zero = Vector.ZERO;
|
|
|
|
unit = Vector.ONE;
|
|
|
|
} else if (offset) {
|
|
|
|
zero = session.getPlacementPosition(player);
|
|
|
|
unit = Vector.ONE;
|
|
|
|
} else if (offsetCenter) {
|
|
|
|
final Vector min = region.getMinimumPoint();
|
|
|
|
final Vector max = region.getMaximumPoint();
|
|
|
|
|
|
|
|
zero = max.add(min).multiply(0.5);
|
|
|
|
unit = Vector.ONE;
|
|
|
|
} else {
|
|
|
|
final Vector min = region.getMinimumPoint();
|
|
|
|
final Vector max = region.getMaximumPoint();
|
|
|
|
|
|
|
|
zero = max.add(min).multiply(0.5);
|
|
|
|
unit = max.subtract(zero);
|
|
|
|
|
|
|
|
if (unit.getX() == 0) unit.mutX(1);
|
|
|
|
if (unit.getY() == 0) unit.mutY(1);
|
|
|
|
if (unit.getZ() == 0) unit.mutZ(1);
|
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-09-07 15:31:30 +00:00
|
|
|
fp.checkConfirmationRegion(() -> {
|
2018-09-07 15:09:31 +00:00
|
|
|
try {
|
|
|
|
final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow);
|
|
|
|
player.findFreePosition();
|
|
|
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
|
|
|
} catch (ExpressionException e) {
|
|
|
|
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
|
|
|
}
|
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 = {"/generatebiome", "/genbiome", "/gb"},
|
|
|
|
usage = "<biome> <expression>",
|
|
|
|
desc = "Sets biome according to a formula.",
|
|
|
|
help =
|
|
|
|
"Generates a shape according to a formula that is expected to\n" +
|
|
|
|
"return positive numbers (true) if the point is inside the shape\n" +
|
|
|
|
"Sets the biome of blocks in that shape.\n" +
|
|
|
|
"Flags:\n" +
|
|
|
|
" -h to generate a hollow shape\n" +
|
|
|
|
" -r to use raw minecraft coordinates\n" +
|
|
|
|
" -o is like -r, except offset from placement.\n" +
|
|
|
|
" -c is like -r, except offset selection center.\n" +
|
|
|
|
"If neither -r nor -o is given, the selection is mapped to -1..1\n" +
|
|
|
|
"See also tinyurl.com/wesyntax.",
|
|
|
|
flags = "hroc",
|
|
|
|
min = 2,
|
|
|
|
max = -1
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions({"worldedit.generation.shape", "worldedit.biome.set"})
|
|
|
|
@Logging(ALL)
|
2018-08-12 14:03:07 +00:00
|
|
|
public void generateBiome(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
2014-06-28 08:01:49 +00:00
|
|
|
@Selection Region region,
|
2014-07-17 07:21:13 +00:00
|
|
|
BaseBiome target,
|
2014-06-28 08:01:49 +00:00
|
|
|
@Text String expression,
|
|
|
|
@Switch('h') boolean hollow,
|
|
|
|
@Switch('r') boolean useRawCoords,
|
|
|
|
@Switch('o') boolean offset,
|
2018-08-12 14:03:07 +00:00
|
|
|
@Switch('c') boolean offsetCenter,
|
|
|
|
CommandContext context) throws WorldEditException, ParameterException {
|
2018-09-07 15:31:30 +00:00
|
|
|
final Vector zero;
|
|
|
|
Vector unit;
|
|
|
|
|
|
|
|
if (useRawCoords) {
|
|
|
|
zero = Vector.ZERO;
|
|
|
|
unit = Vector.ONE;
|
|
|
|
} else if (offset) {
|
|
|
|
zero = session.getPlacementPosition(player);
|
|
|
|
unit = Vector.ONE;
|
|
|
|
} else if (offsetCenter) {
|
|
|
|
final Vector min = region.getMinimumPoint();
|
|
|
|
final Vector max = region.getMaximumPoint();
|
|
|
|
|
|
|
|
zero = max.add(min).multiply(0.5);
|
|
|
|
unit = Vector.ONE;
|
|
|
|
} else {
|
|
|
|
final Vector min = region.getMinimumPoint();
|
|
|
|
final Vector max = region.getMaximumPoint();
|
|
|
|
|
|
|
|
zero = max.add(min).multiply(0.5);
|
|
|
|
unit = max.subtract(zero);
|
|
|
|
|
|
|
|
if (unit.getX() == 0) unit.mutX(1);
|
|
|
|
if (unit.getY() == 0) unit.mutY(1);
|
|
|
|
if (unit.getZ() == 0) unit.mutZ(1);
|
|
|
|
}
|
2018-09-07 15:09:31 +00:00
|
|
|
fp.checkConfirmationRegion(() -> {
|
|
|
|
try {
|
|
|
|
final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow);
|
|
|
|
player.findFreePosition();
|
|
|
|
BBC.VISITOR_FLAT.send(fp, affected);
|
|
|
|
} catch (ExpressionException e) {
|
|
|
|
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
|
|
|
}
|
2018-09-07 23:10:36 +00:00
|
|
|
}, getArguments(context), region, context);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
}
|