Interface AttackAnimationLogic

All Known Implementing Classes:
DelayedAttackAnimationLogic, LegacyAttackAnimationLogic, ModelledAttackAnimationLogic, MovementAttackAnimationLogic

public interface AttackAnimationLogic
Defines the runtime behaviour for a battle attack animation.

An AttackAnimationLogic is responsible for creating, updating, and eventually finishing an AttackAnimation. Implementations may represent the newer data-driven animation system, legacy attack animations, modelled GLTF animations, particle-based animations, or any other animation implementation registered through AttackAnimationType.

The codec supports two input formats:

A typical lifecycle is:

  1. play(BattleController, PixelmonWrapper, PixelmonWrapper, Attack) creates the animation instance.
  2. tick(AttackAnimation) is called every tick while the animation is active.
  3. isFinished(AttackAnimation) is checked to determine whether the animation should end.
  4. cleanUp(AttackAnimation) is called once the animation is removed.
  • Field Details

  • Method Details

    • codec

      com.mojang.serialization.MapCodec<? extends AttackAnimationLogic> codec()
      Gets the codec used to encode and decode this specific animation logic implementation.
      Returns:
      the implementation-specific codec
    • type

      Gets the registered animation logic type for this implementation.

      This value is used by DIRECT_CODEC to dispatch to the correct codec when decoding data-driven animation definitions.

      Returns:
      the registered attack animation type
    • play

      AttackAnimation play(BattleController controller, PixelmonWrapper user, PixelmonWrapper target, Attack attack)
      Starts this attack animation.

      This method should create and initialize the runtime AttackAnimation instance for the supplied battle context. Implementations may spawn entities, attach client-side render data, resolve animation targets, store context values, or perform any other setup required before ticking begins.

      Parameters:
      controller - the battle controller the animation is being played in
      user - the Pokémon using the attack
      target - the Pokémon targeted by the attack
      attack - the attack being animated
      Returns:
      the created runtime animation instance
    • tick

      void tick(AttackAnimation animation)
      Updates the active animation for one battle tick.

      This is called while the animation is active, and before it has finished. Implementations should use this to update positions, transforms, particles, model state, playback state, or any other time-based animation behaviour.

      Parameters:
      animation - the active animation instance
    • isFinished

      boolean isFinished(AttackAnimation animation)
      Checks whether the animation has finished and should be removed.

      Implementations may base this on a fixed duration, a battle state condition being removed, an entity no longer existing, or any other implementation-specific removal condition.

      Parameters:
      animation - the active animation instance
      Returns:
      true if the animation should end; otherwise false
    • cleanUp

      default void cleanUp(AttackAnimation animation)
      Cleans up any resources owned by the animation.

      This is called once the animation has finished or is otherwise removed. Override this method when an implementation needs to discard spawned entities, detach persistent effects, clear cached state, or perform other teardown work.

      Parameters:
      animation - the animation being cleaned up