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 TypeMethodDescriptionnet.minecraft.world.phys.AABBasAABB()asOBB()static booleancontains(BoundingBox box, net.minecraft.world.phys.Vec3 pos) Determine if the provided position is inside the provided BoundingBox.static net.minecraft.world.phys.Vec3getCenter(BoundingBox box) Get the center of the provided BoundingBox.default booleanisAABB()default booleanisOBB()static BoundingBoxmove(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> vertices(BoundingBox box) Gets the vertices of the provided BoundingBox as an 8-element list.
-
Method Details
-
asOBB
- Returns:
- This BoundingBox as an OBB if it is one.
- Throws:
RuntimeException- If this BoundingBox is not an OBB.
-
asAABB
- 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
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
Get the center of the provided BoundingBox.- Parameters:
box- The BoundingBox to get the center of.- Returns:
- The center of the provided BoundingBox.
-
move
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
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.
- Parameters:
box- The box to get the vertices of.- Returns:
- The vertices of the provided box as described above.
-