diff --git a/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index ed83ac25..3e3a81f0 100644 --- a/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -397,10 +397,29 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public boolean contains(Vector position) { - int x = position.getBlockX(); - int y = position.getBlockY(); - int z = position.getBlockZ(); - return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ && y >= this.minY && y <= this.maxY; + return contains(position.getBlockX(), position.getBlockY(), position.getBlockZ()); + } + + private int ly = Integer.MIN_VALUE; + private int lz = Integer.MIN_VALUE; + private boolean lr, lry, lrz; + + public boolean contains(int x, int y, int z) { +// return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ && y >= this.minY && y <= this.maxY; + if (z != lz) { + lz = z; + lrz = z >= this.minZ && z <= this.maxZ; + if (y != ly) { + ly = y; + lry = y >= this.minY && y <= this.maxY; + } + lr = lrz && lry; + } else if (y != ly) { + ly = y; + lry = y >= this.minY && y <= this.maxY; + lr = lrz && lry; + } + return lr && (x >= this.minX && x <= this.maxX); } @Override