From 69bd0274ddaf06da8b1e9e75c033dbe6ad97c579 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 23 Apr 2020 17:07:34 +0100 Subject: [PATCH] Fix undo for stack, move - Most/anything using ForwardCopyExtent basically --- .../operation/BackwardsExtentBlockCopy.java | 14 ++++++++++++-- .../function/operation/ForwardExtentCopy.java | 5 ++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java index f5dab3b03..10e910dde 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java @@ -2,6 +2,8 @@ package com.sk89q.worldedit.function.operation; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; +import com.sk89q.worldedit.function.visitor.FlatRegionVisitor; +import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableVector3; @@ -11,16 +13,18 @@ import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import java.util.List; -public class BackwardsExtentBlockCopy implements Operation { +public class BackwardsExtentBlockCopy extends RegionVisitor implements Operation { private final Region region; private final Transform transform; private final RegionFunction function; private final BlockVector3 origin; + private int affected = 0; private MutableBlockVector3 mutBV3 = new MutableBlockVector3(); private MutableVector3 mutV3 = new MutableVector3(); BackwardsExtentBlockCopy(Region region, BlockVector3 origin, Transform transform, RegionFunction function) { + super(region, function); this.region = region; this.transform = transform; this.function = function; @@ -34,7 +38,9 @@ public class BackwardsExtentBlockCopy implements Operation { for (BlockVector3 pt : destRegion) { BlockVector3 copyFrom = transform(inverse, pt); if (region.contains(copyFrom)) { - function.apply(pt); + if(function.apply(pt)) { + affected++; + } } } return null; @@ -68,6 +74,10 @@ public class BackwardsExtentBlockCopy implements Operation { return mutBV3; } + public int getAffected() { + return affected; + } + @Override public void cancel() { 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 99155b842..cedfee026 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 @@ -305,7 +305,7 @@ public class ForwardExtentCopy implements Operation { } RegionFunction copy; - Operation blockCopy = null; + RegionVisitor blockCopy = null; PositionTransformExtent transExt = null; if (!currentTransform.isIdentity()) { if (!(currentTransform instanceof AffineTransform) || ((AffineTransform) currentTransform).isOffAxis()) { @@ -414,8 +414,7 @@ public class ForwardExtentCopy implements Operation { } } - int affected; - affected = region.getArea(); + affectedBlocks += blockCopy.getAffected(); return null; }