Make surface brush not replacing the whole world

This commit is contained in:
Hannes Greule 2020-07-06 02:29:34 +02:00
parent ed6f3e7b4a
commit 6fb10c3879

View File

@ -5,13 +5,14 @@ import com.boydti.fawe.object.mask.SurfaceMask;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.function.mask.MaskUnion;
import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.math.BlockVector3;
import java.util.Arrays;
public class SurfaceSphereBrush implements Brush {
@ -20,7 +21,7 @@ public class SurfaceSphereBrush implements Brush {
SurfaceMask surface = new SurfaceMask(editSession);
final SolidBlockMask solid = new SolidBlockMask(editSession);
final RadiusMask radius = new RadiusMask(0, (int) size);
RecursiveVisitor visitor = new RecursiveVisitor(new MaskUnion(surface, radius).withExtent(editSession), vector -> editSession.setBlock(vector, pattern));
RecursiveVisitor visitor = new RecursiveVisitor(new MaskIntersection(surface, radius).withExtent(editSession), vector -> editSession.setBlock(vector, pattern));
visitor.visit(position);
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
Operations.completeBlindly(visitor);