Record Class ModelBoundingBox

java.lang.Object
java.lang.Record
kr.toxicity.model.api.data.blueprint.ModelBoundingBox
Record Components:
minX - the minimum X coordinate
minY - the minimum Y coordinate
minZ - the minimum Z coordinate
maxX - the maximum X coordinate
maxY - the maximum Y coordinate
maxZ - the maximum Z coordinate

public record ModelBoundingBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) extends Record
Represents an axis-aligned bounding box (AABB) for a model part.

This record defines the spatial extent of a model element or group, used for hitboxes and collision detection.

Since:
1.15.2
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final ModelBoundingBox
    A minimal bounding box size (0.1 x 0.1 x 0.1).
  • Constructor Summary

    Constructors
    Constructor
    Description
    ModelBoundingBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
    Creates an instance of a ModelBoundingBox record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a new bounding box with the same dimensions but centered at the origin (0,0,0).
    @NotNull org.joml.Vector3f
    Returns the center point of the bounding box as a vector.
    double
    Returns the Y coordinate of the center of the bounding box.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Inverts the X and Z coordinates of the bounding box.
    double
    Calculates the full diagonal length of the bounding box.
    double
    Calculates the diagonal length in the XZ plane.
    @NotNull org.joml.Vector3d
    max()
    Returns the maximum corner as a vector.
    double
    Returns the value of the maxX record component.
    double
    Returns the value of the maxY record component.
    double
    Returns the value of the maxZ record component.
    @NotNull org.joml.Vector3d
    min()
    Returns the minimum corner as a vector.
    double
    Returns the value of the minX record component.
    double
    Returns the value of the minY record component.
    double
    Returns the value of the minZ record component.
    static @NotNull ModelBoundingBox
    of(double x, double y, double z)
    Creates a bounding box centered at the origin with the given dimensions.
    static @NotNull ModelBoundingBox
    of(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
    Creates a bounding box from explicit min/max coordinates.
    static @NotNull ModelBoundingBox
    of(@NotNull org.joml.Vector3d min, @NotNull org.joml.Vector3d max)
    Creates a bounding box from two corner vectors.
    rotate(@NotNull org.joml.Quaterniond quaterniond)
    Rotates the bounding box around its center.
    times(double scale)
    Scales the bounding box by a uniform factor.
    final String
    Returns a string representation of this record class.
    double
    x()
    Returns the width of the bounding box (X-axis extent).
    double
    y()
    Returns the height of the bounding box (Y-axis extent).
    double
    z()
    Returns the depth of the bounding box (Z-axis extent).

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • MIN

      public static final ModelBoundingBox MIN
      A minimal bounding box size (0.1 x 0.1 x 0.1).
      Since:
      1.15.2
  • Constructor Details

    • ModelBoundingBox

      public ModelBoundingBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
      Creates an instance of a ModelBoundingBox record class.
      Parameters:
      minX - the value for the minX record component
      minY - the value for the minY record component
      minZ - the value for the minZ record component
      maxX - the value for the maxX record component
      maxY - the value for the maxY record component
      maxZ - the value for the maxZ record component
  • Method Details

    • of

      @NotNull public static @NotNull ModelBoundingBox of(@NotNull @NotNull org.joml.Vector3d min, @NotNull @NotNull org.joml.Vector3d max)
      Creates a bounding box from two corner vectors.
      Parameters:
      min - the minimum corner vector
      max - the maximum corner vector
      Returns:
      the bounding box
      Since:
      1.15.2
    • of

      @NotNull public static @NotNull ModelBoundingBox of(double x, double y, double z)
      Creates a bounding box centered at the origin with the given dimensions.
      Parameters:
      x - the width (X-axis)
      y - the height (Y-axis)
      z - the depth (Z-axis)
      Returns:
      the centered bounding box
      Since:
      1.15.2
    • of

      @NotNull public static @NotNull ModelBoundingBox of(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
      Creates a bounding box from explicit min/max coordinates.

      This method automatically ensures that min values are less than or equal to max values.

      Parameters:
      minX - the first X coordinate
      minY - the first Y coordinate
      minZ - the first Z coordinate
      maxX - the second X coordinate
      maxY - the second Y coordinate
      maxZ - the second Z coordinate
      Returns:
      the normalized bounding box
      Since:
      1.15.2
    • x

      public double x()
      Returns the width of the bounding box (X-axis extent).
      Returns:
      the width
      Since:
      1.15.2
    • y

      public double y()
      Returns the height of the bounding box (Y-axis extent).
      Returns:
      the height
      Since:
      1.15.2
    • centerY

      public double centerY()
      Returns the Y coordinate of the center of the bounding box.
      Returns:
      the center Y
      Since:
      1.15.2
    • z

      public double z()
      Returns the depth of the bounding box (Z-axis extent).
      Returns:
      the depth
      Since:
      1.15.2
    • centerPoint

      @NotNull public @NotNull org.joml.Vector3f centerPoint()
      Returns the center point of the bounding box as a vector.
      Returns:
      the center vector
      Since:
      1.15.2
    • times

      @NotNull public @NotNull ModelBoundingBox times(double scale)
      Scales the bounding box by a uniform factor.
      Parameters:
      scale - the scale factor
      Returns:
      the scaled bounding box
      Since:
      1.15.2
    • center

      @NotNull public @NotNull ModelBoundingBox center()
      Returns a new bounding box with the same dimensions but centered at the origin (0,0,0).
      Returns:
      the centered bounding box
      Since:
      1.15.2
    • invert

      @NotNull public @NotNull ModelBoundingBox invert()
      Inverts the X and Z coordinates of the bounding box.
      Returns:
      the inverted bounding box
      Since:
      1.15.2
    • rotate

      @NotNull public @NotNull ModelBoundingBox rotate(@NotNull @NotNull org.joml.Quaterniond quaterniond)
      Rotates the bounding box around its center.
      Parameters:
      quaterniond - the rotation quaternion
      Returns:
      the rotated bounding box
      Since:
      1.15.2
    • min

      @NotNull public @NotNull org.joml.Vector3d min()
      Returns the minimum corner as a vector.
      Returns:
      the min vector
      Since:
      1.15.2
    • max

      @NotNull public @NotNull org.joml.Vector3d max()
      Returns the maximum corner as a vector.
      Returns:
      the max vector
      Since:
      1.15.2
    • lengthZX

      public double lengthZX()
      Calculates the diagonal length in the XZ plane.
      Returns:
      the XZ diagonal length
      Since:
      1.15.2
    • length

      public double length()
      Calculates the full diagonal length of the bounding box.
      Returns:
      the diagonal length
      Since:
      1.15.2
    • 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 '=='.
      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.
    • minX

      public double minX()
      Returns the value of the minX record component.
      Returns:
      the value of the minX record component
    • minY

      public double minY()
      Returns the value of the minY record component.
      Returns:
      the value of the minY record component
    • minZ

      public double minZ()
      Returns the value of the minZ record component.
      Returns:
      the value of the minZ record component
    • maxX

      public double maxX()
      Returns the value of the maxX record component.
      Returns:
      the value of the maxX record component
    • maxY

      public double maxY()
      Returns the value of the maxY record component.
      Returns:
      the value of the maxY record component
    • maxZ

      public double maxZ()
      Returns the value of the maxZ record component.
      Returns:
      the value of the maxZ record component