Record Class RelativeVec
java.lang.Object
java.lang.Record
net.minestom.server.utils.location.RelativeVec
public record RelativeVec(@NotNull Vec vec, @NotNull RelativeVec.CoordinateType coordinateType, boolean relativeX, boolean relativeY, boolean relativeZ)
extends Record
Represents a location which can have fields relative to an
Entity
position.
Useful for parsing Vec2 or Vec3 types
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionRelativeVec
(@NotNull Vec vec, @NotNull RelativeVec.CoordinateType coordinateType, boolean relativeX, boolean relativeY, boolean relativeZ) Creates an instance of aRelativeVec
record class. -
Method Summary
Modifier and TypeMethodDescription@NotNull RelativeVec.CoordinateType
Returns the value of thecoordinateType
record component.final boolean
Indicates whether some other object is "equal to" this one.@NotNull Vec
Gets the location based on the relative fields andvec()
.@NotNull Vec
Gets the location based on the relative fields.@NotNull Vec
fromSender
(@Nullable CommandSender sender) Computes a viewVec
based on the given point's yaw and pitch.@NotNull Vec
Shorthand forfromView(Pos)
final int
hashCode()
Returns a hash code value for this object.boolean
Gets if the 'x' field is relative.boolean
Gets if the 'y' field is relative.boolean
Gets if the 'z' field is relative.boolean
Returns the value of therelativeX
record component.boolean
Returns the value of therelativeY
record component.boolean
Returns the value of therelativeZ
record component.final String
toString()
Returns a string representation of this record class.@NotNull Vec
vec()
Returns the value of thevec
record component.
-
Constructor Details
-
RelativeVec
public RelativeVec(@NotNull @NotNull Vec vec, @NotNull @NotNull RelativeVec.CoordinateType coordinateType, boolean relativeX, boolean relativeY, boolean relativeZ) Creates an instance of aRelativeVec
record class.- Parameters:
vec
- the value for thevec
record componentcoordinateType
- the value for thecoordinateType
record componentrelativeX
- the value for therelativeX
record componentrelativeY
- the value for therelativeY
record componentrelativeZ
- the value for therelativeZ
record component
-
-
Method Details
-
from
Gets the location based on the relative fields andvec()
.- Parameters:
origin
- the origin position, null if none- Returns:
- the location
-
from
Gets the location based on the relative fields.- Parameters:
entity
- the entity to get the relative position from- Returns:
- the location
-
fromSender
- Parameters:
sender
- entity- Returns:
- the position with any relativity
-
fromView
-
fromView
Shorthand forfromView(Pos)
- Parameters:
entity
- to get the position from, otherwisePos.ZERO
- Returns:
- the view.
-
isRelativeX
public boolean isRelativeX()Gets if the 'x' field is relative.- Returns:
- true if the 'x' field is relative
-
isRelativeY
public boolean isRelativeY()Gets if the 'y' field is relative.- Returns:
- true if the 'y' field is relative
-
isRelativeZ
public boolean isRelativeZ()Gets if the 'z' field is relative.- Returns:
- true if the 'z' field is relative
-
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. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
vec
Returns the value of thevec
record component.- Returns:
- the value of the
vec
record component
-
coordinateType
Returns the value of thecoordinateType
record component.- Returns:
- the value of the
coordinateType
record component
-
relativeX
public boolean relativeX()Returns the value of therelativeX
record component.- Returns:
- the value of the
relativeX
record component
-
relativeY
public boolean relativeY()Returns the value of therelativeY
record component.- Returns:
- the value of the
relativeY
record component
-
relativeZ
public boolean relativeZ()Returns the value of therelativeZ
record component.- Returns:
- the value of the
relativeZ
record component
-