mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 20:36:42 +00:00
More work on masks (#607)
* Add a #air mask, the opposite of #existing (#1511) (cherry picked from commit 84fa2bbbc63de7bece01f41c0d5cb7d85cf129e6) * Remove unused methods in Mask.java * Remove `test(Extent, BlockVector3)` from Masks. This was a poorly planned idea. This should save some memory too. Authored-by: Matthew Miller <mnmiller1@me.com>
This commit is contained in:
@ -206,7 +206,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
maxY = Math.min(maxY, Math.max(0, maxY));
|
||||
minY = Math.max(0, minY);
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
if (filter.test(this, MutableBlockVector3.get(x, y, z))) {
|
||||
if (filter.test(MutableBlockVector3.get(x, y, z))) {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
@ -276,22 +276,22 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
int clearanceAbove = maxY - y;
|
||||
int clearanceBelow = y - minY;
|
||||
int clearance = Math.min(clearanceAbove, clearanceBelow);
|
||||
boolean state = !mask.test(this, MutableBlockVector3.get(x, y, z));
|
||||
boolean state = !mask.test(MutableBlockVector3.get(x, y, z));
|
||||
int offset = state ? 0 : 1;
|
||||
for (int d = 0; d <= clearance; d++) {
|
||||
int y1 = y + d;
|
||||
if (mask.test(this, MutableBlockVector3.get(x, y1, z)) != state) return y1 - offset;
|
||||
if (mask.test(MutableBlockVector3.get(x, y1, z)) != state) return y1 - offset;
|
||||
int y2 = y - d;
|
||||
if (mask.test(this, MutableBlockVector3.get(x, y2, z)) != state) return y2 + offset;
|
||||
if (mask.test(MutableBlockVector3.get(x, y2, z)) != state) return y2 + offset;
|
||||
}
|
||||
if (clearanceAbove != clearanceBelow) {
|
||||
if (clearanceAbove < clearanceBelow) {
|
||||
for (int layer = y - clearance - 1; layer >= minY; layer--) {
|
||||
if (mask.test(this, MutableBlockVector3.get(x, layer, z)) != state) return layer + offset;
|
||||
if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) return layer + offset;
|
||||
}
|
||||
} else {
|
||||
for (int layer = y + clearance + 1; layer <= maxY; layer++) {
|
||||
if (mask.test(this, MutableBlockVector3.get(x, layer, z)) != state) return layer - offset;
|
||||
if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) return layer - offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -508,7 +508,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
* @return the number of blocks that matched the mask
|
||||
*/
|
||||
default int countBlocks(Region region, Mask searchMask) {
|
||||
RegionVisitor visitor = new RegionVisitor(region, position -> searchMask.test(this, position));
|
||||
RegionVisitor visitor = new RegionVisitor(region, position -> searchMask.test(position));
|
||||
Operations.completeBlindly(visitor);
|
||||
return visitor.getAffected();
|
||||
}
|
||||
|
@ -79,17 +79,17 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||
return mask.test(getExtent(), location) && super.setBlock(location, block);
|
||||
return mask.test(location) && super.setBlock(location, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return mask.test(getExtent(), position.toBlockVector3()) && super.setBiome(position, biome);
|
||||
return mask.test(position.toBlockVector3()) && super.setBiome(position, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return mask.test(getExtent(), BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome);
|
||||
return mask.test(BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,7 +102,7 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
|
||||
public void applyBlock(FilterBlock block) {
|
||||
//TODO: Find a way to make masking thread safe without having to synchonise the whole extent
|
||||
synchronized (this) {
|
||||
if (!mask.test(getExtent(), block)) {
|
||||
if (!mask.test(block)) {
|
||||
block.setOrdinal(0);
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class ExtentBuffer extends AbstractBufferingExtent {
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||
if (mask.test(getExtent(), location)) {
|
||||
if (mask.test(location)) {
|
||||
buffer.put(location, block.toBaseBlock());
|
||||
return true;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
max = max.getMaximum(location);
|
||||
}
|
||||
|
||||
if (mask.test(getExtent(), location)) {
|
||||
if (mask.test( location)) {
|
||||
buffer.put(location, block.toBaseBlock());
|
||||
return true;
|
||||
} else {
|
||||
@ -131,7 +131,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
max2d = max2d.getMaximum(position);
|
||||
}
|
||||
|
||||
if (biomeMask.test(getExtent(), position)) {
|
||||
if (biomeMask.test(position)) {
|
||||
biomeBuffer.put(position, biome);
|
||||
return true;
|
||||
} else {
|
||||
@ -155,7 +155,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
max2d = max2d.getMaximum(BlockVector2.at(x,z));
|
||||
}
|
||||
|
||||
if (biomeMask.test(getExtent(), BlockVector2.at(x,z))) {
|
||||
if (biomeMask.test(BlockVector2.at(x,z))) {
|
||||
biomeBuffer.put(BlockVector2.at(x,z), biome);
|
||||
return true;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user