Removed EditSession from RecursiveVisitor.

Dieser Commit ist enthalten in:
sk89q 2014-03-30 13:46:20 -07:00
Ursprung f0d97c5231
Commit 25021b4a30
4 geänderte Dateien mit 10 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -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

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;

Datei anzeigen

@ -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);
}
}