Fixes PlotSquared#1685

This commit is contained in:
Jesse Boyd 2017-08-11 12:20:14 +10:00
parent ea94c0c11a
commit f85a9f08d0
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -1,39 +1,61 @@
package com.boydti.fawe.object; package com.boydti.fawe.object;
import com.boydti.fawe.object.extent.FaweRegionExtent;
import com.boydti.fawe.object.extent.HeightBoundExtent;
import com.boydti.fawe.object.extent.MultiRegionExtent;
import com.boydti.fawe.object.extent.SingleRegionExtent;
import com.boydti.fawe.util.DelegateFaweQueue; import com.boydti.fawe.util.DelegateFaweQueue;
import com.boydti.fawe.util.WEManager;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
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 RegionWrapper[] mask; private FaweRegionExtent region;
public MaskedFaweQueue(FaweQueue parent, RegionWrapper[] mask) { public MaskedFaweQueue(FaweQueue parent, RegionWrapper[] mask) {
super(parent); super(parent);
this.mask = mask; setMask(mask);
} }
public void setMask(RegionWrapper[] mask) { public void setMask(RegionWrapper[] mask) {
this.mask = mask; switch (mask.length) {
case 0:
region = new HeightBoundExtent(this, FaweLimit.MAX.copy(), Integer.MIN_VALUE, Integer.MAX_VALUE);
break;
case 1:
region = new SingleRegionExtent(this, FaweLimit.MAX.copy(), mask[0]);
break;
default:
region = new MultiRegionExtent(this, FaweLimit.MAX.copy(), mask);
break;
}
if (mask.length == 1) {
region = new SingleRegionExtent(this, FaweLimit.MAX.copy(), mask[0]);
} else {
region = new MultiRegionExtent(this, FaweLimit.MAX.copy(), 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 (region.contains(x, y, z)) {
super.setTile(x, y, z, tag); super.setTile(x, y, z, tag);
} }
} }
@Override @Override
public void setEntity(int x, int y, int z, CompoundTag tag) { public void setEntity(int x, int y, int z, CompoundTag tag) {
if (WEManager.IMP.maskContains(mask, x, z)) { if (region.contains(x, y, z)) {
super.setEntity(x, y, z, tag); super.setEntity(x, y, z, tag);
} }
} }
@Override @Override
public boolean setBlock(int x, int y, int z, int id, int data) { public boolean setBlock(int x, int y, int z, int id, int data) {
if (WEManager.IMP.maskContains(mask, x, z)) { if (region.contains(x, y, z)) {
return super.setBlock(x, y, z, id, data); return super.setBlock(x, y, z, id, data);
} }
return false; return false;
@ -41,15 +63,47 @@ public class MaskedFaweQueue extends DelegateFaweQueue {
@Override @Override
public boolean setBlock(int x, int y, int z, int id, int data, CompoundTag nbt) { public boolean setBlock(int x, int y, int z, int id, int data, CompoundTag nbt) {
if (WEManager.IMP.maskContains(mask, x, z)) { if (region.contains(x, y, z)) {
return super.setBlock(x, y, z, id, data, nbt); return super.setBlock(x, y, z, id, data, nbt);
} }
return false; return false;
} }
@Override
public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
if (region.contains(position.getBlockX(), position.getBlockZ())) {
return super.setBlock(position, block);
}
return false;
}
@Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
if (region.contains(x, y, z)) {
return super.setBlock(x, y, z, block);
}
return false;
}
@Override
public boolean setBlock(int x, int y, int z, int id) {
if (region.contains(x, y, z)) {
return super.setBlock(x, y, z, id);
}
return false;
}
@Override
public boolean setBiome(Vector2D position, BaseBiome biome) {
if (region.contains(position.getBlockX(), position.getBlockZ())) {
return super.setBiome(position, biome);
}
return false;
}
@Override @Override
public boolean setBiome(int x, int z, BaseBiome biome) { public boolean setBiome(int x, int z, BaseBiome biome) {
if (WEManager.IMP.maskContains(mask, x, z)) { if (region.contains(x, z)) {
return super.setBiome(x, z, biome); return super.setBiome(x, z, biome);
} }
return false; return false;