Entity AzAnimator Basics

The AzEntityAnimator is a framework specifically designed to handle animations for Entity instances in AzureLib. By extending the base functionality of AzAnimator, it provides an easy-to-use API for creating animation systems tailored to entities.

Overview of AzEntityAnimator

The AzEntityAnimator builds on the generic animation system outlined in the AzAnimator but focuses explicitly on animating entities. It simplifies entity animation setup and configuration by abstracting much of the common functionality.

Key Features

  • Purpose-built for animating Entity instances.
  • Maintains compatibility with AzureLib's baked animation and MoLang systems.
  • Fully integrates with the AzAnimator APIs, including animation controllers and context handling.

Constructor

The AzEntityAnimator requires a configuration object (AzAnimatorConfig) to initialize:

public AzEntityAnimator(AzAnimatorConfig config) { super(config); }

To simplify setup, you can use the defaultConfig for common scenarios:

public YourEntityAnimator() { super(AzAnimatorConfig.defaultConfig()); }

Example: YourEntityAnimator

Below is a working example of a custom animator for a entity, YourEntity, using the AzEntityAnimator.

java public class YourEntityAnimator extends AzEntityAnimator<YourEntity> {
private static final ResourceLocation ANIMATIONS = CommonMod.modResource(
"animations/entity/yourentity.animation.json"
);
public YourEntityAnimator() {
super(AzAnimatorConfig.defaultConfig());
}
@Override
public void registerControllers(AzAnimationControllerContainer<YourEntity> animationControllerContainer) {
animationControllerContainer.add(
AzAnimationController.builder(this, "base_controller")
.build()
);
}
@Override
public @NotNull ResourceLocation getAnimationLocation(YourEntity animatable) {
return ANIMATIONS;
}
}