Ensure blocks are not moved below world boundary

This commit is contained in:
Kenzie Togami 2019-07-10 14:10:22 -07:00
parent 2ee71cc72f
commit e87a5559d6
No known key found for this signature in database
GPG Key ID: 5D200B325E157A81

View File

@ -42,6 +42,7 @@ public class GravityBrush implements Brush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
double yMax = fullHeight ? editSession.getWorld().getMaxY() : position.getY() + size;
double yMin = Math.max(position.getY() - size, 0);
LocatedBlockList column = new LocatedBlockList();
Set<BlockVector3> removedBlocks = new LinkedHashSet<>();
for (double x = position.getX() - size; x <= position.getX() + size; x++) {
@ -55,7 +56,7 @@ public class GravityBrush implements Brush {
*/
BlockVector3 lowestAir = null;
for (double y = position.getY() - size; y <= yMax; y++) {
for (double y = yMin; y <= yMax; y++) {
BlockVector3 pt = BlockVector3.at(x, y, z);
BaseBlock block = editSession.getFullBlock(pt);