Record Class ElementVector

java.lang.Object
java.lang.Record
kr.toxicity.library.dynamicuv.ElementVector
Record Components:
x - the x coordinate
y - the y coordinate
z - the z coordinate

public record ElementVector(float x, float y, float z) extends Record
Represents a 3D vector for elements.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final ElementVector
    The center vector (8, 8, 8).
  • Constructor Summary

    Constructors
    Constructor
    Description
    ElementVector(float x, float y, float z)
    Creates an instance of a ElementVector record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull com.google.gson.JsonArray
    Converts the vector to a JSON array.
    @NotNull ElementVector
    div(float scala)
    Divides the vector coordinates by the given scalar.
    @NotNull ElementVector
    div(float x, float y, float z)
    Divides the vector coordinates by the given divisors.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    @NotNull ElementVector
    inflate(float inflate)
    Inflates the vector by the given amount.
    static @NotNull ElementVector
    max(@NotNull ElementVector from, @NotNull ElementVector to)
    Returns a vector with the maximum coordinates of the two given vectors.
    static @NotNull ElementVector
    min(@NotNull ElementVector from, @NotNull ElementVector to)
    Returns a vector with the minimum coordinates of the two given vectors.
    @NotNull ElementVector
    minus(float x, float y, float z)
    Subtracts the given coordinates from this vector.
    @NotNull ElementVector
    minus(@NotNull ElementVector vector)
    Subtracts the given vector from this vector.
    @NotNull ElementVector
    mul(float scala)
    Multiplies the vector coordinates by the given scalar.
    @NotNull ElementVector
    mul(float x, float y, float z)
    Multiplies the vector coordinates by the given factors.
    @NotNull ElementVector
    plus(float x, float y, float z)
    Adds the given coordinates to this vector.
    @NotNull ElementVector
    plus(@NotNull ElementVector vector)
    Adds the given vector to this vector.
    @NotNull ElementVector
    Converts this vector to model location (multiplies by 16).
    final String
    Returns a string representation of this record class.
    float
    x()
    Returns the value of the x record component.
    @NotNull ElementVector
    xy()
    Returns a new vector with only the X and Y components (Z is 0).
    @NotNull ElementVector
    xz()
    Returns a new vector with only the X and Z components (Y is 0).
    float
    y()
    Returns the value of the y record component.
    float
    z()
    Returns the value of the z record component.
    @NotNull ElementVector
    zy()
    Returns a new vector with only the Z and Y components (X is 0).

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • CENTER

      public static final ElementVector CENTER
      The center vector (8, 8, 8).
  • Constructor Details

    • ElementVector

      public ElementVector(float x, float y, float z)
      Creates an instance of a ElementVector record class.
      Parameters:
      x - the value for the x record component
      y - the value for the y record component
      z - the value for the z record component
  • Method Details

    • min

      @NotNull public static @NotNull ElementVector min(@NotNull @NotNull ElementVector from, @NotNull @NotNull ElementVector to)
      Returns a vector with the minimum coordinates of the two given vectors.
      Parameters:
      from - the first vector
      to - the second vector
      Returns:
      the vector with minimum coordinates
    • max

      @NotNull public static @NotNull ElementVector max(@NotNull @NotNull ElementVector from, @NotNull @NotNull ElementVector to)
      Returns a vector with the maximum coordinates of the two given vectors.
      Parameters:
      from - the first vector
      to - the second vector
      Returns:
      the vector with maximum coordinates
    • plus

      @NotNull public @NotNull ElementVector plus(float x, float y, float z)
      Adds the given coordinates to this vector.
      Parameters:
      x - the x coordinate to add
      y - the y coordinate to add
      z - the z coordinate to add
      Returns:
      the resulting vector
    • plus

      @NotNull public @NotNull ElementVector plus(@NotNull @NotNull ElementVector vector)
      Adds the given vector to this vector.
      Parameters:
      vector - the vector to add
      Returns:
      the resulting vector
    • minus

      @NotNull public @NotNull ElementVector minus(float x, float y, float z)
      Subtracts the given coordinates from this vector.
      Parameters:
      x - the x coordinate to subtract
      y - the y coordinate to subtract
      z - the z coordinate to subtract
      Returns:
      the resulting vector
    • minus

      @NotNull public @NotNull ElementVector minus(@NotNull @NotNull ElementVector vector)
      Subtracts the given vector from this vector.
      Parameters:
      vector - the vector to subtract
      Returns:
      the resulting vector
    • toModelLocation

      @NotNull public @NotNull ElementVector toModelLocation()
      Converts this vector to model location (multiplies by 16).
      Returns:
      the resulting vector
    • inflate

      @NotNull public @NotNull ElementVector inflate(float inflate)
      Inflates the vector by the given amount.
      Parameters:
      inflate - the amount to inflate
      Returns:
      the resulting vector
    • mul

      @NotNull public @NotNull ElementVector mul(float x, float y, float z)
      Multiplies the vector coordinates by the given factors.
      Parameters:
      x - the x factor
      y - the y factor
      z - the z factor
      Returns:
      the resulting vector
    • div

      @NotNull public @NotNull ElementVector div(float x, float y, float z)
      Divides the vector coordinates by the given divisors.
      Parameters:
      x - the x divisor
      y - the y divisor
      z - the z divisor
      Returns:
      the resulting vector
    • mul

      @NotNull public @NotNull ElementVector mul(float scala)
      Multiplies the vector coordinates by the given scalar.
      Parameters:
      scala - the scalar
      Returns:
      the resulting vector
    • div

      @NotNull public @NotNull ElementVector div(float scala)
      Divides the vector coordinates by the given scalar.
      Parameters:
      scala - the scalar
      Returns:
      the resulting vector
    • asJson

      @NotNull public @NotNull com.google.gson.JsonArray asJson()
      Converts the vector to a JSON array.
      Returns:
      the JSON array
    • xz

      @NotNull public @NotNull ElementVector xz()
      Returns a new vector with only the X and Z components (Y is 0).
      Returns:
      the XZ vector
    • xy

      @NotNull public @NotNull ElementVector xy()
      Returns a new vector with only the X and Y components (Z is 0).
      Returns:
      the XY vector
    • zy

      @NotNull public @NotNull ElementVector zy()
      Returns a new vector with only the Z and Y components (X is 0).
      Returns:
      the ZY vector
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • x

      public float x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      public float y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component
    • z

      public float z()
      Returns the value of the z record component.
      Returns:
      the value of the z record component