diff --git a/src/AxisAlignedBB.php b/src/AxisAlignedBB.php index 12964e5..dedc7b7 100644 --- a/src/AxisAlignedBB.php +++ b/src/AxisAlignedBB.php @@ -133,6 +133,26 @@ public function offsetCopy(float $x, float $y, float $z) : AxisAlignedBB{ return (clone $this)->offset($x, $y, $z); } + /** + * Offsets this AxisAlignedBB in the given direction by the specified distance. + * + * @param int $face one of the Facing::* constants + * + * @return $this + */ + public function offsetTowards(int $face, float $distance) : AxisAlignedBB{ + [$offsetX, $offsetY, $offsetZ] = Facing::OFFSET[$face] ?? throw new \InvalidArgumentException("Invalid Facing $face"); + + return $this->offset($offsetX * $distance, $offsetY * $distance, $offsetZ * $distance); + } + + /** + * Returns an offset clone of this AxisAlignedBB. + */ + public function offsetTowardsCopy(int $face, float $distance) : AxisAlignedBB{ + return (clone $this)->offsetTowards($face, $distance); + } + /** * Insets the bounds of this AxisAlignedBB by the specified X, Y and Z. *