Package net.minestom.server.coordinate
Record Class Pos
java.lang.Object
java.lang.Record
net.minestom.server.coordinate.Pos
- All Implemented Interfaces:
Point
public record Pos(double x, double y, double z, float yaw, float pitch)
extends Record
implements Point
Represents a position containing coordinates and a view.
To become a value then primitive type.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull Posadd(double value) @NotNull Posadd(double x, double y, double z) @NotNull Pos@NotNull Posapply(@NotNull Pos.Operator operator) Returns a new position based on this position fields.@NotNull VecasVec()@NotNull VecGets a unit-vector pointing in the direction that this Location is facing.@NotNull Posdiv(double value) @NotNull Posdiv(double x, double y, double z) @NotNull Posfinal booleanIndicates whether some other object is "equal to" this one.static @NotNull Posfinal inthashCode()Returns a hash code value for this object.@NotNull Posmul(double value) @NotNull Posmul(double x, double y, double z) @NotNull Posfloatpitch()Returns the value of thepitchrecord component.@NotNull PosbooleansameView(float yaw, float pitch) booleanChecks if two positions have a similar view (yaw/pitch).@NotNull Possub(double value) @NotNull Possub(double x, double y, double z) @NotNull Posfinal StringtoString()Returns a string representation of this record class.@NotNull PoswithCoord(double x, double y, double z) Changes the 3 coordinates of this position.@NotNull Pos@NotNull PoswithDirection(@NotNull Point point) Sets the yaw and pitch to point in the direction of the point.@NotNull PoswithLookAt(@NotNull Point point) @NotNull PoswithPitch(float pitch) @NotNull PoswithPitch(@NotNull DoubleUnaryOperator operator) @NotNull PoswithView(float yaw, float pitch) @NotNull Pos@NotNull PoswithX(double x) Creates a point with the specified X coordinate.@NotNull PoswithX(@NotNull DoubleUnaryOperator operator) Creates a point with a modified X coordinate based on its value.@NotNull PoswithY(double y) Creates a point with the specified Y coordinate.@NotNull PoswithY(@NotNull DoubleUnaryOperator operator) Creates a point with a modified Y coordinate based on its value.@NotNull PoswithYaw(float yaw) @NotNull PoswithYaw(@NotNull DoubleUnaryOperator operator) @NotNull PoswithZ(double z) Creates a point with the specified Z coordinate.@NotNull PoswithZ(@NotNull DoubleUnaryOperator operator) Creates a point with a modified Z coordinate based on its value.doublex()Returns the value of thexrecord component.doubley()Returns the value of theyrecord component.floatyaw()Returns the value of theyawrecord component.doublez()Returns the value of thezrecord component.
-
Field Details
-
ZERO
-
-
Constructor Details
-
Pos
public Pos(double x, double y, double z, float yaw, float pitch) Creates an instance of aPosrecord class.- Parameters:
x- the value for thexrecord componenty- the value for theyrecord componentz- the value for thezrecord componentyaw- the value for theyawrecord componentpitch- the value for thepitchrecord component
-
Pos
public Pos(double x, double y, double z) -
Pos
-
Pos
-
-
Method Details
-
fromPoint
- Parameters:
point- the point to convert- Returns:
- the converted position
-
withCoord
Changes the 3 coordinates of this position.- Parameters:
x- the X coordinatey- the Y coordinatez- the Z coordinate- Returns:
- a new position
-
withCoord
-
withView
-
withView
-
withDirection
Sets the yaw and pitch to point in the direction of the point. -
withYaw
-
withYaw
@Contract(pure=true) @NotNull public @NotNull Pos withYaw(@NotNull @NotNull DoubleUnaryOperator operator) -
withPitch
-
withLookAt
-
withPitch
@Contract(pure=true) @NotNull public @NotNull Pos withPitch(@NotNull @NotNull DoubleUnaryOperator operator) -
sameView
Checks if two positions have a similar view (yaw/pitch).- Parameters:
position- the position to compare- Returns:
- true if the two positions have the same view
-
sameView
public boolean sameView(float yaw, float pitch) -
direction
Gets a unit-vector pointing in the direction that this Location is facing. -
apply
Returns a new position based on this position fields.- Parameters:
operator- the operator deconstructing this object and providing a new position- Returns:
- the new position
-
withX
@Contract(pure=true) @NotNull public @NotNull Pos withX(@NotNull @NotNull DoubleUnaryOperator operator) Description copied from interface:PointCreates a point with a modified X coordinate based on its value. -
withX
Description copied from interface:PointCreates a point with the specified X coordinate. -
withY
@Contract(pure=true) @NotNull public @NotNull Pos withY(@NotNull @NotNull DoubleUnaryOperator operator) Description copied from interface:PointCreates a point with a modified Y coordinate based on its value. -
withY
Description copied from interface:PointCreates a point with the specified Y coordinate. -
withZ
@Contract(pure=true) @NotNull public @NotNull Pos withZ(@NotNull @NotNull DoubleUnaryOperator operator) Description copied from interface:PointCreates a point with a modified Z coordinate based on its value. -
withZ
Description copied from interface:PointCreates a point with the specified Z coordinate. -
add
-
add
-
add
-
sub
-
sub
-
sub
-
mul
-
mul
-
mul
-
div
-
div
-
div
-
relative
-
asVec
-
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 double x()Returns the value of thexrecord component. -
y
public double y()Returns the value of theyrecord component. -
z
public double z()Returns the value of thezrecord component. -
yaw
public float yaw()Returns the value of theyawrecord component.- Returns:
- the value of the
yawrecord component
-
pitch
public float pitch()Returns the value of thepitchrecord component.- Returns:
- the value of the
pitchrecord component
-