The AzAnimator is the core system in AzureLib designed to manage the animation logic for various objects, such as entities, block entities, or items. This system provides a reusable framework for integrating MoLang-based animations, custom animation controllers, and smooth transition mechanisms.
Overview of AzAnimator
The AzAnimator is an abstract class with the following key features:
- It manages animation states and transitions for objects (
T) like entities, blocks, and items. - It caches and reuses animation data for performance.
- It provides an extensible structure using animation controllers and Molang queries.
Key Responsibilities
-
Controller Registration Define and register animation controllers responsible for managing behavioral animations.
-
Animation Execution Process animations for entities or objects using MoLang queries and baked models.
-
Custom Animations Overrideable hooks allow custom animations unique to animated objects.
Core Methods
1. registerControllers
- Abstract method where animation controllers must be created and registered:
public abstract void registerControllers(AzAnimationControllerContainer<T> animationControllerContainer);
- Example Usage: Define specific controllers (e.g., idle, walking, interactions) for your entity or object.
- Controllers are applied in the order they are added. When several controllers animate the same bone, each one is layered on top of the ones before it; see Layering Controllers.
- A controller can cycle through random animation variants on its own, such as several idles, using a weighted pool; see Random Animation Pools. The controller's transition length controls how the variants blend into each other.
2. getAnimationLocation
- Abstract method for locating the animation file for the animatable object:
public abstract @NotNull ResourceLocation getAnimationLocation(T animatable);
3. setCustomAnimations
- Override this method to define custom animations or behaviors:
This is useful for unique animations that aren't predefined in the animation file.public void setCustomAnimations(T animatable, float partialTicks)
MoLang Integration
The applyMolangQueries method facilitates MoLang runtime queries that affect animation states
MoLang Queries Supported:
LIFE_TIME: Determines how long the animation has been running.TIME_OF_DAY: Retrieves the in-game time.ACTOR_COUNT: Returns the number of entities in the world.MOON_PHASE: Identifies the moon cycle.