Skip to content

Commit

Permalink
Fix blocks in chunk expression returning a larger cuboid than expected (
Browse files Browse the repository at this point in the history
  • Loading branch information
TPGamesNL authored May 3, 2021
1 parent 6ff7df1 commit c717b2f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public Collection<OfflinePlayer> getOwners() {
@Override
public Iterator<Block> getBlocks() {
final BlockVector min = region.getMinimumPoint(), max = region.getMaximumPoint();
return new AABB(world, new Vector(min.getBlockX(), min.getBlockY(), min.getBlockZ()), new Vector(max.getBlockX() + 1, max.getBlockY() + 1, max.getBlockZ() + 1)).iterator();
return new AABB(world, new Vector(min.getBlockX(), min.getBlockY(), min.getBlockZ()), new Vector(max.getBlockX(), max.getBlockY(), max.getBlockZ())).iterator();
// final Iterator<BlockVector2D> iter = region.getPoints().iterator();
// if (!iter.hasNext())
// return EmptyIterator.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ public Iterator<Block> getBlocks() {
final Location lower = claim.getLesserBoundaryCorner(), upper = claim.getGreaterBoundaryCorner();
if (lower == null || upper == null || lower.getWorld() == null || upper.getWorld() == null || lower.getWorld() != upper.getWorld())
return EmptyIterator.get();
upper.setY(upper.getWorld().getMaxHeight());
upper.setX(upper.getBlockX() + 1);
upper.setZ(upper.getBlockZ() + 1);
upper.setY(upper.getWorld().getMaxHeight() - 1);
upper.setX(upper.getBlockX());
upper.setZ(upper.getBlockZ());
return new AABB(lower, upper).iterator();
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/ch/njol/skript/util/AABB.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ public AABB(final Block b1, final Block b2) {
throw new IllegalArgumentException("Blocks must be in the same world");
world = b1.getWorld();
lowerBound = new Vector(Math.min(b1.getX(), b2.getX()), Math.min(b1.getY(), b2.getY()), Math.min(b1.getZ(), b2.getZ()));
upperBound = new Vector(Math.max(b1.getX(), b2.getX()) + 1, Math.max(b1.getY(), b2.getY()) + 1, Math.max(b1.getZ(), b2.getZ()) + 1);
upperBound = new Vector(Math.max(b1.getX(), b2.getX()), Math.max(b1.getY(), b2.getY()), Math.max(b1.getZ(), b2.getZ()));
}

@SuppressWarnings("null")
public AABB(final Location center, final double rX, final double rY, final double rZ) {
assert rX >= 0 && rY >= 0 && rZ >= 0 : rX + "," + rY + "," + rY;
world = center.getWorld();
lowerBound = new Vector(center.getX() - rX, Math.max(center.getY() - rY, 0), center.getZ() - rZ);
upperBound = new Vector(center.getX() + rX, Math.min(center.getY() + rY, world.getMaxHeight()), center.getZ() + rZ);
upperBound = new Vector(center.getX() + rX, Math.min(center.getY() + rY, world.getMaxHeight() - 1), center.getZ() + rZ);
}

public AABB(final World w, final Vector v1, final Vector v2) {
Expand All @@ -77,7 +77,7 @@ public AABB(final World w, final Vector v1, final Vector v2) {
public AABB(final Chunk c) {
world = c.getWorld();
lowerBound = c.getBlock(0, 0, 0).getLocation().toVector();
upperBound = lowerBound.clone().add(new Vector(16, world.getMaxHeight(), 16));
upperBound = lowerBound.clone().add(new Vector(15, world.getMaxHeight() - 1, 15));
}

public boolean contains(final Location l) {
Expand Down

0 comments on commit c717b2f

Please sign in to comment.