3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-27 03:12:37 +01:00

Make FlatRegionVisitor take FlatRegions only.

Dieser Commit ist enthalten in:
sk89q 2014-03-29 18:34:34 -07:00
Ursprung 69f3862c11
Commit c804aeb03e
3 geänderte Dateien mit 18 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -1162,7 +1162,7 @@ public class EditSession {
RegionOffset offset = new RegionOffset(new Vector(0, 1, 0), replace); RegionOffset offset = new RegionOffset(new Vector(0, 1, 0), replace);
GroundSearch search = new MaskingGroundSearch(this, new ExistingBlockMask()); GroundSearch search = new MaskingGroundSearch(this, new ExistingBlockMask());
GroundFunction groundFunction = new GroundFunction(search, lowerY, upperY, offset); GroundFunction groundFunction = new GroundFunction(search, lowerY, upperY, offset);
FlatRegionVisitor operation = new FlatRegionVisitor(region, groundFunction); FlatRegionVisitor operation = new FlatRegionVisitor(Regions.asFlatRegion(region), groundFunction);
OperationHelper.completeLegacy(operation); OperationHelper.completeLegacy(operation);
return operation.getAffected(); return operation.getAffected();
@ -1966,7 +1966,7 @@ public class EditSession {
FlatRegionMaskingFilter filter = new FlatRegionMaskingFilter(this, mask, groundFunction); FlatRegionMaskingFilter filter = new FlatRegionMaskingFilter(this, mask, groundFunction);
// Generate those patches! // Generate those patches!
FlatRegionVisitor operation = new FlatRegionVisitor(region, filter); FlatRegionVisitor operation = new FlatRegionVisitor(Regions.asFlatRegion(region), filter);
OperationHelper.completeLegacy(operation); OperationHelper.completeLegacy(operation);
return operation.getAffected(); return operation.getAffected();

Datei anzeigen

@ -561,7 +561,7 @@ public class RegionCommands {
FlatRegionMaskingFilter filter = new FlatRegionMaskingFilter(editSession, mask, groundFunction); FlatRegionMaskingFilter filter = new FlatRegionMaskingFilter(editSession, mask, groundFunction);
// Execute // Execute
FlatRegionVisitor operation = new FlatRegionVisitor(region, filter); FlatRegionVisitor operation = new FlatRegionVisitor(Regions.asFlatRegion(region), filter);
OperationHelper.complete(operation); OperationHelper.complete(operation);
player.print(operation.getAffected() + " trees created."); player.print(operation.getAffected() + " trees created.");
@ -591,7 +591,7 @@ public class RegionCommands {
FlatRegionMaskingFilter filter = new FlatRegionMaskingFilter(editSession, mask, groundFunction); FlatRegionMaskingFilter filter = new FlatRegionMaskingFilter(editSession, mask, groundFunction);
// Execute // Execute
FlatRegionVisitor operation = new FlatRegionVisitor(region, filter); FlatRegionVisitor operation = new FlatRegionVisitor(Regions.asFlatRegion(region), filter);
OperationHelper.complete(operation); OperationHelper.complete(operation);
player.print(operation.getAffected() + " flora created."); player.print(operation.getAffected() + " flora created.");

Datei anzeigen

@ -23,12 +23,12 @@ import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.FlatRegionFunction; import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.FlatRegion; import com.sk89q.worldedit.regions.FlatRegion;
import com.sk89q.worldedit.regions.Region;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Utility class to apply region functions to {@link com.sk89q.worldedit.regions.Region}. * Applies region functions to columns in a {@link FlatRegion}.
*/ */
public class FlatRegionVisitor implements Operation { public class FlatRegionVisitor implements Operation {
@ -36,14 +36,18 @@ public class FlatRegionVisitor implements Operation {
private final FlatRegionFunction function; private final FlatRegionFunction function;
private int affected = 0; private int affected = 0;
public FlatRegionVisitor(Region region, FlatRegionFunction function) { /**
this.function = function; * Create a new visitor.
*
* @param flatRegion a flat region
* @param function a function to apply to columns
*/
public FlatRegionVisitor(FlatRegion flatRegion, FlatRegionFunction function) {
checkNotNull(flatRegion);
checkNotNull(function);
if (region instanceof FlatRegion) { this.flatRegion = flatRegion;
flatRegion = (FlatRegion) region; this.function = function;
} else {
flatRegion = CuboidRegion.makeCuboid(region);
}
} }
/** /**