Trigger Animations Based on Player Interaction or Game Events
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.