Interface BoundingBox

All Known Subinterfaces:
OBB
All Known Implementing Classes:
AABBBoundingBoxImplMixin, OBBImpl

public interface BoundingBox
A representation of a box for collision and similar detection purposes. Minecraft's AABB and ImmersiveMC's OBBImpl both implement this. Other classes may implement this interface in the future, though only ImmersiveMC should create implementations of this interface.

Although this already applies across the API, it's noted here explicitly that implementations of methods are not part of the API contract, only what is specified in the Javadocs and method signatures are. For example, the implementation of move(BoundingBox, Vec3) is not guaranteed to make the same calls it does now in the future.

  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.phys.AABB
     
     
    static boolean
    contains(BoundingBox box, net.minecraft.world.phys.Vec3 pos)
    Determine if the provided position is inside the provided BoundingBox.
    static net.minecraft.world.phys.Vec3
    Get the center of the provided BoundingBox.
    default boolean
     
    default boolean
     
    move(BoundingBox box, net.minecraft.world.phys.Vec3 movement)
    Creates a new BoundingBox which is the same as the provided one, but moved by the provided movement.
    static List<net.minecraft.world.phys.Vec3>
    Gets the vertices of the provided BoundingBox as an 8-element list.
  • Method Details

    • asOBB

      OBB asOBB() throws RuntimeException
      Returns:
      This BoundingBox as an OBB if it is one.
      Throws:
      RuntimeException - If this BoundingBox is not an OBB.
    • asAABB

      net.minecraft.world.phys.AABB asAABB() throws RuntimeException
      Returns:
      This BoundingBox as an AABB if it is one.
      Throws:
      RuntimeException - If this BoundingBox is not an AABB.
    • isOBB

      default boolean isOBB()
      Returns:
      Whether this BoundingBox is an OBB.
    • isAABB

      default boolean isAABB()
      Returns:
      Whether this BoundingBox is an AABB.
    • contains

      static boolean contains(BoundingBox box, net.minecraft.world.phys.Vec3 pos)
      Determine if the provided position is inside the provided BoundingBox.
      Parameters:
      box - The BoundingBox to check if it contains the provided position.
      pos - The position to check if inside the provided BoundingBox.
      Returns:
      Whether pos is inside the box.
    • getCenter

      static net.minecraft.world.phys.Vec3 getCenter(BoundingBox box)
      Get the center of the provided BoundingBox.
      Parameters:
      box - The BoundingBox to get the center of.
      Returns:
      The center of the provided BoundingBox.
    • move

      static BoundingBox move(BoundingBox box, net.minecraft.world.phys.Vec3 movement)
      Creates a new BoundingBox which is the same as the provided one, but moved by the provided movement.
      Parameters:
      box - The original BoundingBox to move.
      movement - The amount on each axis to move the BoundingBox by.
      Returns:
      A new BoundingBox, which is the original, but translated by the provided movement.
    • vertices

      static List<net.minecraft.world.phys.Vec3> vertices(BoundingBox box)
      Gets the vertices of the provided BoundingBox as an 8-element list.

      The order of the vertices is guaranteed to match the following criteria:

      • The first four elements form a rectangle in a clockwise or counter-clockwise order as would be present on an outline of the BoundingBox.
      • The last four elements form a rectangle in a clockwise or counter-clockwise order as would be present on an outline of the BoundingBox.
      • For each pair of indices for indexing into the list (0, 4), (1, 5), (2, 6), and (3, 7), each pair would have a connecting line segment as would be present on an outline of the BoundingBox.
      In other words, the list of vertices returned by this method is such that a full outline of the BoundingBox is made by drawing line segments with vertices provided by the following indices into the returned list: (0, 1), (1, 2), (2, 3), (3, 0), (4, 5), (5, 6), (6, 7), (7, 4), (0, 4), (1, 5), (2, 6), (3, 7)
      Parameters:
      box - The box to get the vertices of.
      Returns:
      The vertices of the provided box as described above.