use of com.fastasyncworldedit.core.extent.filter.block.ExtentFilterBlock in project FastAsyncWorldEdit by IntellectualSites.
the class LimitExtent method apply.
@Override
public <T extends Filter> T apply(Iterable<BlockVector3> positions, T filter) {
int size;
if (positions instanceof Collection) {
size = ((Collection<BlockVector3>) positions).size();
} else if (positions instanceof Region) {
BlockVector3 dim = ((Region) positions).getDimensions();
size = dim.getX() * dim.getY() * dim.getZ();
} else if (positions instanceof Extent) {
BlockVector3 min = ((Extent) positions).getMinimumPoint();
BlockVector3 max = ((Extent) positions).getMinimumPoint();
BlockVector3 dim = max.subtract(min).add(BlockVector3.ONE);
size = dim.getX() * dim.getY() * dim.getZ();
} else {
ExtentFilterBlock block = new ExtentFilterBlock(this);
for (BlockVector3 pos : positions) {
limit.THROW_MAX_CHECKS();
try {
filter.applyBlock(block.init(pos));
} catch (FaweException e) {
if (!limit.MAX_FAILS()) {
throw e;
}
}
}
return filter;
}
limit.THROW_MAX_CHECKS(size);
limit.THROW_MAX_CHANGES(size);
return super.apply(positions, filter);
}
Aggregations