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