Skip to content

Commit

Permalink
Added -s flag to //move and //stack to move the selection along with …
Browse files Browse the repository at this point in the history
…the blocks.
  • Loading branch information
wizjany committed May 16, 2011
1 parent 520d7ac commit f97c765
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/main/java/com/sk89q/worldedit/commands/RegionCommands.java
Expand Up @@ -29,6 +29,7 @@
import com.sk89q.worldedit.filtering.HeightMapFilter;
import com.sk89q.worldedit.patterns.*;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionOperationException;

/**
* Region related commands.
Expand Down Expand Up @@ -182,6 +183,7 @@ public static void smooth(CommandContext args, WorldEdit we,
@Command(
aliases = {"/move"},
usage = "[count] [direction] [leave-id]",
flags = "s",
desc = "Move the contents of the selection",
min = 0,
max = 3
Expand All @@ -205,14 +207,28 @@ public static void move(CommandContext args, WorldEdit we,

int affected = editSession.moveCuboidRegion(session.getSelection(player.getWorld()),
dir, count, true, replace);

if (args.hasFlag('s')) {
try {
Region region = session.getSelection(player.getWorld());
region.expand(dir.multiply(count));
region.contract(dir.multiply(count));

session.getRegionSelector().learnChanges();
session.getRegionSelector().explainRegionAdjust(player, session);
} catch (RegionOperationException e) {
player.printError(e.getMessage());
}
}

player.print(affected + " blocks moved.");
}


@Command(
aliases = {"/stack"},
usage = "[count] [direction]",
flags = "a",
flags = "sa",
desc = "Repeat the contents of the selection",
min = 0,
max = 2
Expand All @@ -228,6 +244,20 @@ public static void stack(CommandContext args, WorldEdit we,

int affected = editSession.stackCuboidRegion(session.getSelection(player.getWorld()),
dir, count, !args.hasFlag('a'));

if (args.hasFlag('s')) {
try {
Region region = session.getSelection(player.getWorld());
region.expand(dir.multiply(count));
region.contract(dir.multiply(count));

session.getRegionSelector().learnChanges();
session.getRegionSelector().explainRegionAdjust(player, session);
} catch (RegionOperationException e) {
player.printError(e.getMessage());
}
}

player.print(affected + " blocks changed. Undo with //undo");
}

Expand Down

0 comments on commit f97c765

Please sign in to comment.