Fix fixliquid.

This commit is contained in:
Jesse Boyd 2016-08-01 16:41:21 +10:00
parent ffc23f4020
commit 7c06899111

View File

@ -72,7 +72,6 @@ import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.FuzzyBlockMask; import com.sk89q.worldedit.function.mask.FuzzyBlockMask;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.MaskIntersection; import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.mask.MaskUnion;
import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.mask.NoiseFilter2D; import com.sk89q.worldedit.function.mask.NoiseFilter2D;
import com.sk89q.worldedit.function.mask.RegionMask; import com.sk89q.worldedit.function.mask.RegionMask;
@ -1685,19 +1684,31 @@ public class EditSession implements Extent {
public int fixLiquid(final Vector origin, final double radius, final int moving, final int stationary) throws MaxChangedBlocksException { public int fixLiquid(final Vector origin, final double radius, final int moving, final int stationary) throws MaxChangedBlocksException {
checkNotNull(origin); checkNotNull(origin);
checkArgument(radius >= 0, "radius >= 0 required"); checkArgument(radius >= 0, "radius >= 0 required");
// Our origins can only be liquids // Our origins can only be liquids
BlockMask liquidMask = new BlockMask( BlockMask liquidMask = new BlockMask(
this, this,
FaweCache.getBlock(moving, 0), new BaseBlock(moving, -1),
FaweCache.getBlock(stationary, 0)); new BaseBlock(stationary, -1)
) {
@Override
public boolean test(Vector vector) {
BaseBlock block = getBlock(vector);
return block.getId() == moving || block.getId() == stationary;
}
};
// But we will also visit air blocks BlockMask blockMask = new BlockMask(
MaskIntersection blockMask = this,
new MaskUnion(liquidMask, new BaseBlock(moving, -1),
new BlockMask( new BaseBlock(stationary, -1),
this, new BaseBlock(0, 0)
new BaseBlock(BlockID.AIR))); ) {
@Override
public boolean test(Vector vector) {
BaseBlock block = getBlock(vector);
return block.getId() == 0 || block.getId() == moving || block.getId() == stationary;
}
};
// There are boundaries that the routine needs to stay in // There are boundaries that the routine needs to stay in
MaskIntersection mask = new MaskIntersection( MaskIntersection mask = new MaskIntersection(