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 aRelativeVecrecord class. -
Method Summary
Modifier and TypeMethodDescription@NotNull RelativeVec.CoordinateTypeReturns the value of thecoordinateTyperecord component.final booleanIndicates whether some other object is "equal to" this one.@NotNull VecGets the location based on the relative fields andvec().@NotNull VecGets the location based on the relative fields.@NotNull VecfromSender(@Nullable CommandSender sender) Computes a viewVecbased on the given point's yaw and pitch.@NotNull VecShorthand forfromView(Pos)final inthashCode()Returns a hash code value for this object.booleanGets if the 'x' field is relative.booleanGets if the 'y' field is relative.booleanGets if the 'z' field is relative.booleanReturns the value of therelativeXrecord component.booleanReturns the value of therelativeYrecord component.booleanReturns the value of therelativeZrecord component.final StringtoString()Returns a string representation of this record class.@NotNull Vecvec()Returns the value of thevecrecord 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 aRelativeVecrecord class.- Parameters:
vec- the value for thevecrecord componentcoordinateType- the value for thecoordinateTyperecord componentrelativeX- the value for therelativeXrecord componentrelativeY- the value for therelativeYrecord componentrelativeZ- the value for therelativeZrecord 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 thevecrecord component.- Returns:
- the value of the
vecrecord component
-
coordinateType
Returns the value of thecoordinateTyperecord component.- Returns:
- the value of the
coordinateTyperecord component
-
relativeX
public boolean relativeX()Returns the value of therelativeXrecord component.- Returns:
- the value of the
relativeXrecord component
-
relativeY
public boolean relativeY()Returns the value of therelativeYrecord component.- Returns:
- the value of the
relativeYrecord component
-
relativeZ
public boolean relativeZ()Returns the value of therelativeZrecord component.- Returns:
- the value of the
relativeZrecord component
-