Package net.minestom.server.coordinate
Interface Point
Represents a 3D point.
-
Method Summary
Modifier and TypeMethodDescription@NotNull Pointadd(double value) @NotNull Pointadd(double x, double y, double z) @NotNull Pointdefault intblockX()Gets the floored value of the X componentdefault intblockY()Gets the floored value of the X componentdefault intblockZ()Gets the floored value of the X componentdefault intchunkX()default intchunkZ()default doubledistance(double x, double y, double z) default doubleGets the distance between this point and another.default doubledistanceSquared(double x, double y, double z) default doubledistanceSquared(@NotNull Point point) Gets the squared distance between this point and another.@NotNull Pointdiv(double value) @NotNull Pointdiv(double x, double y, double z) @NotNull Pointdefault booleanisZero()@NotNull Pointmul(double value) @NotNull Pointmul(double x, double y, double z) @NotNull Pointdefault @NotNull Pointdefault booleansameBlock(int blockX, int blockY, int blockZ) default booleanChecks if two points are in the same block.default booleanChecks if two points are in the same chunk.default booleansamePoint(double x, double y, double z) default booleanChecks it two points have similar (x/y/z).default intsection()@NotNull Pointsub(double value) @NotNull Pointsub(double x, double y, double z) @NotNull Point@NotNull PointwithX(double x) Creates a point with the specified X coordinate.@NotNull PointwithX(@NotNull DoubleUnaryOperator operator) Creates a point with a modified X coordinate based on its value.@NotNull PointwithY(double y) Creates a point with the specified Y coordinate.@NotNull PointwithY(@NotNull DoubleUnaryOperator operator) Creates a point with a modified Y coordinate based on its value.@NotNull PointwithZ(double z) Creates a point with the specified Z coordinate.@NotNull PointwithZ(@NotNull DoubleUnaryOperator operator) Creates a point with a modified Z coordinate based on its value.doublex()Gets the X coordinate.doubley()Gets the Y coordinate.doublez()Gets the Z coordinate.
-
Method Details
-
x
@Contract(pure=true) double x()Gets the X coordinate.- Returns:
- the X coordinate
-
y
@Contract(pure=true) double y()Gets the Y coordinate.- Returns:
- the Y coordinate
-
z
@Contract(pure=true) double z()Gets the Z coordinate.- Returns:
- the Z coordinate
-
blockX
@Contract(pure=true) default int blockX()Gets the floored value of the X component- Returns:
- the block X
-
blockY
@Contract(pure=true) default int blockY()Gets the floored value of the X component- Returns:
- the block X
-
blockZ
@Contract(pure=true) default int blockZ()Gets the floored value of the X component- Returns:
- the block X
-
chunkX
@Contract(pure=true) default int chunkX() -
section
@Contract(pure=true) @Experimental default int section() -
chunkZ
@Contract(pure=true) default int chunkZ() -
withX
Creates a point with a modified X coordinate based on its value.- Parameters:
operator- the operator providing the current X coordinate and returning the new- Returns:
- a new point
-
withX
Creates a point with the specified X coordinate.- Parameters:
x- the new X coordinate- Returns:
- a new point
-
withY
Creates a point with a modified Y coordinate based on its value.- Parameters:
operator- the operator providing the current Y coordinate and returning the new- Returns:
- a new point
-
withY
Creates a point with the specified Y coordinate.- Parameters:
y- the new Y coordinate- Returns:
- a new point
-
withZ
Creates a point with a modified Z coordinate based on its value.- Parameters:
operator- the operator providing the current Z coordinate and returning the new- Returns:
- a new point
-
withZ
Creates a point with the specified Z coordinate.- Parameters:
z- the new Z coordinate- Returns:
- a new point
-
add
-
add
-
add
-
sub
-
sub
-
sub
-
mul
-
mul
-
mul
-
div
-
div
-
div
-
relative
-
distanceSquared
@Contract(pure=true) default double distanceSquared(double x, double y, double z) -
distanceSquared
Gets the squared distance between this point and another.- Parameters:
point- the other point- Returns:
- the squared distance
-
distance
@Contract(pure=true) default double distance(double x, double y, double z) -
distance
Gets the distance between this point and another. The value of this method is not cached and uses a costly square-root function, so do not repeatedly call this method to get the vector's magnitude. NaN will be returned if the inner result of the sqrt() function overflows, which will be caused if the distance is too long.- Parameters:
point- the other point- Returns:
- the distance
-
samePoint
default boolean samePoint(double x, double y, double z) -
samePoint
Checks it two points have similar (x/y/z).- Parameters:
point- the point to compare- Returns:
- true if the two positions are similar
-
isZero
default boolean isZero()- Returns:
- true if the three coordinates are zero
-
sameChunk
Checks if two points are in the same chunk.- Parameters:
point- the point to compare to- Returns:
- true if 'this' is in the same chunk as
point
-
sameBlock
default boolean sameBlock(int blockX, int blockY, int blockZ) -
sameBlock
Checks if two points are in the same block.- Parameters:
point- the point to compare to- Returns:
- true if 'this' is in the same block as
point
-