Class: BoundingBoxUtils
Bounding Box Utils is a utility class that provides a number of useful functions for the creation and utility of @minecraft-server.BoundingBox objects
Constructors
new BoundingBoxUtils()
private
new BoundingBoxUtils():BoundingBoxUtils
Returns
Methods
createValid()
static
createValid(min
,max
):BoundingBox
Parameters
Parameter | Type | Description |
---|---|---|
min | Vector3 | A corner world location |
max | Vector3 | A corner world location diametrically opposite |
Returns
Remarks
Create a validated instance of a @minecraft-server.BoundingBox where the min and max components are guaranteed to be (min <= max)
This function can't be called in read-only mode.
dilate()
static
dilate(box
,size
):BoundingBox
Parameters
Parameter | Type |
---|---|
box | BoundingBox |
size | Vector3 |
Returns
Return a new @minecraft-server.BoundingBox object representing the changes
Remarks
Expand a @minecraft-server.BoundingBox by a given amount along each axis. Sizes can be negative to perform contraction. Note: corners can be inverted if the contraction size is greater than the span, but the min/max relationship will remain correct
This function can't be called in read-only mode.
equals()
static
equals(box
,other
):boolean
Parameters
Parameter | Type |
---|---|
box | BoundingBox |
other | BoundingBox |
Returns
boolean
Remarks
Check if two @minecraft-server.BoundingBox objects are identical
This function can't be called in read-only mode.
expand()
static
expand(box
,other
):BoundingBox
Parameters
Parameter | Type |
---|---|
box | BoundingBox |
other | BoundingBox |
Returns
A new @minecraft-server.BoundingBox instance representing the smallest possible bounding box which can encompass both
Remarks
Expand the initial box object bounds to include the 2nd box argument. The resultant @minecraft-server.BoundingBox object will be a BoundingBox which exactly encompasses the two boxes.
This function can't be called in read-only mode.
getCenter()
static
getCenter(box
):Vector3
Parameters
Parameter | Type |
---|---|
box | BoundingBox |
Returns
Note that @minecraft-server.BoundingBox objects represent whole blocks, so the center of boxes which have odd numbered bounds are not mathematically centered... i.e. a BoundingBox( 0,0,0 -> 3,3,3 ) would have a center of (1,1,1) (not (1.5, 1.5, 1.5) as expected)
Remarks
Calculate the center block of a given @minecraft-server.BoundingBox object.
This function can't be called in read-only mode.
getIntersection()
static
getIntersection(box
,other
):BoundingBox
Parameters
Parameter | Type |
---|---|
box | BoundingBox |
other | BoundingBox |
Returns
Remarks
Calculate the BoundingBox which represents the union area of two intersecting BoundingBoxes
This function can't be called in read-only mode.
getSpan()
static
getSpan(box
):Vector3
Parameters
Parameter | Type |
---|---|
box | BoundingBox |
Returns
Remarks
Get the Span of each of the BoundingBox Axis components
This function can't be called in read-only mode.
intersects()
static
intersects(box
,other
):boolean
Parameters
Parameter | Type |
---|---|
box | BoundingBox |
other | BoundingBox |
Returns
boolean
Remarks
Check to see if two BoundingBox objects intersect
This function can't be called in read-only mode.
isInside()
static
isInside(box
,pos
):boolean
Parameters
Parameter | Type |
---|---|
box | BoundingBox |
pos | Vector3 |
Returns
boolean
Remarks
Check to see if a given coordinate is inside a BoundingBox
This function can't be called in read-only mode.
isValid()
static
isValid(box
):boolean
Parameters
Parameter | Type |
---|---|
box | BoundingBox |
Returns
boolean
Remarks
Check to see if a BoundingBox is valid (i.e. (min <= max))
This function can't be called in read-only mode.
translate()
static
translate(box
,delta
):BoundingBox
Parameters
Parameter | Type |
---|---|
box | BoundingBox |
delta | Vector3 |
Returns
Return a new BoundingBox object which represents the change
Remarks
Move a BoundingBox by a given amount
This function can't be called in read-only mode.