-
-
Notifications
You must be signed in to change notification settings - Fork 204
/
SourceMaskExtent.java
57 lines (47 loc) · 1.62 KB
/
SourceMaskExtent.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.fastasyncworldedit.core.extent;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import static com.google.common.base.Preconditions.checkNotNull;
public final class SourceMaskExtent extends TemporalExtent {
private Mask mask;
private final MutableBlockVector3 mutable = new MutableBlockVector3();
public SourceMaskExtent(Extent extent, Mask mask) {
super(extent);
checkNotNull(mask);
this.mask = mask;
}
/**
* Get the mask.
*
* @return the mask
*/
public Mask getMask() {
return mask;
}
/**
* Set a mask.
*
* @param mask a mask
*/
public void setMask(Mask mask) {
checkNotNull(mask);
this.mask = mask;
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
set(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
return mask.test(location) && super.setBlock(location.getX(), location.getY(), location.getZ(), block);
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
set(x, y, z, block);
mutable.mutX(x);
mutable.mutY(y);
mutable.mutZ(z);
return mask.test(mutable) && super.setBlock(x, y, z, block);
}
}