From ea445ebcf549d73471e11cc19f7a9725925ff802 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Tue, 16 Aug 2011 10:10:23 +0200 Subject: [PATCH] Added a -s flag to //chunk, which extends your current selection to the encompassed chunks. --- .../worldedit/commands/SelectionCommands.java | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java b/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java index 9f36ae4e3..172d86a8f 100644 --- a/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java @@ -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(