Record Class BlockVec
java.lang.Object
java.lang.Record
net.minestom.server.coordinate.BlockVec
- Record Components:
blockX- the block X coordinateblockY- the block Y coordinateblockZ- the block Z coordinate
- All Implemented Interfaces:
Point
Represents a 3D vector with block-aligned coordinates.
Using 12 bytes compared to 24 bytes for Vec.
Ideal for block positions, chunk coordinates, and anything on a grid.
Conversion: When constructed from double values,
coordinates are floored to the nearest integer block position.
Instances are immutable. All operations return new instances
(either BlockVec for integer results or Vec where doubles are used).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA functional interface representing an operation on the components of aBlockVec. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BlockVecstatic final BlockVecstatic final BlockVecstatic final BlockVecstatic final BlockVecFields inherited from interface Point
EPSILON, REGION_SIZE, SECTION_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionBlockVec(double value) Creates a block vector with the given value for all coordinates.BlockVec(double x, double y, double z) Narrows an assumed global coordinate to a block coordinate by flooring the value.BlockVec(int value) Creates a block vector with the given value for all coordinates (x/y/z).BlockVec(int blockX, int blockZ) Creates a BlockVec with the blockX and blockZ, with blockY being zero.BlockVec(int blockX, int blockY, int blockZ) Creates an instance of aBlockVecrecord class.Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionabs()Represents this point with all coordinates as their absolute values.add(double value) Creates a new point by adding the provided value to this point coordinates for all XYZ.add(double x, double y, double z) Creates a new point by adding the provided values to this point coordinates.add(int value) Adds the given integer value to all coordinates of this block vector.add(int blockX, int blockY, int blockZ) Adds the given block XYZ to this block vector.Adds the given block vector to this block vector.Creates a new point by adding another point coordinates to this point coordinates.apply(BlockVec.Operator operator) Applies the given operator to this block vector.Deprecated.intblockX()Returns the value of theblockXrecord component.intblockY()Returns the value of theblockYrecord component.intblockZ()Returns the value of theblockZrecord component.Calculates the cross product of this point with another.Calculates the cross product of this point with another.div(double value) Creates a new point by dividing the provided value to this point coordinates for all XYZ.div(double x, double y, double z) Creates a new point by dividing the provided values to this point coordinates.div(int value) Divides this block vector by the given integer value.div(int blockX, int blockY, int blockZ) Divides this block vector by the given integer values.Divides this block vector by another block vector.Creates a new point by dividing another point coordinates to this point coordinates.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Calculates a linear interpolation between this point with another point (x/y/z).max(double value) Gets a point representing the maximum values between this point and the provided value for all coordinates.max(double x, double y, double z) Gets a point representing the maximum values between this point and the provided coordinates (x/y/z).max(int value) Calculates the maximum between this block vector and the given integer value.max(int blockX, int blockY, int blockZ) Calculates the maximum between this block vector and the given block coordinates (x/y/z).Calculates the maximum between this block vector and another block vector.Gets a point representing the maximum values between this point and the provided one (x/y/z).min(double value) Gets a point representing the minimum values between this point and the provided value for all coordinates.min(double x, double y, double z) Gets a point representing the minimum values between this point and the provided coordinates (x/y/z).min(int value) Calculates the minimum between this block vector and the given integer value.min(int blockX, int blockY, int blockZ) Calculates the minimum between this block vector and the given block coordinates.Calculates the minimum between this block vector and another block vector.Gets a point representing the minimum values between this point and the provided one (x/y/z).mul(double value) Creates a new point by multiplying the provided value to this point coordinates for all XYZ.mul(double x, double y, double z) Creates a new point by multiplying the provided values to this point coordinates.mul(int value) Multiplies this block vector by the given integer value.mul(int blockX, int blockY, int blockZ) Multiplies this block vector by the given integer values.Multiplies this block vector by another block vector.Creates a new point by multiplying another point coordinates to this point coordinates.neg()Represents this point with all coordinates negated.Converts this point to a unit point (a point with length of 1).Creates a new point relative to this point based on the provided block face.booleansamePoint(int blockX, int blockY, int blockZ) Checks if two block positions have the same coordinates (x/y/z).booleanChecks if two block vectors have the same coordinates (x/y/z).sub(double value) Creates a new point by subtracting the provided value to this point coordinates for all XYZ.sub(double x, double y, double z) Creates a new point by subtracting the provided values to this point coordinates.sub(int value) Subtracts the given integer value from all coordinates of this block vector.sub(int blockX, int blockY, int blockZ) Subtracts the given block XYZ from this block vector.Subtracts the given block vector from this block vector.Creates a new point by subtracting another point coordinates to this point coordinates.final StringtoString()Returns a string representation of this record class.withBlockX(int blockX) Sets the block X coordinate to the given value.withBlockX(IntUnaryOperator operator) Applies the given operator to the block X coordinate.withBlockY(int blockY) Sets the block Y coordinate to the given value.withBlockY(IntUnaryOperator operator) Applies the given operator to the block Y coordinate.withBlockZ(int blockZ) Sets the block Z coordinate to the given value.withBlockZ(IntUnaryOperator operator) Applies the given operator to the block Z coordinate.withX(double x) Creates a point with the specified X coordinate.withX(DoubleUnaryOperator operator) Creates a point with a modified X coordinate based on its value.withY(double y) Creates a point with the specified Y coordinate.withY(DoubleUnaryOperator operator) Creates a point with a modified Y coordinate based on its value.withZ(double z) Creates a point with the specified Z coordinate.withZ(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.Methods inherited from interface Point
angle, asPos, asPos, asVec, chunkX, chunkZ, distance, distance, distanceSquared, distanceSquared, dot, isNormalized, isZero, length, lengthSquared, regionX, regionZ, sameBlock, sameBlock, sameChunk, samePoint, samePoint, samePoint, samePoint, section, sectionX, sectionY, sectionZ, similarPoint, similarPoint
-
Field Details
-
ZERO
-
ONE
-
SECTION
-
CHUNK
-
REGION
-
-
Constructor Details
-
BlockVec
public BlockVec(double x, double y, double z) Narrows an assumed global coordinate to a block coordinate by flooring the value.
Developer Note: Minestom should not call this constructor without explicit warnings.- Parameters:
x- the global x coordinatey- the global y coordinatez- the global z coordinate
-
BlockVec
public BlockVec(double value) Creates a block vector with the given value for all coordinates. SeeBlockVec(double, double, double)for side effects.- Parameters:
value- the value
-
BlockVec
Deprecated, for removal: This API element is subject to removal in a future version.UsePoint.asBlockVec()insteadCreates a block vector from a point.- Parameters:
point- the point
-
BlockVec
public BlockVec(int blockX, int blockZ) Creates a BlockVec with the blockX and blockZ, with blockY being zero.- Parameters:
blockX- the blockXblockZ- the blockZ
-
BlockVec
public BlockVec(int value) Creates a block vector with the given value for all coordinates (x/y/z).- Parameters:
value- the value
-
BlockVec
-
-
Method Details
-
x
-
y
-
z
-
apply
Applies the given operator to this block vector.- Parameters:
operator- the operator to apply- Returns:
- the resulting block vector
-
withX
Description copied from interface:PointCreates a point with a modified X coordinate based on its value. -
withX
-
withBlockX
-
withBlockX
Applies the given operator to the block X coordinate.- Parameters:
operator- the operator to apply- Returns:
- the resulting block vector
-
withY
Description copied from interface:PointCreates a point with a modified Y coordinate based on its value. -
withY
-
withBlockY
-
withBlockY
Applies the given operator to the block Y coordinate.- Parameters:
operator- the operator to apply- Returns:
- the resulting block vector
-
withZ
Description copied from interface:PointCreates a point with a modified Z coordinate based on its value. -
withZ
-
withBlockZ
-
withBlockZ
Applies the given operator to the block Z coordinate.- Parameters:
operator- the operator to apply- Returns:
- the resulting block vector
-
add
Description copied from interface:PointCreates a new point by adding the provided values to this point coordinates. -
add
-
add
Description copied from interface:PointCreates a new point by adding another point coordinates to this point coordinates. -
add
-
add
-
add
-
sub
Description copied from interface:PointCreates a new point by subtracting the provided values to this point coordinates. -
sub
@Contract(pure=true, value="_, _, _ -> new") public BlockVec sub(int blockX, int blockY, int blockZ) Subtracts the given block XYZ from this block vector.- Parameters:
blockX- the block X to subtractblockY- the block Y to subtractblockZ- the block Z to subtract- Returns:
- the resulting block vector
-
sub
Description copied from interface:PointCreates a new point by subtracting another point coordinates to this point coordinates. -
sub
-
sub
Description copied from interface:PointCreates a new point by subtracting the provided value to this point coordinates for all XYZ. -
sub
-
mul
Description copied from interface:PointCreates a new point by multiplying the provided values to this point coordinates. -
mul
@Contract(pure=true, value="_, _, _ -> new") public BlockVec mul(int blockX, int blockY, int blockZ) Multiplies this block vector by the given integer values.- Parameters:
blockX- the block x to multiply byblockY- the block y to multiply byblockZ- the block z to multiply by- Returns:
- the resulting block vector
-
mul
Description copied from interface:PointCreates a new point by multiplying another point coordinates to this point coordinates. -
mul
-
mul
Description copied from interface:PointCreates a new point by multiplying the provided value to this point coordinates for all XYZ. -
mul
-
div
Description copied from interface:PointCreates a new point by dividing the provided values to this point coordinates.Warning: division by zero will not error.
-
div
@Contract(pure=true, value="_, _, _ -> new") public BlockVec div(int blockX, int blockY, int blockZ) Divides this block vector by the given integer values.- Parameters:
blockX- the x divisorblockY- the y divisorblockZ- the z divisor- Returns:
- the resulting block vector
- Throws:
ArithmeticException- if any of the divisors is zero
-
div
Description copied from interface:PointCreates a new point by dividing another point coordinates to this point coordinates.Warning: division by zero will not error.
-
div
-
div
Description copied from interface:PointCreates a new point by dividing the provided value to this point coordinates for all XYZ.Warning: division by zero will not error.
-
div
Divides this block vector by the given integer value.- Parameters:
value- the divisor- Returns:
- the resulting block vector
- Throws:
ArithmeticException- if the divisor is zero
-
relative
-
neg
-
abs
-
min
Description copied from interface:PointGets a point representing the minimum values between this point and the provided one (x/y/z). -
min
Description copied from interface:PointGets a point representing the minimum values between this point and the provided coordinates (x/y/z). -
min
Description copied from interface:PointGets a point representing the minimum values between this point and the provided value for all coordinates. -
min
-
min
-
min
-
max
Description copied from interface:PointGets a point representing the maximum values between this point and the provided one (x/y/z). -
max
Description copied from interface:PointGets a point representing the maximum values between this point and the provided coordinates (x/y/z). -
max
Description copied from interface:PointGets a point representing the maximum values between this point and the provided value for all coordinates. -
normalize
-
cross
Description copied from interface:PointCalculates the cross product of this point with another. The cross product is defined as:- x = y1 * z2 - y2 * z1
- y = z1 * x2 - z2 * x1
- z = x1 * y2 - x2 * y1
-
cross
Calculates the cross product of this point with another. The cross product is defined as:- x = y1 * z2 - y2 * z1
- y = z1 * x2 - z2 * x1
- z = x1 * y2 - x2 * y1
- Parameters:
point- the other point- Returns:
- the cross product point
-
lerp
Description copied from interface:PointCalculates a linear interpolation between this point with another point (x/y/z). -
max
-
max
@Contract(pure=true, value="_, _, _ -> new") public BlockVec max(int blockX, int blockY, int blockZ) Calculates the maximum between this block vector and the given block coordinates (x/y/z).- Parameters:
blockX- the block XblockY- the block YblockZ- the block Z- Returns:
- the resulting block vector
-
max
-
samePoint
Checks if two block positions have the same coordinates (x/y/z).- Parameters:
blockX- the block X coordinateblockY- the block Y coordinateblockZ- the block Z coordinate- Returns:
- true if the coordinates are the same
-
samePoint
-
asBlockVec
Deprecated.Does nothing as this is already aBlockVec.Marked as deprecated to warn against redundant usage.
- Specified by:
asBlockVecin interfacePoint- Returns:
- this block vector
-
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 with thecomparemethod from their corresponding wrapper classes. -
blockX
-
blockY
-
blockZ
-
Point.asBlockVec()instead