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 Summary
ConstructorsConstructorDescriptionAnimationContext(Pose pose, AnimatorContext animatorContext, double animationTime) Creates an instance of aAnimationContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of theanimationTimerecord component.Returns the value of theanimatorContextrecord component.final booleanIndicates whether some other object is "equal to" this one.doubleThe time since the animation started, in seconds.doublegetDelta()Get the delta time since the last render in seconds.@Nullable ModelPartStateGet the model part state for the given name.floatGet the partial ticks since the last (global) render.Get the model part states for the given names.doubleThe time since the entity was spawned*, in seconds.final inthashCode()Returns a hash code value for this object.pose()Returns the value of theposerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
AnimationContext
Creates an instance of aAnimationContextrecord class.- Parameters:
pose- the value for theposerecord componentanimatorContext- the value for theanimatorContextrecord componentanimationTime- the value for theanimationTimerecord component
-
-
Method Details
-
getPart
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
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
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 '=='. -
pose
Returns the value of theposerecord component.- Returns:
- the value of the
poserecord component
-
animatorContext
Returns the value of theanimatorContextrecord component.- Returns:
- the value of the
animatorContextrecord component
-
animationTime
public double animationTime()Returns the value of theanimationTimerecord component.- Returns:
- the value of the
animationTimerecord component
-