Fix vs mask

This commit is contained in:
Jesse Boyd 2016-05-23 05:01:29 +10:00
parent c950b7554d
commit 8a91f09192
2 changed files with 12 additions and 5 deletions

View File

@ -71,7 +71,8 @@ public class Sniper {
} }
// Added // Added
public AsyncWorld tmpWorld; private AsyncWorld tmpWorld;
private MaskedFaweQueue mask;
// Added // Added
public World getWorld() { public World getWorld() {
@ -100,12 +101,14 @@ public class Sniper {
FaweQueue queue; FaweQueue queue;
{ {
Player player = getPlayer(); Player player = getPlayer();
FawePlayer<Player> fp = FawePlayer.wrap(player);
RegionWrapper[] mask = WEManager.IMP.getMask(fp).toArray(new RegionWrapper[0]);
if (tmpWorld == null || !player.getWorld().getName().equals(tmpWorld.getName())) { if (tmpWorld == null || !player.getWorld().getName().equals(tmpWorld.getName())) {
FawePlayer<Player> fp = FawePlayer.wrap(player);
RegionWrapper[] mask = WEManager.IMP.getMask(fp).toArray(new RegionWrapper[0]);
queue = FaweAPI.createQueue(fp.getLocation().world, true); queue = FaweAPI.createQueue(fp.getLocation().world, true);
queue = new MaskedFaweQueue(queue, mask); this.mask = (MaskedFaweQueue) (queue = new MaskedFaweQueue(queue, mask));
tmpWorld = new AsyncWorld(player.getWorld(), queue); tmpWorld = new AsyncWorld(player.getWorld(), queue);
} else if (this.mask != null) {
this.mask.setMask(mask);
} }
if (clickedBlock != null) { if (clickedBlock != null) {
clickedBlock = tmpWorld.getBlockAt(clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ()); clickedBlock = tmpWorld.getBlockAt(clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ());

View File

@ -6,13 +6,17 @@ import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
public class MaskedFaweQueue extends DelegateFaweQueue { public class MaskedFaweQueue extends DelegateFaweQueue {
private final RegionWrapper[] mask; private RegionWrapper[] mask;
public MaskedFaweQueue(FaweQueue parent, RegionWrapper[] mask) { public MaskedFaweQueue(FaweQueue parent, RegionWrapper[] mask) {
super(parent); super(parent);
this.mask = mask; this.mask = mask;
} }
public void setMask(RegionWrapper[] mask) {
this.mask = mask;
}
@Override @Override
public void setTile(int x, int y, int z, CompoundTag tag) { public void setTile(int x, int y, int z, CompoundTag tag) {
if (WEManager.IMP.maskContains(mask, x, z)) { if (WEManager.IMP.maskContains(mask, x, z)) {