From 1f07d38f2b1f9d6146e0e9ca52588899e123ae49 Mon Sep 17 00:00:00 2001 From: Samuel Date: Wed, 22 May 2024 18:59:13 -0400 Subject: [PATCH] Add BoundingBox::fromPoints (#2145) --- .../java/net/minestom/server/collision/BoundingBox.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/net/minestom/server/collision/BoundingBox.java b/src/main/java/net/minestom/server/collision/BoundingBox.java index b570b26ddb2..0c714422375 100644 --- a/src/main/java/net/minestom/server/collision/BoundingBox.java +++ b/src/main/java/net/minestom/server/collision/BoundingBox.java @@ -252,4 +252,12 @@ public boolean equals(Object o) { default -> null; }; } + + public static @NotNull BoundingBox fromPoints(@NotNull Point a, @NotNull Point b) { + Vec aVec = Vec.fromPoint(a); + Vec min = aVec.min(b); + Vec max = aVec.max(b); + Vec dimensions = max.sub(min); + return new BoundingBox(dimensions.x(), dimensions.y(), dimensions.z(), min); + } }