From e53962daddc3a9d342f386a79eec55789316d106 Mon Sep 17 00:00:00 2001 From: wizjany Date: Fri, 1 Mar 2019 21:15:21 -0500 Subject: [PATCH] Apply source function after source mask in ForwardExtentCopy. The source function should only get applied to actually copied blocks. --- .../src/main/java/com/sk89q/worldedit/EditSession.java | 2 +- .../java/com/sk89q/worldedit/command/RegionCommands.java | 8 +++++--- .../worldedit/function/operation/ForwardExtentCopy.java | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index fef75da83..404299e99 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -1252,7 +1252,7 @@ public class EditSession implements Extent, AutoCloseable { BlockVector3 to = region.getMinimumPoint(); // Remove the original blocks - com.sk89q.worldedit.function.pattern.Pattern pattern = replacement != null ? + Pattern pattern = replacement != null ? replacement : new BlockPattern(BlockTypes.AIR.getDefaultState()); BlockReplace remove = new BlockReplace(this, pattern); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 704025a3f..00c70d5c6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -262,11 +262,12 @@ public class RegionCommands { @Command( aliases = { "/move" }, usage = "[count] [direction] [leave-id]", - flags = "s", + flags = "sa", 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" + + "The -a flag skips air blocks.\n" + "Optionally fills the old location with .", min = 0, max = 3 @@ -278,9 +279,10 @@ public class RegionCommands { @Optional("1") @Range(min = 1) int count, @Optional(Direction.AIM) @Direction(includeDiagonals = true) BlockVector3 direction, @Optional("air") Pattern replace, - @Switch('s') boolean moveSelection) throws WorldEditException { + @Switch('s') boolean moveSelection, + @Switch('a') boolean ignoreAirBlocks) throws WorldEditException { - int affected = editSession.moveRegion(region, direction, count, true, replace); + int affected = editSession.moveRegion(region, direction, count, !ignoreAirBlocks, replace); if (moveSelection) { try { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java index b3f663836..cbf73e857 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java @@ -248,9 +248,9 @@ public class ForwardExtentCopy implements Operation { } ExtentBlockCopy blockCopy = new ExtentBlockCopy(source, from, destination, to, currentTransform); - RegionMaskingFilter filter = new RegionMaskingFilter(sourceMask, blockCopy); - RegionFunction function = sourceFunction != null ? new CombinedRegionFunction(filter, sourceFunction) : filter; - RegionVisitor blockVisitor = new RegionVisitor(region, function); + RegionMaskingFilter filteredFunction = new RegionMaskingFilter(sourceMask, + sourceFunction == null ? blockCopy : new CombinedRegionFunction(blockCopy, sourceFunction)); + RegionVisitor blockVisitor = new RegionVisitor(region, filteredFunction); lastVisitor = blockVisitor;