Added a -s flag to //chunk, which extends your current selection to the encompassed chunks.

This commit is contained in:
TomyLobo 2011-08-16 10:10:23 +02:00
parent c79d90bb99
commit ea445ebcf5

View File

@ -170,7 +170,8 @@ public class SelectionCommands {
@Command(
aliases = {"/chunk"},
usage = "",
desc = "Set the selection to your current chunk",
flags = "s",
desc = "Set the selection to your current chunk. The -s flag extends your current selection to the encompassed chunks.",
min = 0,
max = 0
)
@ -179,9 +180,30 @@ public class SelectionCommands {
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
Vector2D min2D = ChunkStore.toChunk(player.getBlockIn());
Vector min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
Vector max = min.add(15, 127, 15);
final Vector min;
final Vector max;
if (args.hasFlag('s')) {
Region region = session.getSelection(player.getWorld());
final Vector2D min2D = ChunkStore.toChunk(region.getMinimumPoint());
final Vector2D max2D = ChunkStore.toChunk(region.getMaximumPoint());
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
max = new Vector(max2D.getBlockX() * 16 + 15, 127, max2D.getBlockZ() * 16 + 15);
player.print("Chunks selected: ("
+ min2D.getBlockX() + ", " + min2D.getBlockZ() + ") - ("
+ max2D.getBlockX() + ", " + max2D.getBlockZ() + ")");
}
else {
final Vector2D min2D = ChunkStore.toChunk(player.getBlockIn());
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
max = min.add(15, 127, 15);
player.print("Chunk selected: "
+ min2D.getBlockX() + ", " + min2D.getBlockZ());
}
CuboidRegionSelector selector = new CuboidRegionSelector();
selector.selectPrimary(min);
@ -190,8 +212,6 @@ public class SelectionCommands {
session.dispatchCUISelection(player);
player.print("Chunk selected: "
+ min2D.getBlockX() + ", " + min2D.getBlockZ());
}
@Command(