Package net.minestom.server.collision
Record Class BoundingBox
java.lang.Object
java.lang.Record
net.minestom.server.collision.BoundingBox
- All Implemented Interfaces:
Shape
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static class
static class
-
Constructor Summary
ConstructorDescriptionBoundingBox
(double width, double height, double depth) BoundingBox
(double width, double height, double depth, Point offset) BoundingBox
(Vec relativeStart, Vec relativeEnd) Creates an instance of aBoundingBox
record class. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boundingBoxRayIntersectionCheck
(Vec start, Vec direction, Pos position) @NotNull BoundingBox
contract
(double x, double y, double z) Creates a newBoundingBox
with a contracted size.double
depth()
final boolean
Indicates whether some other object is "equal to" this one.@NotNull BoundingBox
expand
(double x, double y, double z) Creates a newBoundingBox
with an expanded size.static @NotNull BoundingBox
fromPoints
(@NotNull Point a, @NotNull Point b) static @Nullable BoundingBox
fromPose
(@NotNull EntityPose pose) getBlocks
(Point point, BoundingBox.AxisMask axisMask, double axis) final int
hashCode()
Returns a hash code value for this object.double
height()
boolean
intersectBox
(@NotNull Point positionRelative, @NotNull BoundingBox boundingBox) Checks if two bounding boxes intersect.boolean
intersectBoxSwept
(@NotNull Point rayStart, @NotNull Point rayDirection, @NotNull Point shapePos, @NotNull BoundingBox moving, @NotNull SweepResult finalResult) Checks if a moving bounding box will hit this shape.boolean
isOccluded
(@NotNull Shape shape, @NotNull BlockFace face) double
maxX()
double
maxY()
double
maxZ()
double
minX()
double
minY()
double
minZ()
Returns the value of therelativeEnd
record component.Returns the value of therelativeStart
record component.final String
toString()
Returns a string representation of this record class.double
width()
@NotNull BoundingBox
withOffset
(Point offset) Creates a newBoundingBox
with an offset.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.minestom.server.collision.Shape
intersectEntity, isFaceFull
-
Constructor Details
-
BoundingBox
-
BoundingBox
public BoundingBox(double width, double height, double depth) -
BoundingBox
Creates an instance of aBoundingBox
record class.- Parameters:
relativeStart
- the value for therelativeStart
record componentrelativeEnd
- the value for therelativeEnd
record component
-
-
Method Details
-
isOccluded
- Specified by:
isOccluded
in interfaceShape
-
intersectBox
public boolean intersectBox(@NotNull @NotNull Point positionRelative, @NotNull @NotNull BoundingBox boundingBox) Description copied from interface:Shape
Checks if two bounding boxes intersect.- Specified by:
intersectBox
in 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(@NotNull @NotNull Point rayStart, @NotNull @NotNull Point rayDirection, @NotNull @NotNull Point shapePos, @NotNull @NotNull BoundingBox moving, @NotNull @NotNull SweepResult finalResult) Description copied from interface:Shape
Checks if a moving bounding box will hit this shape.- Specified by:
intersectBoxSwept
in 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 newBoundingBox
with an expanded size.- Parameters:
x
- the X offsety
- the Y offsetz
- the Z offset- Returns:
- a new
BoundingBox
expanded
-
contract
Creates a newBoundingBox
with a contracted size.- Parameters:
x
- the X offsety
- the Y offsetz
- the Z offset- Returns:
- a new bounding box contracted
-
withOffset
Creates a newBoundingBox
with an offset.- Parameters:
offset
- the offset- Returns:
- a new bounding box with an offset.
-
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
@NotNull public static @NotNull BoundingBox fromPoints(@NotNull @NotNull Point a, @NotNull @NotNull Point b) -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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 therelativeStart
record component.- Specified by:
relativeStart
in interfaceShape
- Returns:
- the value of the
relativeStart
record component
-
relativeEnd
Returns the value of therelativeEnd
record component.- Specified by:
relativeEnd
in interfaceShape
- Returns:
- the value of the
relativeEnd
record component
-