Class BoundingBox

java.lang.Object
net.minestom.server.collision.BoundingBox

public class BoundingBox
extends java.lang.Object
See https://wiki.vg/Entity_metadata#Mobs_2
  • Constructor Details

    • BoundingBox

      public BoundingBox​(@NotNull Entity entity, float x, float y, float z)
      Creates a BoundingBox linked to an Entity and with a specific size.
      Parameters:
      entity - the linked entity
      x - the width size
      y - the height size
      z - the depth size
  • Method Details

    • intersect

      public boolean intersect​(@NotNull BoundingBox boundingBox)
      Used to know if two BoundingBox intersect with each other.
      Parameters:
      boundingBox - the BoundingBox to check
      Returns:
      true if the two BoundingBox intersect with each other, false otherwise
    • intersect

      public boolean intersect​(@NotNull Entity entity)
      Used to know if this BoundingBox intersects with the bounding box of an entity.
      Parameters:
      entity - the entity to check the bounding box
      Returns:
      true if this bounding box intersects with the entity, false otherwise
    • intersect

      public boolean intersect​(@NotNull BlockPosition blockPosition)
      Used to know if the bounding box intersects at a BlockPosition.
      Parameters:
      blockPosition - the position to check
      Returns:
      true if the bounding box intersects with the position, false otherwise
    • intersect

      public boolean intersect​(float x, float y, float z)
    • intersect

      public boolean intersect​(@NotNull Position position)
    • expand

      @NotNull public BoundingBox expand​(float x, float y, float z)
      Creates a new BoundingBox linked to the same Entity with expanded size.
      Parameters:
      x - the X offset
      y - the Y offset
      z - the Z offset
      Returns:
      a new BoundingBox expanded
    • contract

      @NotNull public BoundingBox contract​(float x, float y, float z)
      Creates a new BoundingBox linked to the same Entity with contracted size.
      Parameters:
      x - the X offset
      y - the Y offset
      z - the Z offset
      Returns:
      a new bounding box contracted
    • getWidth

      public float getWidth()
      Gets the width of the BoundingBox.
      Returns:
      the width
    • getHeight

      public float getHeight()
      Gets the height of the BoundingBox.
      Returns:
      the height
    • getDepth

      public float getDepth()
      Gets the depth of the BoundingBox.
      Returns:
      the depth
    • getMinX

      public float getMinX()
      Gets the min X based on getWidth() and the Entity position.
      Returns:
      the min X
    • getMaxX

      public float getMaxX()
      Gets the max X based on getWidth() and the Entity position.
      Returns:
      the max X
    • getMinY

      public float getMinY()
      Gets the min Y based on the Entity position.
      Returns:
      the min Y
    • getMaxY

      public float getMaxY()
      Gets the max Y based on getHeight() and the Entity position.
      Returns:
      the max Y
    • getMinZ

      public float getMinZ()
      Gets the min Z based on getDepth() and the Entity position.
      Returns:
      the min Z
    • getMaxZ

      public float getMaxZ()
      Gets the max Z based on getDepth() and the Entity position.
      Returns:
      the max Z
    • getBottomFace

      @NotNull public Vector[] getBottomFace()
      Gets an array of Vector representing the points at the bottom of the BoundingBox.
      Returns:
      the points at the bottom of the BoundingBox
    • getTopFace

      @NotNull public Vector[] getTopFace()
      Gets an array of Vector representing the points at the top of the BoundingBox.
      Returns:
      the points at the top of the BoundingBox
    • getLeftFace

      @NotNull public Vector[] getLeftFace()
      Gets an array of Vector representing the points on the left face of the BoundingBox.
      Returns:
      the points on the left face of the BoundingBox
    • getRightFace

      @NotNull public Vector[] getRightFace()
      Gets an array of Vector representing the points on the right face of the BoundingBox.
      Returns:
      the points on the right face of the BoundingBox
    • getFrontFace

      @NotNull public Vector[] getFrontFace()
      Gets an array of Vector representing the points at the front of the BoundingBox.
      Returns:
      the points at the front of the BoundingBox
    • getBackFace

      @NotNull public Vector[] getBackFace()
      Gets an array of Vector representing the points at the back of the BoundingBox.
      Returns:
      the points at the back of the BoundingBox
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object