Package net.minestom.server.collision
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 Summary
Constructors Constructor Description BoundingBox(Entity entity, float x, float y, float z)
Creates aBoundingBox
linked to anEntity
and with a specific size. -
Method Summary
Modifier and Type Method Description BoundingBox
contract(float x, float y, float z)
Creates a newBoundingBox
linked to the sameEntity
with contracted size.BoundingBox
expand(float x, float y, float z)
Creates a newBoundingBox
linked to the sameEntity
with expanded size.Vector[]
getBackFace()
Gets an array ofVector
representing the points at the back of theBoundingBox
.Vector[]
getBottomFace()
Gets an array ofVector
representing the points at the bottom of theBoundingBox
.float
getDepth()
Gets the depth of theBoundingBox
.Vector[]
getFrontFace()
Gets an array ofVector
representing the points at the front of theBoundingBox
.float
getHeight()
Gets the height of theBoundingBox
.Vector[]
getLeftFace()
Gets an array ofVector
representing the points on the left face of theBoundingBox
.float
getMaxX()
Gets the max X based ongetWidth()
and theEntity
position.float
getMaxY()
Gets the max Y based ongetHeight()
and theEntity
position.float
getMaxZ()
Gets the max Z based ongetDepth()
and theEntity
position.float
getMinX()
Gets the min X based ongetWidth()
and theEntity
position.float
getMinY()
Gets the min Y based on theEntity
position.float
getMinZ()
Gets the min Z based ongetDepth()
and theEntity
position.Vector[]
getRightFace()
Gets an array ofVector
representing the points on the right face of theBoundingBox
.Vector[]
getTopFace()
Gets an array ofVector
representing the points at the top of theBoundingBox
.float
getWidth()
Gets the width of theBoundingBox
.boolean
intersect(float x, float y, float z)
boolean
intersect(BoundingBox boundingBox)
Used to know if twoBoundingBox
intersect with each other.boolean
intersect(Entity entity)
Used to know if thisBoundingBox
intersects with the bounding box of an entity.boolean
intersect(BlockPosition blockPosition)
Used to know if the bounding box intersects at aBlockPosition
.boolean
intersect(Position position)
java.lang.String
toString()
-
Constructor Details
-
BoundingBox
Creates aBoundingBox
linked to anEntity
and with a specific size.- Parameters:
entity
- the linked entityx
- the width sizey
- the height sizez
- the depth size
-
-
Method Details
-
intersect
Used to know if twoBoundingBox
intersect with each other.- Parameters:
boundingBox
- theBoundingBox
to check- Returns:
- true if the two
BoundingBox
intersect with each other, false otherwise
-
intersect
Used to know if thisBoundingBox
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
Used to know if the bounding box intersects at aBlockPosition
.- 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
-
expand
Creates a newBoundingBox
linked to the sameEntity
with expanded size.- Parameters:
x
- the X offsety
- the Y offsetz
- the Z offset- Returns:
- a new
BoundingBox
expanded
-
contract
Creates a newBoundingBox
linked to the sameEntity
with contracted size.- Parameters:
x
- the X offsety
- the Y offsetz
- the Z offset- Returns:
- a new bounding box contracted
-
getWidth
public float getWidth()Gets the width of theBoundingBox
.- Returns:
- the width
-
getHeight
public float getHeight()Gets the height of theBoundingBox
.- Returns:
- the height
-
getDepth
public float getDepth()Gets the depth of theBoundingBox
.- Returns:
- the depth
-
getMinX
public float getMinX()Gets the min X based ongetWidth()
and theEntity
position.- Returns:
- the min X
-
getMaxX
public float getMaxX()Gets the max X based ongetWidth()
and theEntity
position.- Returns:
- the max X
-
getMinY
public float getMinY()Gets the min Y based on theEntity
position.- Returns:
- the min Y
-
getMaxY
public float getMaxY()Gets the max Y based ongetHeight()
and theEntity
position.- Returns:
- the max Y
-
getMinZ
public float getMinZ()Gets the min Z based ongetDepth()
and theEntity
position.- Returns:
- the min Z
-
getMaxZ
public float getMaxZ()Gets the max Z based ongetDepth()
and theEntity
position.- Returns:
- the max Z
-
getBottomFace
Gets an array ofVector
representing the points at the bottom of theBoundingBox
.- Returns:
- the points at the bottom of the
BoundingBox
-
getTopFace
Gets an array ofVector
representing the points at the top of theBoundingBox
.- Returns:
- the points at the top of the
BoundingBox
-
getLeftFace
Gets an array ofVector
representing the points on the left face of theBoundingBox
.- Returns:
- the points on the left face of the
BoundingBox
-
getRightFace
Gets an array ofVector
representing the points on the right face of theBoundingBox
.- Returns:
- the points on the right face of the
BoundingBox
-
getFrontFace
Gets an array ofVector
representing the points at the front of theBoundingBox
.- Returns:
- the points at the front of the
BoundingBox
-
getBackFace
Gets an array ofVector
representing the points at the back of theBoundingBox
.- Returns:
- the points at the back of the
BoundingBox
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-