类 BoundingBox
- 所有已实现的接口:
Cloneable,ConfigurationSerializable
这基本上表示一个矩形框(由最小和最大角指定),可用于描述对象(如实体、方块或矩形区域)在 3D 空间中的位置和范围。其边缘和面与笛卡尔坐标系的轴平行。
边界框可能是退化的(一个或多个边的长度为 0)。
由于边界框是可变的,如果以后修改它们,长期存储可能会很危险。如果您想保留边界框,调用 clone() 获取副本可能是明智的。
-
构造器概要
构造器构造器说明创建一个新的(退化)边界框,所有角坐标为0。BoundingBox(double x1, double y1, double z1, double x2, double y2, double z2) 从给定角坐标创建新的边界框。 -
方法概要
修饰符和类型方法说明clone()创建此边界框的副本。booleancontains(double x, double y, double z) 检查此边界框是否包含指定位置。booleancontains(@NotNull BoundingBox other) 检查此边界框是否完全包含给定边界框。boolean检查此边界框是否包含指定位置。boolean检查此边界框是否完全包含给定角定义的边界框。copy(@NotNull BoundingBox other) 复制另一个边界框。static @NotNull BoundingBoxdeserialize(@NotNull Map<String, Object> args) booleanexpand(double expansion) 在所有方向上按给定值均匀扩展此边界框。expand(double x, double y, double z) 在正负方向上按给定值均匀扩展此边界框。expand(double dirX, double dirY, double dirZ, double expansion) 在指定方向上扩展此边界框。expand(double negativeX, double negativeY, double negativeZ, double positiveX, double positiveY, double positiveZ) 在相应方向上按给定值扩展此边界框。在给定方块面指定的方向上扩展此边界框。在正负方向上按给定值均匀扩展此边界框。在指定方向上扩展此边界框。expandDirectional(double dirX, double dirY, double dirZ) 在指定方向上扩展此边界框。expandDirectional(@NotNull Vector direction) 在指定方向上扩展此边界框。获取边界框的中心。double获取边界框中心的 x 坐标。double获取边界框中心的 y 坐标。double获取边界框中心的 z 坐标。double获取边界框的高度。getMax()获取最大角作为向量。doublegetMaxX()获取最大 x 值。doublegetMaxY()获取最大 y 值。doublegetMaxZ()获取最大 z 值。getMin()获取最小角作为向量。doublegetMinX()获取最小 x 值。doublegetMinY()获取最小 y 值。doublegetMinZ()获取最小 z 值。double获取边界框的体积。double获取边界框在 x 方向的宽度。double获取边界框在 z 方向的宽度。inthashCode()intersection(@NotNull BoundingBox other) 调整此边界框大小以表示此边界框与给定边界的交集。static @NotNull BoundingBox创建包含给定方块的新 1x1x1 大小边界框。static @NotNull BoundingBox使用给定方块的坐标作为角创建新的边界框。static @NotNull BoundingBox使用给定中心和范围创建新的边界框。static @NotNull BoundingBox使用给定位置的坐标作为角创建新的边界框。static @NotNull BoundingBox使用给定中心和范围创建新的边界框。static @NotNull BoundingBox使用给定向量的坐标作为角创建新的边界框。booleanoverlaps(@NotNull BoundingBox other) 检查此边界框是否与给定边界框重叠。boolean检查此边界框是否与给定角定义的边界框重叠。计算此边界框与指定线段的交点。resize(double x1, double y1, double z1, double x2, double y2, double z2) 调整此边界框的大小。创建此类的 Map 表示。shift(double shiftX, double shiftY, double shiftZ) 按给定量移动此边界框。Shifts this bounding box by the given amounts.Shifts this bounding box by the given amounts.toString()union(double posX, double posY, double posZ) 扩展此边界框以包含(或边界)指定位置。Expands this bounding box to contain (or border) the specified position.union(@NotNull BoundingBox other) 扩展此边界框以包含此边界框和给定边界框。Expands this bounding box to contain (or border) the specified position.
-
构造器详细资料
-
BoundingBox
public BoundingBox()创建一个新的(退化)边界框,所有角坐标为0。 -
BoundingBox
public BoundingBox(double x1, double y1, double z1, double x2, double y2, double z2) 从给定角坐标创建新的边界框。原文: Creates a new bounding box from the given corner coordinates.
- 参数:
x1- 第一个角的 x 值y1- 第一个角的 y 值z1- 第一个角的 z 值x2- 第二个角的 x 值y2- 第二个角的 y 值z2- 第二个角的 z 值
-
-
方法详细资料
-
of
@NotNull public static @NotNull BoundingBox of(@NotNull @NotNull Vector corner1, @NotNull @NotNull Vector corner2) 使用给定向量的坐标作为角创建新的边界框。原文: Creates a new bounding box using the coordinates of the given vectors as corners.
- 参数:
corner1- 第一个角corner2- 第二个角- 返回:
- 边界框
-
of
@NotNull public static @NotNull BoundingBox of(@NotNull @NotNull Location corner1, @NotNull @NotNull Location corner2) 使用给定位置的坐标作为角创建新的边界框。原文: Creates a new bounding box using the coordinates of the given locations as corners.
- 参数:
corner1- 第一个角corner2- 第二个角- 返回:
- 边界框
-
of
@NotNull public static @NotNull BoundingBox of(@NotNull @NotNull Block corner1, @NotNull @NotNull Block corner2) 使用给定方块的坐标作为角创建新的边界框。边界框的大小将完全包含两个方块。
原文: Creates a new bounding box using the coordinates of the given blocks as corners.
The bounding box will be sized to fully contain both blocks.
- 参数:
corner1- 第一个角方块corner2- 第二个角方块- 返回:
- 边界框
-
of
创建包含给定方块的新 1x1x1 大小边界框。原文: Creates a new 1x1x1 sized bounding box containing the given block.
- 参数:
block- 方块- 返回:
- 边界框
-
of
@NotNull public static @NotNull BoundingBox of(@NotNull @NotNull Vector center, double x, double y, double z) 使用给定中心和范围创建新的边界框。原文: Creates a new bounding box using the given center and extents.
- 参数:
center- 中心x- 边界框沿 x 轴大小的 1/2y- 边界框沿 y 轴大小的 1/2z- 边界框沿 z 轴大小的 1/2- 返回:
- 边界框
-
of
@NotNull public static @NotNull BoundingBox of(@NotNull @NotNull Location center, double x, double y, double z) 使用给定中心和范围创建新的边界框。原文: Creates a new bounding box using the given center and extents.
- 参数:
center- 中心x- 边界框沿 x 轴大小的 1/2y- 边界框沿 y 轴大小的 1/2z- 边界框沿 z 轴大小的 1/2- 返回:
- 边界框
-
resize
@NotNull public @NotNull BoundingBox resize(double x1, double y1, double z1, double x2, double y2, double z2) 调整此边界框的大小。原文: Resizes this bounding box.
- 参数:
x1- 第一个角的 x 值y1- 第一个角的 y 值z1- 第一个角的 z 值x2- 第二个角的 x 值y2- 第二个角的 y 值z2- 第二个角的 z 值- 返回:
- 此边界框(已调整大小)
-
getMinX
public double getMinX()获取最小 x 值。原文: Gets the minimum x value.
- 返回:
- 最小 x 值
-
getMinY
public double getMinY()获取最小 y 值。原文: Gets the minimum y value.
- 返回:
- 最小 y 值
-
getMinZ
public double getMinZ()获取最小 z 值。原文: Gets the minimum z value.
- 返回:
- 最小 z 值
-
getMin
获取最小角作为向量。原文: Gets the minimum corner as vector.
- 返回:
- 最小角作为向量
-
getMaxX
public double getMaxX()获取最大 x 值。原文: Gets the maximum x value.
- 返回:
- 最大 x 值
-
getMaxY
public double getMaxY()获取最大 y 值。原文: Gets the maximum y value.
- 返回:
- 最大 y 值
-
getMaxZ
public double getMaxZ()获取最大 z 值。原文: Gets the maximum z value.
- 返回:
- 最大 z 值
-
getMax
获取最大角作为向量。原文: Gets the maximum corner as vector.
- 返回:
- 最大角向量
-
getWidthX
public double getWidthX()获取边界框在 x 方向的宽度。原文: Gets the width of the bounding box in the x direction.
- 返回:
- x 方向的宽度
-
getWidthZ
public double getWidthZ()获取边界框在 z 方向的宽度。原文: Gets the width of the bounding box in the z direction.
- 返回:
- z 方向的宽度
-
getHeight
public double getHeight()获取边界框的高度。原文: Gets the height of the bounding box.
- 返回:
- 高度
-
getVolume
public double getVolume()获取边界框的体积。原文: Gets the volume of the bounding box.
- 返回:
- 体积
-
getCenterX
public double getCenterX()获取边界框中心的 x 坐标。原文: Gets the x coordinate of the center of the bounding box.
- 返回:
- 中心的 x 坐标
-
getCenterY
public double getCenterY()获取边界框中心的 y 坐标。原文: Gets the y coordinate of the center of the bounding box.
- 返回:
- 中心的 y 坐标
-
getCenterZ
public double getCenterZ()获取边界框中心的 z 坐标。原文: Gets the z coordinate of the center of the bounding box.
- 返回:
- 中心的 z 坐标
-
getCenter
获取边界框的中心。原文: Gets the center of the bounding box.
- 返回:
- 中心
-
copy
复制另一个边界框。原文: Copies another bounding box.
- 参数:
other- 另一个边界框- 返回:
- 此边界框
-
expand
@NotNull public @NotNull BoundingBox expand(double negativeX, double negativeY, double negativeZ, double positiveX, double positiveY, double positiveZ) 在相应方向上按给定值扩展此边界框。负值将在相应方向上收缩边界框。收缩将限制在受影响相对面以均匀速度收缩时会相遇的点。
原文: Expands this bounding box by the given values in the corresponding directions.
Negative values will shrink the bounding box in the corresponding direction. Shrinking will be limited to the point where the affected opposite faces would meet if the they shrank at uniform speeds.
- 参数:
negativeX- 负 x 方向的扩展量negativeY- 负 y 方向的扩展量negativeZ- 负 z 方向的扩展量positiveX- 正 x 方向的扩展量positiveY- 正 y 方向的扩展量positiveZ- 正 z 方向的扩展量- 返回:
- 此边界框(已扩展)
-
expand
在正负方向上按给定值均匀扩展此边界框。负值将收缩边界框。收缩将限制在边界框的当前大小。
原文: Expands this bounding box uniformly by the given values in both positive and negative directions.
Negative values will shrink the bounding box. Shrinking will be limited to the bounding box's current size.
- 参数:
x- 正负 x 方向上的扩展量y- 正负 y 方向上的扩展量z- 正负 z 方向上的扩展量- 返回:
- 此边界框(已扩展)
-
expand
在正负方向上按给定值均匀扩展此边界框。负值将收缩边界框。收缩将限制在边界框的当前大小。
原文: Expands this bounding box uniformly by the given values in both positive and negative directions.
Negative values will shrink the bounding box. Shrinking will be limited to the bounding box's current size.
- 参数:
expansion- 扩展值- 返回:
- 此边界框(已扩展)
-
expand
在所有方向上按给定值均匀扩展此边界框。负值将收缩边界框。收缩将限制在边界框的当前大小。
原文: Expands this bounding box uniformly by the given value in all directions.
A negative value will shrink the bounding box. Shrinking will be limited to the bounding box's current size.
- 参数:
expansion- 扩展量- 返回:
- 此边界框(已扩展)
-
expand
@NotNull public @NotNull BoundingBox expand(double dirX, double dirY, double dirZ, double expansion) 在指定方向上扩展此边界框。方向的大小将缩放扩展。负的扩展值将在此方向上收缩边界框。收缩将限制在边界框的当前大小。
原文: Expands this bounding box in the specified direction.
The magnitude of the direction will scale the expansion. A negative expansion value will shrink the bounding box in this direction. Shrinking will be limited to the bounding box's current size.
- 参数:
dirX- x 方向分量dirY- y 方向分量dirZ- z 方向分量expansion- 扩展量- 返回:
- 此边界框(已扩展)
-
expand
在指定方向上扩展此边界框。方向的大小将缩放扩展。负的扩展值将在此方向上收缩边界框。收缩将限制在边界框的当前大小。
原文: Expands this bounding box in the specified direction.
The magnitude of the direction will scale the expansion. A negative expansion value will shrink the bounding box in this direction. Shrinking will be limited to the bounding box's current size.
- 参数:
direction- 方向expansion- 扩展量- 返回:
- 此边界框(已扩展)
-
expand
@NotNull public @NotNull BoundingBox expand(@NotNull @NotNull BlockFace blockFace, double expansion) 在给定方块面指定的方向上扩展此边界框。负的扩展值将在此方向上收缩边界框。收缩将限制在边界框的当前大小。
原文: Expands this bounding box in the direction specified by the given block face.
A negative expansion value will shrink the bounding box in this direction. Shrinking will be limited to the bounding box's current size.
- 参数:
blockFace- 方块面expansion- 扩展量- 返回:
- 此边界框(已扩展)
-
expandDirectional
在指定方向上扩展此边界框。负值将在负方向上扩展边界框,正值将在正方向上扩展。方向分量的大小决定相应的扩展量。
原文: Expands this bounding box in the specified direction.
Negative values will expand the bounding box in the negative direction, positive values will expand it in the positive direction. The magnitudes of the direction components determine the corresponding amounts of expansion.
- 参数:
dirX- x 方向分量dirY- y 方向分量dirZ- z 方向分量- 返回:
- 此边界框(已扩展)
-
expandDirectional
在指定方向上扩展此边界框。负值将在负方向上扩展边界框,正值将在正方向上扩展。方向向量的大小决定扩展量。
原文: Expands this bounding box in the specified direction.
Negative values will expand the bounding box in the negative direction, positive values will expand it in the positive direction. The magnitude of the direction vector determines the amount of expansion.
- 参数:
direction- 扩展的方向和大小- 返回:
- 此边界框(已扩展)
-
union
扩展此边界框以包含(或边界)指定位置。原文: Expands this bounding box to contain (or border) the specified position.
- 参数:
posX- x 位置值posY- y 位置值posZ- z 位置值- 返回:
- 此边界框(已扩展)
- 另请参阅:
-
union
Expands this bounding box to contain (or border) the specified position.- 参数:
position- the position- 返回:
- this bounding box (now expanded)
- 另请参阅:
-
union
Expands this bounding box to contain (or border) the specified position.- 参数:
position- the position- 返回:
- this bounding box (now expanded)
- 另请参阅:
-
union
扩展此边界框以包含此边界框和给定边界框。原文: Expands this bounding box to contain both this and the given bounding box.
- 参数:
other- 另一个边界框- 返回:
- 此边界框(已扩展)
-
intersection
调整此边界框大小以表示此边界框与给定边界的交集。原文: Resizes this bounding box to represent the intersection of this and the given bounding box.
- 参数:
other- 另一个边界框- 返回:
- 此边界框(现在表示交集)
- 抛出:
IllegalArgumentException- 如果边界框不重叠
-
shift
按给定量移动此边界框。原文: Shifts this bounding box by the given amounts.
- 参数:
shiftX- x 方向的移动量shiftY- y 方向的移动量shiftZ- z 方向的移动量- 返回:
- 此边界框(已移动)
-
shift
Shifts this bounding box by the given amounts.- 参数:
shift- the shift- 返回:
- this bounding box (now shifted)
-
shift
Shifts this bounding box by the given amounts.- 参数:
shift- the shift- 返回:
- this bounding box (now shifted)
-
overlaps
检查此边界框是否与给定边界框重叠。仅在边界处相交的边界框不被视为重叠。
原文: Checks if this bounding box overlaps with the given bounding box.
Bounding boxes that are only intersecting at the borders are not considered overlapping.
- 参数:
other- 另一个边界框- 返回:
true如果重叠
-
overlaps
检查此边界框是否与给定角定义的边界框重叠。仅在边界处相交的边界框不被视为重叠。
原文: Checks if this bounding box overlaps with the bounding box that is defined by the given corners.
Bounding boxes that are only intersecting at the borders are not considered overlapping.
- 参数:
min- 第一个角max- 第二个角- 返回:
true如果重叠
-
contains
public boolean contains(double x, double y, double z) 检查此边界框是否包含指定位置。恰好在边界框最小边界上的位置被视为在边界框内,而恰好在最大边界上的位置被视为在外。这允许边界框直接相邻放置,位置始终只位于其中一个边界框内。
原文: Checks if this bounding box contains the specified position.
Positions exactly on the minimum borders of the bounding box are considered to be inside the bounding box, while positions exactly on the maximum borders are considered to be outside. This allows bounding boxes to reside directly next to each other with positions always only residing in exactly one of them.
- 参数:
x- 位置的 x 坐标y- 位置的 y 坐标z- 位置的 z 坐标- 返回:
true如果边界框包含该位置
-
contains
检查此边界框是否包含指定位置。恰好在边界框最小边界上的位置被视为在边界框内,而恰好在最大边界上的位置被视为在外。这允许边界框直接相邻放置,位置始终只位于其中一个边界框内。
原文: Checks if this bounding box contains the specified position.
Positions exactly on the minimum borders of the bounding box are considered to be inside the bounding box, while positions exactly on the maximum borders are considered to be outside. This allows bounding boxes to reside directly next to each other with positions always only residing in exactly one of them.
- 参数:
position- 位置- 返回:
true如果边界框包含该位置
-
contains
检查此边界框是否完全包含给定边界框。原文: Checks if this bounding box fully contains the given bounding box.
- 参数:
other- 另一个边界框- 返回:
true如果边界框包含给定边界框
-
contains
检查此边界框是否完全包含给定角定义的边界框。原文: Checks if this bounding box fully contains the bounding box that is defined by the given corners.
- 参数:
min- 第一个角max- 第二个角- 返回:
true如果边界框包含指定的边界框
-
rayTrace
@Nullable public @Nullable RayTraceResult rayTrace(@NotNull @NotNull Vector start, @NotNull @NotNull Vector direction, double maxDistance) 计算此边界框与指定线段的交点。在边和角处的交点会产生一个受影响的方块面作为命中结果,但不确定是哪一个。
原文: Calculates the intersection of this bounding box with the specified line segment.
Intersections at edges and corners yield one of the affected block faces as hit result, but it is not defined which of them.
- 参数:
start- 起始位置direction- 光线方向maxDistance- 最大距离- 返回:
- 光线追踪命中结果,如果没有命中则返回
null
-
hashCode
public int hashCode() -
equals
-
toString
-
clone
创建此边界框的副本。原文: Creates a copy of this bounding box.
-
serialize
从接口复制的说明:ConfigurationSerializable创建此类的 Map 表示。此类必须提供一个方法来恢复此类,具体定义见
ConfigurationSerializable接口的 javadoc。原文:Creates a Map representation of this class.
This class must provide a method to restore this class, as defined in the
ConfigurationSerializableinterface javadocs.- 指定者:
serialize在接口中ConfigurationSerializable- 返回:
- 包含此类当前状态的 Map
-
deserialize
-