Record Class Pos
java.lang.Object
java.lang.Record
net.minestom.server.coordinate.Pos
- All Implemented Interfaces:
Point
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(double value) add(double x, double y, double z) apply(Pos.Operator operator) Returns a new position based on this position fields.Gets a unit-vector pointing in the direction that this Location is facing.div(double value) div(double x, double y, double z) final booleanIndicates whether some other object is "equal to" this one.facing()static floatfixYaw(float yaw) Fixes a yaw value that is not between -180.0F and 180.0F So for example -1355.0F becomes 85.0F and 225.0F becomes -135.0Fstatic PosDeprecated.final inthashCode()Returns a hash code value for this object.mul(double value) mul(double x, double y, double z) floatpitch()Returns the value of thepitchrecord component.booleansameView(float yaw, float pitch) booleanChecks if two positions have a similar view (yaw/pitch).sub(double value) sub(double x, double y, double z) final StringtoString()Returns a string representation of this record class.withCoord(double x, double y, double z) Changes the 3 coordinates of this position.withDirection(Point point) Sets the yaw and pitch to point in the direction of the point.withLookAt(Point point) withPitch(float pitch) withPitch(DoubleUnaryOperator operator) withView(float yaw, float pitch) 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.withYaw(float yaw) withYaw(DoubleUnaryOperator operator) 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()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
Deprecated.usePoint.asPos()instead- Parameters:
point- the point to convert- Returns:
- the converted position
-
withCoord
-
withCoord
-
withView
-
withView
-
withDirection
-
withYaw
-
withYaw
-
withPitch
-
withLookAt
-
withPitch
-
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
-
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
Description copied from interface:PointCreates a point with a modified X coordinate based on its value. -
withX
-
withY
Description copied from interface:PointCreates a point with a modified Y coordinate based on its value. -
withY
-
withZ
Description copied from interface:PointCreates a point with a modified Z coordinate based on its value. -
withZ
-
add
-
add
-
add
-
sub
-
sub
-
sub
-
mul
-
mul
-
mul
-
div
-
div
-
div
-
relative
-
fixYaw
public static float fixYaw(float yaw) Fixes a yaw value that is not between -180.0F and 180.0F So for example -1355.0F becomes 85.0F and 225.0F becomes -135.0F- Parameters:
yaw- The possible "wrong" yaw- Returns:
- a fixed yaw
-
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. -
x
-
y
-
z
-
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
-
Point.asPos()instead