From 25021b4a30db971bfac9062dfd7b90f590794fe6 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 30 Mar 2014 13:46:20 -0700 Subject: [PATCH] Removed EditSession from RecursiveVisitor. --- src/main/java/com/sk89q/worldedit/EditSession.java | 8 +++++--- .../worldedit/function/visitor/DownwardVisitor.java | 6 ++---- .../worldedit/function/visitor/LayerVisitor.java | 5 +---- .../worldedit/function/visitor/RecursiveVisitor.java | 11 ++--------- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index ef1021570..69302e1bc 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -828,7 +828,9 @@ public class EditSession implements Extent { MaskIntersection mask = new MaskIntersection( new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))), - new BoundedHeightMask(origin.getBlockY() - depth + 1, origin.getBlockY()), + new BoundedHeightMask( + Math.max(origin.getBlockY() - depth + 1, 0), + Math.min(getWorld().getMaxY(), origin.getBlockY())), Masks.negate(new ExistingBlockMask(this))); // Want to replace blocks @@ -837,9 +839,9 @@ public class EditSession implements Extent { // Pick how we're going to visit blocks RecursiveVisitor visitor; if (recursive) { - visitor = new RecursiveVisitor(this, mask, replace); + visitor = new RecursiveVisitor(mask, replace); } else { - visitor = new DownwardVisitor(this, mask, replace, origin.getBlockY()); + visitor = new DownwardVisitor(mask, replace, origin.getBlockY()); } // Start at the origin diff --git a/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java b/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java index 0af12c68e..3533eba0e 100644 --- a/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java +++ b/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.visitor; -import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; @@ -40,13 +39,12 @@ public class DownwardVisitor extends RecursiveVisitor { /** * Create a new visitor. * - * @param editSession the edit session * @param mask the mask * @param function the function * @param baseY the base Y */ - public DownwardVisitor(EditSession editSession, Mask mask, RegionFunction function, int baseY) { - super(editSession, mask, function); + public DownwardVisitor(Mask mask, RegionFunction function, int baseY) { + super(mask, function); this.baseY = baseY; diff --git a/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java b/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java index a7500ce74..a51bbc719 100644 --- a/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java +++ b/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java @@ -42,7 +42,6 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class LayerVisitor implements Operation { - private final EditSession editSession; private final FlatRegion flatRegion; private final LayerFunction function; private Mask2D mask = Masks.alwaysTrue2D(); @@ -57,13 +56,11 @@ public class LayerVisitor implements Operation { * @param maxY the maximum Y to begin the search at * @param function the layer function to apply t blocks */ - public LayerVisitor(EditSession editSession, FlatRegion flatRegion, int minY, int maxY, LayerFunction function) { - checkNotNull(editSession); + public LayerVisitor(FlatRegion flatRegion, int minY, int maxY, LayerFunction function) { checkNotNull(flatRegion); checkArgument(minY <= maxY, "minY <= maxY required"); checkNotNull(function); - this.editSession = editSession; this.flatRegion = flatRegion; this.minY = minY; this.maxY = maxY; diff --git a/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java b/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java index 4446c566a..3bb013f6a 100644 --- a/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java +++ b/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java @@ -19,10 +19,9 @@ package com.sk89q.worldedit.function.visitor; -import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.RegionFunction; +import com.sk89q.worldedit.function.mask.Mask; /** * An implementation of an {@link BreadthFirstSearch} that uses a mask to @@ -30,21 +29,15 @@ import com.sk89q.worldedit.function.RegionFunction; */ public class RecursiveVisitor extends BreadthFirstSearch { - private final EditSession editSession; private final Mask mask; - public RecursiveVisitor(EditSession editSession, Mask mask, RegionFunction function) { + public RecursiveVisitor(Mask mask, RegionFunction function) { super(function); - this.editSession = editSession; this.mask = mask; } @Override protected boolean isVisitable(Vector from, Vector to) { - int y = to.getBlockY(); - if (y < 0 || y > editSession.getWorld().getMaxY()) { - return false; - } return mask.test(to); } }