Record Class BoundingBox
java.lang.Object
java.lang.Record
net.minestom.server.collision.BoundingBox
- All Implemented Interfaces:
Shape
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic classstatic class -
Constructor Summary
ConstructorsConstructorDescriptionBoundingBox(double width, double height, double depth) BoundingBox(double width, double height, double depth, Point offset) BoundingBox(Vec relativeStart, Vec relativeEnd) Creates an instance of aBoundingBoxrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanboundingBoxRayIntersectionCheck(Vec start, Vec direction, Pos position) contract(double x, double y, double z) Creates a newBoundingBoxwith a contracted size.doubledepth()final booleanIndicates whether some other object is "equal to" this one.expand(double x, double y, double z) Creates a newBoundingBoxwith an expanded size.static BoundingBoxfromPoints(Point a, Point b) static @Nullable BoundingBoxfromPose(EntityPose pose) getBlocks(Point point, BoundingBox.AxisMask axisMask, double axis) grow(double x, double y, double z) Creates a newBoundingBoxwith an expanded size from its center in every plane.growSymmetrically(double x, double y, double z) Creates a newBoundingBoxwith an expanded size from its center in every plane.final inthashCode()Returns a hash code value for this object.doubleheight()booleanintersectBox(Point positionRelative, BoundingBox boundingBox) Checks if two bounding boxes intersect.booleanintersectBoxSwept(Point rayStart, Point rayDirection, Point shapePos, BoundingBox moving, SweepResult finalResult) Checks if a moving bounding box will hit this shape.booleanisOccluded(Shape shape, BlockFace face) doublemaxX()doublemaxY()doublemaxZ()doubleminX()doubleminY()doubleminZ()Returns the value of therelativeEndrecord component.Returns the value of therelativeStartrecord component.final StringtoString()Returns a string representation of this record class.doublewidth()withOffset(Point offset) Creates a newBoundingBoxwith an offset.Methods inherited from interface Shape
intersectEntity, isFaceFull
-
Constructor Details
-
BoundingBox
-
BoundingBox
public BoundingBox(double width, double height, double depth) -
BoundingBox
-
-
Method Details
-
isOccluded
- Specified by:
isOccludedin interfaceShape
-
intersectBox
Description copied from interface:ShapeChecks if two bounding boxes intersect.- Specified by:
intersectBoxin interfaceShape- Parameters:
positionRelative- Relative position of bounding box to check withboundingBox- Bounding box to check for intersections with- Returns:
- is an intersection found
-
intersectBoxSwept
public boolean intersectBoxSwept(Point rayStart, Point rayDirection, Point shapePos, BoundingBox moving, SweepResult finalResult) Description copied from interface:ShapeChecks if a moving bounding box will hit this shape.- Specified by:
intersectBoxSweptin interfaceShape- Parameters:
rayStart- Position of the moving shaperayDirection- Movement vectorshapePos- Position of this shapemoving- Bounding Box of moving shapefinalResult- Stores final SweepResult- Returns:
- is an intersection found
-
boundingBoxRayIntersectionCheck
-
expand
Creates a newBoundingBoxwith an expanded size.- Parameters:
x- the X offsety- the Y offsetz- the Z offset- Returns:
- a new
BoundingBoxexpanded
-
contract
Creates a newBoundingBoxwith a contracted size.- Parameters:
x- the X offsety- the Y offsetz- the Z offset- Returns:
- a new bounding box contracted
-
withOffset
Creates a newBoundingBoxwith an offset.- Parameters:
offset- the offset- Returns:
- a new bounding box with an offset.
-
grow
Creates a newBoundingBoxwith an expanded size from its center in every plane.Equivalent to an expansion and an offset where the point is the three-axis offset. Particularly useful when you already use centered and aligned minY=0 position.
- Parameters:
x- the X offset, this will be applied on both sidesy- the Y offset, this will be applied on both sidesz- the Z offset, this will be applied on both sides- Returns:
- a new
BoundingBoxexpanded and centered from the original minY
-
growSymmetrically
Creates a newBoundingBoxwith an expanded size from its center in every plane.Equivalent to a double expansion and an offset where the point is the three-axis offset. Particularly useful when you already use centered and aligned minY=0 position.
- Parameters:
x- the X offset, this will be applied on both sidesy- the Y offset, this will be applied on both sidesz- the Z offset, this will be applied on both sides- Returns:
- a new
BoundingBoxexpanded and centered from the original minY
-
width
public double width() -
height
public double height() -
depth
public double depth() -
minX
public double minX() -
maxX
public double maxX() -
minY
public double minY() -
maxY
public double maxY() -
minZ
public double minZ() -
maxZ
public double maxZ() -
getBlocks
-
getBlocks
-
fromPose
-
fromPoints
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
relativeStart
Returns the value of therelativeStartrecord component.- Specified by:
relativeStartin interfaceShape- Returns:
- the value of the
relativeStartrecord component
-
relativeEnd
Returns the value of therelativeEndrecord component.- Specified by:
relativeEndin interfaceShape- Returns:
- the value of the
relativeEndrecord component
-