Added //gmask to set a *GLOBAL* mask that affects nearly ALL operations. Now you can confine //sphere to a region or create //walls that do not replace existing blocks.

This commit is contained in:
sk89q
2011-06-04 12:16:10 -07:00
parent e1da7c41ad
commit aa17d2f0e0
4 changed files with 78 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import com.sk89q.worldedit.regions.*;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.bags.*;
import com.sk89q.worldedit.blocks.*;
import com.sk89q.worldedit.masks.Mask;
import com.sk89q.worldedit.patterns.*;
/**
@ -108,6 +109,11 @@ public class EditSession {
* List of missing blocks;
*/
private Set<Integer> missingBlocks = new HashSet<Integer>();
/**
* Mask to cover operations.
*/
private Mask mask;
/**
* Construct the object with a maximum number of blocks.
@ -162,6 +168,12 @@ public class EditSession {
return false;
}
if (mask != null) {
if (!mask.matches(this, pt)) {
return false;
}
}
int existing = world.getBlockType(pt);
// Clear the container block so that it doesn't drop items
@ -2245,4 +2257,22 @@ public class EditSession {
public int getBlockChangeCount() {
return original.size();
}
/**
* Get the mask.
*
* @return mask, may be null
*/
public Mask getMask() {
return mask;
}
/**
* Set a mask.
*
* @param mask mask or null
*/
public void setMask(Mask mask) {
this.mask = mask;
}
}