Record Class BoundingBox

java.lang.Object
java.lang.Record
net.minestom.server.collision.BoundingBox
All Implemented Interfaces:
Shape

public record BoundingBox(Vec relativeStart, Vec relativeEnd) extends Record implements Shape
  • Constructor Details

    • BoundingBox

      public BoundingBox(double width, double height, double depth, Point offset)
    • BoundingBox

      public BoundingBox(double width, double height, double depth)
    • BoundingBox

      public BoundingBox(Vec relativeStart, Vec relativeEnd)
      Creates an instance of a BoundingBox record class.
      Parameters:
      relativeStart - the value for the relativeStart record component
      relativeEnd - the value for the relativeEnd record component
  • Method Details

    • isOccluded

      public boolean isOccluded(@NotNull @NotNull Shape shape, @NotNull @NotNull BlockFace face)
      Specified by:
      isOccluded in interface Shape
    • intersectBox

      public boolean intersectBox(@NotNull @NotNull Point positionRelative, @NotNull @NotNull BoundingBox boundingBox)
      Description copied from interface: Shape
      Checks if two bounding boxes intersect.
      Specified by:
      intersectBox in interface Shape
      Parameters:
      positionRelative - Relative position of bounding box to check with
      boundingBox - Bounding box to check for intersections with
      Returns:
      is an intersection found
    • intersectBoxSwept

      public boolean intersectBoxSwept(@NotNull @NotNull Point rayStart, @NotNull @NotNull Point rayDirection, @NotNull @NotNull Point shapePos, @NotNull @NotNull BoundingBox moving, @NotNull @NotNull SweepResult finalResult)
      Description copied from interface: Shape
      Checks if a moving bounding box will hit this shape.
      Specified by:
      intersectBoxSwept in interface Shape
      Parameters:
      rayStart - Position of the moving shape
      rayDirection - Movement vector
      shapePos - Position of this shape
      moving - Bounding Box of moving shape
      finalResult - Stores final SweepResult
      Returns:
      is an intersection found
    • boundingBoxRayIntersectionCheck

      public boolean boundingBoxRayIntersectionCheck(Vec start, Vec direction, Pos position)
    • expand

      @NotNull public @NotNull BoundingBox expand(double x, double y, double z)
      Creates a new BoundingBox with an expanded size.
      Parameters:
      x - the X offset
      y - the Y offset
      z - the Z offset
      Returns:
      a new BoundingBox expanded
    • contract

      @NotNull public @NotNull BoundingBox contract(double x, double y, double z)
      Creates a new BoundingBox with a contracted size.
      Parameters:
      x - the X offset
      y - the Y offset
      z - the Z offset
      Returns:
      a new bounding box contracted
    • withOffset

      @NotNull public @NotNull BoundingBox withOffset(Point offset)
      Creates a new BoundingBox with an offset.
      Parameters:
      offset - the offset
      Returns:
      a new bounding box with an offset.
    • width

      public double width()
    • height

      public double height()
    • depth

      public double depth()
    • minX

      public double minX()
    • maxX

      public double maxX()
    • minY

      public double minY()
    • maxY

      public double maxY()
    • minZ

      public double minZ()
    • maxZ

      public double maxZ()
    • getBlocks

      public BoundingBox.PointIterator getBlocks(Point point)
    • getBlocks

      public BoundingBox.PointIterator getBlocks(Point point, BoundingBox.AxisMask axisMask, double axis)
    • fromPose

      @Nullable public static @Nullable BoundingBox fromPose(@NotNull @NotNull EntityPose pose)
    • fromPoints

      @NotNull public static @NotNull BoundingBox fromPoints(@NotNull @NotNull Point a, @NotNull @NotNull Point b)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • relativeStart

      public Vec relativeStart()
      Returns the value of the relativeStart record component.
      Specified by:
      relativeStart in interface Shape
      Returns:
      the value of the relativeStart record component
    • relativeEnd

      public Vec relativeEnd()
      Returns the value of the relativeEnd record component.
      Specified by:
      relativeEnd in interface Shape
      Returns:
      the value of the relativeEnd record component