Add mask flag to stack - alternate to //gsmask

This commit is contained in:
Jesse Boyd 2017-03-29 07:07:55 +11:00
parent ecbcc7e64b
commit 7a939e08bb
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 22 additions and 13 deletions

View File

@ -690,6 +690,22 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
}
}
public void addSourceMask(Mask mask) {
checkNotNull(mask);
Mask existing = getSourceMask();
if (existing != null) {
if (existing instanceof MaskIntersection) {
((MaskIntersection) existing).add(mask);
return;
} else {
MaskIntersection intersection = new MaskIntersection(existing);
intersection.add(mask);
mask = intersection;
}
}
setSourceMask(mask);
}
/**
* Set a mask.
*

View File

@ -532,7 +532,7 @@ public class RegionCommands {
@Command(
aliases = { "/stack" },
usage = "[count] [direction]",
flags = "sa",
flags = "sam",
desc = "Repeat the contents of the selection",
help =
"Repeats the contents of the selection.\n" +
@ -549,7 +549,10 @@ public class RegionCommands {
@Optional("1") @Range(min = 1) int count,
@Optional(Direction.AIM) @Direction Vector direction,
@Switch('s') boolean moveSelection,
@Switch('a') boolean ignoreAirBlocks) throws WorldEditException {
@Switch('a') boolean ignoreAirBlocks, @Switch('m') Mask sourceMask) throws WorldEditException {
if (sourceMask != null) {
editSession.addSourceMask(sourceMask);
}
int affected = editSession.stackCuboidRegion(region, direction, count, !ignoreAirBlocks);
if (moveSelection) {

View File

@ -303,17 +303,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
}
}
if (current.sourceMask != null) {
Mask existingMask = editSession.getSourceMask();
if (existingMask == null) {
editSession.setSourceMask(current.sourceMask);
} else if (existingMask instanceof MaskIntersection) {
((MaskIntersection) existingMask).add(current.sourceMask);
} else {
MaskIntersection newMask = new MaskIntersection(existingMask);
newMask.add(current.sourceMask);
editSession.setSourceMask(newMask);
}
editSession.addSourceMask(current.sourceMask);
}
if (current.transform != null) {
editSession.addTransform(current.transform);