Search in sources :

Example 1 with SolidBlockMask

use of com.sk89q.worldedit.function.mask.SolidBlockMask in project FastAsyncWorldEdit by IntellectualSites.

the class BrushTool method trace.

private Vector3 trace(EditSession editSession, Player player, int range, boolean useLastBlock) {
    Mask mask = traceMask == null ? new SolidBlockMask(editSession) : traceMask;
    new MaskTraverser(mask).reset(editSession);
    MaskedTargetBlock tb = new MaskedTargetBlock(mask, player, range, 0.2);
    return tb.getMaskedTargetBlock(useLastBlock);
}
Also used : MaskedTargetBlock(com.fastasyncworldedit.core.function.mask.MaskedTargetBlock) SolidBlockMask(com.sk89q.worldedit.function.mask.SolidBlockMask) Mask(com.sk89q.worldedit.function.mask.Mask) SolidBlockMask(com.sk89q.worldedit.function.mask.SolidBlockMask) MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser)

Example 2 with SolidBlockMask

use of com.sk89q.worldedit.function.mask.SolidBlockMask in project FastAsyncWorldEdit by IntellectualSites.

the class LayerBrush method build.

@Override
public void build(EditSession editSession, BlockVector3 position, Pattern ignore, double size) throws MaxChangedBlocksException {
    final AdjacentAnyMask adjacent = new AdjacentAnyMask(new BlockMask(editSession).add(BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR), editSession.getMinY(), editSession.getMaxY());
    final SolidBlockMask solid = new SolidBlockMask(editSession);
    final RadiusMask radius = new RadiusMask(0, (int) size);
    visitor = new RecursiveVisitor(new MaskIntersection(adjacent, solid, radius), funcion -> true, Integer.MAX_VALUE, editSession.getMinY(), editSession.getMaxY());
    visitor.visit(position);
    visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
    Operations.completeBlindly(visitor);
    BlockVectorSet visited = visitor.getVisited();
    visitor = new RecursiveVisitor(new LayerBrushMask(editSession, visitor, layers, adjacent), pos -> {
        int depth = visitor.getDepth();
        Pattern currentPattern = layers[depth];
        return currentPattern.apply(editSession, pos, pos);
    }, layers.length - 1, editSession.getMinY(), editSession.getMaxY());
    for (BlockVector3 pos : visited) {
        visitor.visit(pos);
    }
    Operations.completeBlindly(visitor);
    visitor = null;
}
Also used : BlockVectorSet(com.fastasyncworldedit.core.math.BlockVectorSet) EditSession(com.sk89q.worldedit.EditSession) Arrays(java.util.Arrays) BlockTypes(com.sk89q.worldedit.world.block.BlockTypes) BlockVector3(com.sk89q.worldedit.math.BlockVector3) RecursiveVisitor(com.sk89q.worldedit.function.visitor.RecursiveVisitor) SolidBlockMask(com.sk89q.worldedit.function.mask.SolidBlockMask) MaxChangedBlocksException(com.sk89q.worldedit.MaxChangedBlocksException) AdjacentAnyMask(com.fastasyncworldedit.core.function.mask.AdjacentAnyMask) BlockMask(com.sk89q.worldedit.function.mask.BlockMask) RadiusMask(com.fastasyncworldedit.core.function.mask.RadiusMask) BreadthFirstSearch(com.sk89q.worldedit.function.visitor.BreadthFirstSearch) LayerBrushMask(com.fastasyncworldedit.core.function.mask.LayerBrushMask) MaskIntersection(com.sk89q.worldedit.function.mask.MaskIntersection) Brush(com.sk89q.worldedit.command.tool.brush.Brush) Operations(com.sk89q.worldedit.function.operation.Operations) BlockState(com.sk89q.worldedit.world.block.BlockState) Pattern(com.sk89q.worldedit.function.pattern.Pattern) Pattern(com.sk89q.worldedit.function.pattern.Pattern) MaskIntersection(com.sk89q.worldedit.function.mask.MaskIntersection) SolidBlockMask(com.sk89q.worldedit.function.mask.SolidBlockMask) BlockMask(com.sk89q.worldedit.function.mask.BlockMask) RadiusMask(com.fastasyncworldedit.core.function.mask.RadiusMask) LayerBrushMask(com.fastasyncworldedit.core.function.mask.LayerBrushMask) SolidBlockMask(com.sk89q.worldedit.function.mask.SolidBlockMask) RecursiveVisitor(com.sk89q.worldedit.function.visitor.RecursiveVisitor) BlockVector3(com.sk89q.worldedit.math.BlockVector3) AdjacentAnyMask(com.fastasyncworldedit.core.function.mask.AdjacentAnyMask) BlockVectorSet(com.fastasyncworldedit.core.math.BlockVectorSet)

Example 3 with SolidBlockMask

use of com.sk89q.worldedit.function.mask.SolidBlockMask in project FastAsyncWorldEdit by IntellectualSites.

the class RegionCommands method hollow.

@Command(name = "/hollow", desc = "Hollows out the object contained in this selection", descFooter = "Hollows out the object contained in this selection.\n" + "Optionally fills the hollowed out part with the given block.\n" + "Thickness is measured in manhattan distance.")
@CommandPermissions("worldedit.region.hollow")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int hollow(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "Thickness of the shell to leave", def = "0") int thickness, @Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air") Pattern pattern, @ArgFlag(name = 'm', desc = "Mask to hollow with") Mask mask) throws WorldEditException {
    checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
    // FAWE start > the mask will have been initialised with a WorldWrapper extent (very bad/slow)
    Mask finalMask;
    if (mask != null) {
        new MaskTraverser(mask).setNewExtent(editSession);
        finalMask = mask;
    } else {
        finalMask = new SolidBlockMask(editSession);
    }
    // FAWE end
    int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask);
    actor.print(Caption.of("worldedit.hollow.changed", TextComponent.of(affected)));
    return affected;
}
Also used : SolidBlockMask(com.sk89q.worldedit.function.mask.SolidBlockMask) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) Mask(com.sk89q.worldedit.function.mask.Mask) SolidBlockMask(com.sk89q.worldedit.function.mask.SolidBlockMask) MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) Logging(com.sk89q.worldedit.command.util.Logging) Preload(com.sk89q.worldedit.command.util.annotation.Preload) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

SolidBlockMask (com.sk89q.worldedit.function.mask.SolidBlockMask)3 MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)2 Mask (com.sk89q.worldedit.function.mask.Mask)2 AdjacentAnyMask (com.fastasyncworldedit.core.function.mask.AdjacentAnyMask)1 LayerBrushMask (com.fastasyncworldedit.core.function.mask.LayerBrushMask)1 MaskedTargetBlock (com.fastasyncworldedit.core.function.mask.MaskedTargetBlock)1 RadiusMask (com.fastasyncworldedit.core.function.mask.RadiusMask)1 BlockVectorSet (com.fastasyncworldedit.core.math.BlockVectorSet)1 EditSession (com.sk89q.worldedit.EditSession)1 MaxChangedBlocksException (com.sk89q.worldedit.MaxChangedBlocksException)1 Brush (com.sk89q.worldedit.command.tool.brush.Brush)1 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)1 Logging (com.sk89q.worldedit.command.util.Logging)1 Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)1 Preload (com.sk89q.worldedit.command.util.annotation.Preload)1 BlockMask (com.sk89q.worldedit.function.mask.BlockMask)1 ExistingBlockMask (com.sk89q.worldedit.function.mask.ExistingBlockMask)1 MaskIntersection (com.sk89q.worldedit.function.mask.MaskIntersection)1 Operations (com.sk89q.worldedit.function.operation.Operations)1 Pattern (com.sk89q.worldedit.function.pattern.Pattern)1