Package wtf.choco.veinminer.util
Record Class BlockPosition
java.lang.Object
java.lang.Record
wtf.choco.veinminer.util.BlockPosition
- Record Components:
x
- the x coordinatey
- the y coordinatez
- the z coordinate
Represents a set of x, y, and z coordinates in a world.
-
Constructor Summary
ConstructorDescriptionBlockPosition
(int x, int y, int z) Creates an instance of aBlockPosition
record class. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull BlockPosition
at
(int x, int y, int z) Get aBlockPosition
at the given coordinates.double
distance
(int x, int y, int z) Get the distance between this block and the given set of coordinates.double
distanceSquared
(int x, int y, int z) Get the distance squared between this block and the given set of coordinates.final boolean
Indicates whether some other object is "equal to" this one.@NotNull BlockPosition
getRelative
(@NotNull BlockFace face) Get a newBlockPosition
relative to the givenBlockFace
.final int
hashCode()
Returns a hash code value for this object.@NotNull BlockPosition
offset
(int dx, int dy, int dz) Get a newBlockPosition
offset by the given values.long
pack()
Pack thisBlockPosition
's coordinates into a primitive long.static long
pack
(int x, int y, int z) Packs the given coordinates into a primitive long.final String
toString()
Returns a string representation of this record class.static @NotNull BlockPosition
unpack
(long packedPos) Unpack aBlockPosition
from the given packed long.static int
unpackX
(long packedPos) Unpack an x coordinate from the given packed long.static int
unpackY
(long packedPos) Unpack a y coordinate from the given packed long.static int
unpackZ
(long packedPos) Unpack a z coordinate from the given packed long.int
x()
Returns the value of thex
record component.int
y()
Returns the value of they
record component.int
z()
Returns the value of thez
record component.
-
Constructor Details
-
Method Details
-
offset
Get a newBlockPosition
offset by the given values.- Parameters:
dx
- the x offsetdy
- the y offsetdz
- the z offset- Returns:
- the offset block position
-
getRelative
Get a newBlockPosition
relative to the givenBlockFace
.- Parameters:
face
- the direction in which to get the relative position- Returns:
- the relative position
-
distanceSquared
public double distanceSquared(int x, int y, int z) Get the distance squared between this block and the given set of coordinates.- Parameters:
x
- the x coordinatey
- the y coordinatez
- the z coordinate- Returns:
- the distance squared in blocks
- See Also:
-
distance
public double distance(int x, int y, int z) Get the distance between this block and the given set of coordinates.- Parameters:
x
- the x coordinatey
- the y coordinatez
- the z coordinate- Returns:
- the distance in blocks
- See Also:
-
pack
public long pack()Pack thisBlockPosition
's coordinates into a primitive long.- Returns:
- the packed position
-
at
Get aBlockPosition
at the given coordinates.Convenience method. Equivalent to invoking the constructor with the same arguments
- Parameters:
x
- the x coordinatey
- the y coordinatez
- the z coordinate- Returns:
- the created
BlockPosition
-
unpack
Unpack aBlockPosition
from the given packed long.- Parameters:
packedPos
- the packed long position- Returns:
- the resulting BlockPosition
-
pack
public static long pack(int x, int y, int z) Packs the given coordinates into a primitive long.- Parameters:
x
- the x coordinatey
- the y coordinatez
- the z coordinate- Returns:
- the packed position
-
unpackX
public static int unpackX(long packedPos) Unpack an x coordinate from the given packed long.- Parameters:
packedPos
- the position as a long- Returns:
- the unpacked x coordinate
-
unpackY
public static int unpackY(long packedPos) Unpack a y coordinate from the given packed long.- Parameters:
packedPos
- the position as a long- Returns:
- the unpacked y coordinate
-
unpackZ
public static int unpackZ(long packedPos) Unpack a z coordinate from the given packed long.- Parameters:
packedPos
- the position as a long- Returns:
- the unpacked z coordinate
-
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 with '=='. -
x
public int x()Returns the value of thex
record component.- Returns:
- the value of the
x
record component
-
y
public int y()Returns the value of they
record component.- Returns:
- the value of the
y
record component
-
z
public int z()Returns the value of thez
record component.- Returns:
- the value of the
z
record component
-