How to trigger Animations on Block Entities

Setting up your controller

In your registerControllers add triggerableAnim to your controller like so

public void registerControllers(ControllerRegistrar controllers) {
        new AnimationController<>(this, "baseAnim", event -> PlayState.CONTINUE)
        .triggerableAnim("anim", RawAnimation.begin().thenPlayAndHold("anim"));

You can add more triggers for each animation you want to call.

Calling the trigger

To call the trigger, you will simply need to call triggerAnim wherever you wish to use the trigger. Here is an example of calling on the tick method of a Block Entity to play an animation when applying effects.

public static void tick(Level level, BlockPos pos, BlockState state, ExampleBlockEntity bEntity) {
    if (bEntity.getLevel().getGameTime() % 80L == 0L) {
        this.triggerAnim("baseAnim", "anim");

Last updated