Wiki 9Minecraft Wiki 9Minecraft

Trigger Animations Based on Player Interaction or Game Events

Java EditionModGuides 4FAQ 10Related mods 60
DownloadGeckoLib Mod

Get the files on 9Minecraft

Contents (4)
  1. Create Event-Driven Animation Controllers
  2. Use Predicates to Switch Animations
  3. Trigger Custom Events
  4. Add Sound and Particle Keyframes

Create Event-Driven Animation Controllers

In your entity or block class, set up animation controllers that listen for specific conditions. These conditions can be entity states (attacking, hurt, moving), player proximity, or custom events you define.

Use Predicates to Switch Animations

Within each animation controller, write predicates—conditional checks that determine which animation plays. For example: if the entity's health drops, play a hurt animation; if a player is within range, play an alert animation. Predicates evaluate every tick and switch animations smoothly.

Trigger Custom Events

When specific actions occur (right-click, collision, timer), call methods on your animation controller to queue a new animation. GeckoLib handles the transition, using easing to blend from the current animation to the new one.

Add Sound and Particle Keyframes

In Blockbench, place keyframes at specific points in your animation timeline to spawn particles or play sounds. When that animation plays in-game, GeckoLib automatically triggers those effects at the exact frame, synchronizing audio and visuals perfectly.

More guides for this mod