From 075468854de5df80fbbecf81164e8e97314a8e50 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Wed, 27 Dec 2023 18:56:44 +0100 Subject: [PATCH] Fix AABBBlockGroup --- .../lib/paper/geometry/blocks/AABBBlock.java | 11 ++++++++++- .../paper/geometry/blocks/AABBBlockGroup.java | 18 +++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/geometry/blocks/AABBBlock.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/geometry/blocks/AABBBlock.java index 6077adb..28bad5c 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/geometry/blocks/AABBBlock.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/geometry/blocks/AABBBlock.java @@ -180,7 +180,16 @@ public class AABBBlock implements BlockSet, Cloneable { } - + @Override + public String toString() { + return "{(" + pos1.getBlockX() + + ", " + pos1.getBlockY() + + ", " + pos1.getBlockZ() + + "), (" + pos2.getBlockX() + + ", " + pos2.getBlockY() + + ", " + pos2.getBlockZ() + + ")}"; + } static boolean overlap(AABBBlock aabb1, AABBBlock aabb2) { return aabb1.asBukkitBoundingBox().overlaps(aabb2.asBukkitBoundingBox()); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/geometry/blocks/AABBBlockGroup.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/geometry/blocks/AABBBlockGroup.java index 289400e..3a6acba 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/geometry/blocks/AABBBlockGroup.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/geometry/blocks/AABBBlockGroup.java @@ -35,11 +35,11 @@ public class AABBBlockGroup implements BlockSet { for (int i = 1; i < subAABB.size(); i++) { AABBBlock aabb = subAABB.get(i); pos1.setX(Math.min(pos1.getBlockX(), aabb.pos1.getBlockX())); - pos1.setY(Math.min(pos1.getBlockY(), aabb.pos1.getBlockZ())); - pos1.setZ(Math.min(pos1.getBlockY(), aabb.pos1.getBlockZ())); + pos1.setY(Math.min(pos1.getBlockY(), aabb.pos1.getBlockY())); + pos1.setZ(Math.min(pos1.getBlockZ(), aabb.pos1.getBlockZ())); pos2.setX(Math.max(pos2.getBlockX(), aabb.pos2.getBlockX() - 1)); - pos2.setY(Math.max(pos2.getBlockY(), aabb.pos2.getBlockZ() - 1)); - pos2.setZ(Math.max(pos2.getBlockY(), aabb.pos2.getBlockZ() - 1)); + pos2.setY(Math.max(pos2.getBlockY(), aabb.pos2.getBlockY() - 1)); + pos2.setZ(Math.max(pos2.getBlockZ(), aabb.pos2.getBlockZ() - 1)); } return new AABBBlock(pos1, pos2); } @@ -86,9 +86,13 @@ public class AABBBlockGroup implements BlockSet { return IteratorIterator.ofCollectionOfIterator(subAABB.stream().map(AABBBlock::iterator).toList()); } - - - + @Override + public String toString() { + return "AABBBlockGroup{" + + "subAABB=" + subAABB + + ", englobingAABB=" + englobingAABB + + '}'; + } /* package */ static boolean overlap(AABBBlockGroup aabbGroup, AABBBlock aabb) { if (!aabbGroup.englobingAABB.overlaps(aabb))