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
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NotNull Pos
add
(double value) @NotNull Pos
add
(double x, double y, double z) @NotNull Pos
@NotNull Pos
apply
(@NotNull Pos.Operator operator) Returns a new position based on this position fields.@NotNull Vec
asVec()
@NotNull Vec
Gets a unit-vector pointing in the direction that this Location is facing.@NotNull Pos
div
(double value) @NotNull Pos
div
(double x, double y, double z) @NotNull Pos
final boolean
Indicates whether some other object is "equal to" this one.static @NotNull Pos
final int
hashCode()
Returns a hash code value for this object.@NotNull Pos
mul
(double value) @NotNull Pos
mul
(double x, double y, double z) @NotNull Pos
float
pitch()
Returns the value of thepitch
record component.@NotNull Pos
boolean
sameView
(float yaw, float pitch) boolean
Checks if two positions have a similar view (yaw/pitch).@NotNull Pos
sub
(double value) @NotNull Pos
sub
(double x, double y, double z) @NotNull Pos
final String
toString()
Returns a string representation of this record class.@NotNull Pos
withCoord
(double x, double y, double z) Changes the 3 coordinates of this position.@NotNull Pos
@NotNull Pos
withDirection
(@NotNull Point point) Sets the yaw and pitch to point in the direction of the point.@NotNull Pos
withLookAt
(@NotNull Point point) @NotNull Pos
withPitch
(float pitch) @NotNull Pos
withPitch
(@NotNull DoubleUnaryOperator operator) @NotNull Pos
withView
(float yaw, float pitch) @NotNull Pos
@NotNull Pos
withX
(double x) Creates a point with the specified X coordinate.@NotNull Pos
withX
(@NotNull DoubleUnaryOperator operator) Creates a point with a modified X coordinate based on its value.@NotNull Pos
withY
(double y) Creates a point with the specified Y coordinate.@NotNull Pos
withY
(@NotNull DoubleUnaryOperator operator) Creates a point with a modified Y coordinate based on its value.@NotNull Pos
withYaw
(float yaw) @NotNull Pos
withYaw
(@NotNull DoubleUnaryOperator operator) @NotNull Pos
withZ
(double z) Creates a point with the specified Z coordinate.@NotNull Pos
withZ
(@NotNull DoubleUnaryOperator operator) Creates a point with a modified Z coordinate based on its value.double
x()
Returns the value of thex
record component.double
y()
Returns the value of they
record component.float
yaw()
Returns the value of theyaw
record component.double
z()
Returns the value of thez
record component.
-
Field Details
-
ZERO
-
-
Constructor Details
-
Pos
public Pos(double x, double y, double z, float yaw, float pitch) Creates an instance of aPos
record class.- Parameters:
x
- the value for thex
record componenty
- the value for they
record componentz
- the value for thez
record componentyaw
- the value for theyaw
record componentpitch
- the value for thepitch
record 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:Point
Creates a point with a modified X coordinate based on its value. -
withX
Description copied from interface:Point
Creates a point with the specified X coordinate. -
withY
@Contract(pure=true) @NotNull public @NotNull Pos withY(@NotNull @NotNull DoubleUnaryOperator operator) Description copied from interface:Point
Creates a point with a modified Y coordinate based on its value. -
withY
Description copied from interface:Point
Creates a point with the specified Y coordinate. -
withZ
@Contract(pure=true) @NotNull public @NotNull Pos withZ(@NotNull @NotNull DoubleUnaryOperator operator) Description copied from interface:Point
Creates a point with a modified Z coordinate based on its value. -
withZ
Description copied from interface:Point
Creates 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 thex
record component. -
y
public double y()Returns the value of they
record component. -
z
public double z()Returns the value of thez
record component. -
yaw
public float yaw()Returns the value of theyaw
record component.- Returns:
- the value of the
yaw
record component
-
pitch
public float pitch()Returns the value of thepitch
record component.- Returns:
- the value of the
pitch
record component
-