Search in sources :

Example 16 with MaskTraverser

use of com.fastasyncworldedit.core.util.MaskTraverser 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)

Example 17 with MaskTraverser

use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.

the class EditSession method setMask.

// FAWE end
// FAWE start - use MaskingExtent & ExtentTraverser
/**
 * Set a mask.
 *
 * @param mask mask or null
 */
public void setMask(Mask mask) {
    if (mask == null) {
        mask = Masks.alwaysTrue();
    } else {
        new MaskTraverser(mask).reset(this);
    }
    ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser<>(getExtent()).find(MaskingExtent.class);
    if (maskingExtent != null && maskingExtent.get() != null) {
        Mask oldMask = maskingExtent.get().getMask();
        if (oldMask instanceof ResettableMask) {
            ((ResettableMask) oldMask).reset();
        }
        maskingExtent.get().setMask(mask);
    } else if (mask != Masks.alwaysTrue()) {
        addProcessor(new MaskingExtent(getExtent(), mask));
    }
}
Also used : BlockTypeMask(com.sk89q.worldedit.function.mask.BlockTypeMask) SingleBlockTypeMask(com.fastasyncworldedit.core.function.mask.SingleBlockTypeMask) RegionMask(com.sk89q.worldedit.function.mask.RegionMask) BlockStateMask(com.sk89q.worldedit.function.mask.BlockStateMask) WallMakeMask(com.fastasyncworldedit.core.function.mask.WallMakeMask) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) BoundedHeightMask(com.sk89q.worldedit.function.mask.BoundedHeightMask) ResettableMask(com.fastasyncworldedit.core.function.mask.ResettableMask) Mask(com.sk89q.worldedit.function.mask.Mask) MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) ResettableMask(com.fastasyncworldedit.core.function.mask.ResettableMask) MaskingExtent(com.sk89q.worldedit.extent.MaskingExtent)

Example 18 with MaskTraverser

use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.

the class EditSession method setSourceMask.

// FAWE end
// FAWE start - use source mast > mask
/**
 * Set a mask.
 *
 * @param mask mask or null
 */
public void setSourceMask(Mask mask) {
    if (mask == null) {
        mask = Masks.alwaysTrue();
    } else {
        new MaskTraverser(mask).reset(this);
    }
    ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser<>(getExtent()).find(SourceMaskExtent.class);
    if (maskingExtent != null && maskingExtent.get() != null) {
        Mask oldMask = maskingExtent.get().getMask();
        if (oldMask instanceof ResettableMask) {
            ((ResettableMask) oldMask).reset();
        }
        maskingExtent.get().setMask(mask);
    } else if (mask != Masks.alwaysTrue()) {
        SourceMaskExtent next = new SourceMaskExtent(getExtent(), mask);
        new ExtentTraverser(this).setNext(next);
    }
}
Also used : ExtentTraverser(com.fastasyncworldedit.core.util.ExtentTraverser) BlockTypeMask(com.sk89q.worldedit.function.mask.BlockTypeMask) SingleBlockTypeMask(com.fastasyncworldedit.core.function.mask.SingleBlockTypeMask) RegionMask(com.sk89q.worldedit.function.mask.RegionMask) BlockStateMask(com.sk89q.worldedit.function.mask.BlockStateMask) WallMakeMask(com.fastasyncworldedit.core.function.mask.WallMakeMask) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) BoundedHeightMask(com.sk89q.worldedit.function.mask.BoundedHeightMask) ResettableMask(com.fastasyncworldedit.core.function.mask.ResettableMask) Mask(com.sk89q.worldedit.function.mask.Mask) SourceMaskExtent(com.fastasyncworldedit.core.extent.SourceMaskExtent) MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) ResettableMask(com.fastasyncworldedit.core.function.mask.ResettableMask)

Example 19 with MaskTraverser

use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.

the class FuzzyRegionSelector method setWorld.

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setWorld(@Nullable World world) {
    EditSession extent = WorldEdit.getInstance().newEditSessionBuilder().world(world).actor(actor).changeSetNull().checkMemory(false).build();
    new ExtentTraverser(this).setNext(extent);
    this.region.setWorld(world);
    this.region.setExtent(extent);
    new MaskTraverser(getMask()).reset(extent);
}
Also used : ExtentTraverser(com.fastasyncworldedit.core.util.ExtentTraverser) MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) EditSession(com.sk89q.worldedit.EditSession)

Example 20 with MaskTraverser

use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.

the class FuzzyRegionSelector method selectPrimary.

@Override
public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
    setWorld(getWorld());
    new MaskTraverser(getMask()).reset(getExtent());
    positions.clear();
    positions.add(position);
    this.region = new FuzzyRegion(getWorld(), getExtent(), getMask());
    this.region.select(position);
    return true;
}
Also used : MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) FuzzyRegion(com.fastasyncworldedit.core.regions.FuzzyRegion)

Aggregations

MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)20 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)12 Command (org.enginehub.piston.annotation.Command)12 Logging (com.sk89q.worldedit.command.util.Logging)10 Preload (com.sk89q.worldedit.command.util.annotation.Preload)9 Mask (com.sk89q.worldedit.function.mask.Mask)9 Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)8 ExistingBlockMask (com.sk89q.worldedit.function.mask.ExistingBlockMask)8 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)6 RegionMask (com.sk89q.worldedit.function.mask.RegionMask)4 SolidBlockMask (com.sk89q.worldedit.function.mask.SolidBlockMask)4 FaweLimit (com.fastasyncworldedit.core.limit.FaweLimit)3 ForwardExtentCopy (com.sk89q.worldedit.function.operation.ForwardExtentCopy)3 Region (com.sk89q.worldedit.regions.Region)3 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)2 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)2 ResettableMask (com.fastasyncworldedit.core.function.mask.ResettableMask)2 SingleBlockTypeMask (com.fastasyncworldedit.core.function.mask.SingleBlockTypeMask)2 WallMakeMask (com.fastasyncworldedit.core.function.mask.WallMakeMask)2 ExtentTraverser (com.fastasyncworldedit.core.util.ExtentTraverser)2