Package net.minestom.server.collision
Class BoundingBox
java.lang.Object
net.minestom.server.collision.BoundingBox
- All Implemented Interfaces:
Shape
See https://wiki.vg/Entity_metadata#Mobs_2
-
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, net.minestom.server.coordinate.Point offset) -
Method Summary
Modifier and TypeMethodDescriptionbooleanboundingBoxRayIntersectionCheck(net.minestom.server.coordinate.Vec start, net.minestom.server.coordinate.Vec direction, net.minestom.server.coordinate.Pos position) @NotNull BoundingBoxcontract(double x, double y, double z) Creates a newBoundingBoxwith a contracted size.doubledepth()boolean@NotNull BoundingBoxexpand(double x, double y, double z) Creates a newBoundingBoxwith an expanded size.static @NotNull BoundingBoxfromPoints(@NotNull net.minestom.server.coordinate.Point a, @NotNull net.minestom.server.coordinate.Point b) static @Nullable BoundingBoxfromPose(@NotNull net.minestom.server.entity.EntityPose pose) getBlocks(net.minestom.server.coordinate.Point point) getBlocks(net.minestom.server.coordinate.Point point, BoundingBox.AxisMask axisMask, double axis) doubleheight()booleanintersectBox(@NotNull net.minestom.server.coordinate.Point positionRelative, @NotNull BoundingBox boundingBox) Checks if two bounding boxes intersect.booleanintersectBoxSwept(@NotNull net.minestom.server.coordinate.Point rayStart, @NotNull net.minestom.server.coordinate.Point rayDirection, @NotNull net.minestom.server.coordinate.Point shapePos, @NotNull BoundingBox moving, @NotNull SweepResult finalResult) Checks if a moving bounding box will hit this shape.booleanisOccluded(@NotNull Shape shape, @NotNull net.minestom.server.instance.block.BlockFace face) doublemaxX()doublemaxY()doublemaxZ()doubleminX()doubleminY()doubleminZ()@NotNull net.minestom.server.coordinate.PointRelative End@NotNull net.minestom.server.coordinate.PointRelative StarttoString()doublewidth()@NotNull BoundingBoxwithOffset(net.minestom.server.coordinate.Point offset) Creates a newBoundingBoxwith an offset.Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minestom.server.collision.Shape
intersectEntity, isFaceFull
-
Constructor Details
-
BoundingBox
public BoundingBox(double width, double height, double depth, net.minestom.server.coordinate.Point offset) -
BoundingBox
public BoundingBox(double width, double height, double depth)
-
-
Method Details
-
isOccluded
public boolean isOccluded(@NotNull @NotNull Shape shape, @NotNull @NotNull net.minestom.server.instance.block.BlockFace face) - Specified by:
isOccludedin interfaceShape
-
intersectBox
@Experimental public boolean intersectBox(@NotNull @NotNull net.minestom.server.coordinate.Point positionRelative, @NotNull @NotNull BoundingBox boundingBox) 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
@Experimental public boolean intersectBoxSwept(@NotNull @NotNull net.minestom.server.coordinate.Point rayStart, @NotNull @NotNull net.minestom.server.coordinate.Point rayDirection, @NotNull @NotNull net.minestom.server.coordinate.Point shapePos, @NotNull @NotNull BoundingBox moving, @NotNull @NotNull 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
@Experimental public boolean boundingBoxRayIntersectionCheck(net.minestom.server.coordinate.Vec start, net.minestom.server.coordinate.Vec direction, net.minestom.server.coordinate.Pos position) -
relativeStart
@NotNull public @NotNull net.minestom.server.coordinate.Point relativeStart()Description copied from interface:ShapeRelative Start- Specified by:
relativeStartin interfaceShape- Returns:
- Start of shape
-
relativeEnd
@NotNull public @NotNull net.minestom.server.coordinate.Point relativeEnd()Description copied from interface:ShapeRelative End- Specified by:
relativeEndin interfaceShape- Returns:
- End of shape
-
toString
-
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.
-
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
public BoundingBox.PointIterator getBlocks(net.minestom.server.coordinate.Point point, BoundingBox.AxisMask axisMask, double axis) -
equals
-
fromPose
@Nullable public static @Nullable BoundingBox fromPose(@NotNull @NotNull net.minestom.server.entity.EntityPose pose) -
fromPoints
@NotNull public static @NotNull BoundingBox fromPoints(@NotNull @NotNull net.minestom.server.coordinate.Point a, @NotNull @NotNull net.minestom.server.coordinate.Point b)
-