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
ConstructorsConstructorDescriptionBlockPosition(int x, int y, int z) Creates an instance of aBlockPositionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull BlockPositionat(int x, int y, int z) Get aBlockPositionat the given coordinates.doubledistance(int x, int y, int z) Get the distance between this block and the given set of coordinates.doubledistanceSquared(int x, int y, int z) Get the distance squared between this block and the given set of coordinates.final booleanIndicates whether some other object is "equal to" this one.@NotNull BlockPositiongetRelative(@NotNull BlockFace face) Get a newBlockPositionrelative to the givenBlockFace.final inthashCode()Returns a hash code value for this object.@NotNull BlockPositionoffset(int dx, int dy, int dz) Get a newBlockPositionoffset by the given values.longpack()Pack thisBlockPosition's coordinates into a primitive long.static longpack(int x, int y, int z) Packs the given coordinates into a primitive long.final StringtoString()Returns a string representation of this record class.static @NotNull BlockPositionunpack(long packedPos) Unpack aBlockPositionfrom the given packed long.static intunpackX(long packedPos) Unpack an x coordinate from the given packed long.static intunpackY(long packedPos) Unpack a y coordinate from the given packed long.static intunpackZ(long packedPos) Unpack a z coordinate from the given packed long.intx()Returns the value of thexrecord component.inty()Returns the value of theyrecord component.intz()Returns the value of thezrecord component.
-
Constructor Details
-
Method Details
-
offset
Get a newBlockPositionoffset by the given values.- Parameters:
dx- the x offsetdy- the y offsetdz- the z offset- Returns:
- the offset block position
-
getRelative
Get a newBlockPositionrelative 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 aBlockPositionat 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 aBlockPositionfrom 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 thexrecord component.- Returns:
- the value of the
xrecord component
-
y
public int y()Returns the value of theyrecord component.- Returns:
- the value of the
yrecord component
-
z
public int z()Returns the value of thezrecord component.- Returns:
- the value of the
zrecord component
-