Record Class AnimationContext

java.lang.Object
java.lang.Record
dev.oxydien.mathimations.animations.AnimationContext

public record AnimationContext(Pose pose, AnimatorContext animatorContext, double animationTime) extends Record
A context to animate an entity. This context provides the current model part states, the delta time since the last tick, and the time since the entity was spawned*.
  • Constructor Details

    • AnimationContext

      public AnimationContext(Pose pose, AnimatorContext animatorContext, double animationTime)
      Creates an instance of a AnimationContext record class.
      Parameters:
      pose - the value for the pose record component
      animatorContext - the value for the animatorContext record component
      animationTime - the value for the animationTime record component
  • Method Details

    • getPart

      @Nullable public @Nullable ModelPartState getPart(String name)
      Get the model part state for the given name. If the part does not exist, the method returns null.

      Note for users: If this returns null, the model part does not exist. DON'T TRY TO FIX IT BY CHECKING FOR NULL, this will just make it worse for players (and you, trying to fix it).

      Parameters:
      name - the name of the model part. If the part is under a parent, use a forward slash ("/") to separate the parent and child parts. For example: "neck/head/left_ear" . Root of the model is named "ROOT".
      Returns:
      the model part state or null
    • getParts

      public ModelPartState[] getParts(String... names)
      Get the model part states for the given names. If a part does not exist, the corresponding index in the array will be null.
      Parameters:
      names - the names of the model parts. If the part is under a parent, use a forward slash ("/") to separate the parent and child parts. For example: "neck/head/left_ear" . Root of the model is named "ROOT".
      Returns:
      an array of model part states
    • getPartialTicks

      public float getPartialTicks()
      Get the partial ticks since the last (global) render.
      Returns:
      the partial ticks
    • getDelta

      public double getDelta()
      Get the delta time since the last render in seconds.

      Note that this number can get extremely high if the entity is not visible for a long time.

      Use getPartialTicks() to get the partial ticks since the last render.

      Returns:
      the delta time in seconds
    • getTimeSinceEntityStart

      public double getTimeSinceEntityStart()
      The time since the entity was spawned*, in seconds. This value is the sum of:
      • The time since the renderer started tracking this entity (in seconds)
      • The entity age when the renderer started tracking this entity (in ticks)

      This number can be useful when working with goniometric functions.

      Returns:
      the time since the entity was spawned
    • getAnimationTime

      public double getAnimationTime()
      The time since the animation started, in seconds.
      Returns:
      the time since the animation started
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components 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.
    • pose

      public Pose pose()
      Returns the value of the pose record component.
      Returns:
      the value of the pose record component
    • animatorContext

      public AnimatorContext animatorContext()
      Returns the value of the animatorContext record component.
      Returns:
      the value of the animatorContext record component
    • animationTime

      public double animationTime()
      Returns the value of the animationTime record component.
      Returns:
      the value of the animationTime record component