Record Class ModelDatapoint

java.lang.Object
java.lang.Record
kr.toxicity.model.api.data.raw.ModelDatapoint
Record Components:
x - the x-coordinate value or script
y - the y-coordinate value or script
z - the z-coordinate value or script
script - the script string (used for sound/particle effects)

@Internal public record ModelDatapoint(@Nullable com.google.gson.JsonPrimitive x, @Nullable com.google.gson.JsonPrimitive y, @Nullable com.google.gson.JsonPrimitive z, @Nullable String script) extends Record
Represents a single data point within a keyframe, which can be a static value or a Molang script.

This record holds the raw JSON values for x, y, and z coordinates, or a script string.

Since:
1.15.2
  • Constructor Summary

    Constructors
    Constructor
    Description
    ModelDatapoint(@Nullable com.google.gson.JsonPrimitive x, @Nullable com.google.gson.JsonPrimitive y, @Nullable com.google.gson.JsonPrimitive z, @Nullable String script)
    Creates an instance of a ModelDatapoint record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Checks if this data point contains a script.
    @NotNull String
    Returns the script string.
    @NotNull FloatFunction<org.joml.Vector3f>
    toFunction(@NotNull ModelLoadContext context)
    Converts this data point into a function that returns a Vector3f.
    final String
    Returns a string representation of this record class.
    @Nullable com.google.gson.JsonPrimitive
    x()
    Returns the value of the x record component.
    @Nullable com.google.gson.JsonPrimitive
    y()
    Returns the value of the y record component.
    @Nullable com.google.gson.JsonPrimitive
    z()
    Returns the value of the z record component.

    Methods inherited from class java.lang.Object

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

    • ModelDatapoint

      public ModelDatapoint(@Nullable @Nullable com.google.gson.JsonPrimitive x, @Nullable @Nullable com.google.gson.JsonPrimitive y, @Nullable @Nullable com.google.gson.JsonPrimitive z, @Nullable @Nullable String script)
      Creates an instance of a ModelDatapoint 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
      script - the value for the script record component
  • Method Details

    • hasScript

      public boolean hasScript()
      Checks if this data point contains a script.
      Returns:
      true if a script is present, false otherwise
      Since:
      1.15.2
    • script

      @NotNull public @NotNull String script()
      Returns the script string.
      Returns:
      the script
      Throws:
      NullPointerException - if no script is present
      Since:
      1.15.2
    • toFunction

      @NotNull public @NotNull FloatFunction<org.joml.Vector3f> toFunction(@NotNull @NotNull ModelLoadContext context)
      Converts this data point into a function that returns a Vector3f.

      If the data point contains static values, it returns a constant function. If it contains Molang expressions, it compiles them into a function that evaluates the expressions.

      Parameters:
      context - the model loading context
      Returns:
      a function to get the vector value
      Since:
      1.15.2
    • 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 Objects::equals(Object,Object).
      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

      @Nullable public @Nullable com.google.gson.JsonPrimitive x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      @Nullable public @Nullable com.google.gson.JsonPrimitive y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component
    • z

      @Nullable public @Nullable com.google.gson.JsonPrimitive z()
      Returns the value of the z record component.
      Returns:
      the value of the z record component