Allow offsetting the BoundingBox

This commit is contained in:
cosrnic 2024-02-23 23:18:33 +00:00 committed by iam
parent b58db7d5b0
commit 49a4226ebb

View File

@ -25,7 +25,7 @@ public final class BoundingBox implements Shape {
private final Point offset; private final Point offset;
private Point relativeEnd; private Point relativeEnd;
BoundingBox(double width, double height, double depth, Point offset) { public BoundingBox(double width, double height, double depth, Point offset) {
this.width = width; this.width = width;
this.height = height; this.height = height;
this.depth = depth; this.depth = depth;
@ -125,6 +125,16 @@ public final class BoundingBox implements Shape {
return new BoundingBox(this.width - x, this.height - y, this.depth - z); return new BoundingBox(this.width - x, this.height - y, this.depth - z);
} }
/**
* Creates a new {@link BoundingBox} linked to the same {@link Entity} with an offset.
*
* @param offset the offset
* @return a new bounding box with an offset.
*/
public @NotNull BoundingBox offset(Point offset) {
return new BoundingBox(this.width, this.height, this.depth, offset);
}
public double width() { public double width() {
return width; return width;
} }