Interface AttackAnimationLogic
- All Known Implementing Classes:
DelayedAttackAnimationLogic,LegacyAttackAnimationLogic,ModelledAttackAnimationLogic,MovementAttackAnimationLogic
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:
-
The new typed animation format, decoded through the
PixelmonRegistry.getAttackAnimationTypeRegistry()registry. -
The legacy
AttackAnimationformat, which is automatically wrapped inLegacyAttackAnimationLogic.
A typical lifecycle is:
play(BattleController, PixelmonWrapper, PixelmonWrapper, Attack)creates the animation instance.tick(AttackAnimation)is called every tick while the animation is active.isFinished(AttackAnimation)is checked to determine whether the animation should end.cleanUp(AttackAnimation)is called once the animation is removed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<AttackAnimationLogic> static final com.mojang.serialization.Codec<AttackAnimationLogic> -
Method Summary
Modifier and TypeMethodDescriptiondefault voidcleanUp(AttackAnimation animation) Cleans up any resources owned by the animation.com.mojang.serialization.MapCodec<? extends AttackAnimationLogic> codec()Gets the codec used to encode and decode this specific animation logic implementation.booleanisFinished(AttackAnimation animation) Checks whether the animation has finished and should be removed.play(BattleController controller, PixelmonWrapper user, PixelmonWrapper target, Attack attack) Starts this attack animation.voidtick(AttackAnimation animation) Updates the active animation for one battle tick.AttackAnimationType<? extends AttackAnimationLogic> type()Gets the registered animation logic type for this implementation.
-
Field Details
-
DIRECT_CODEC
-
CODEC
-
-
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
AttackAnimationType<? extends AttackAnimationLogic> type()Gets the registered animation logic type for this implementation.This value is used by
DIRECT_CODECto 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
AttackAnimationinstance 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 inuser- the Pokémon using the attacktarget- the Pokémon targeted by the attackattack- the attack being animated- Returns:
- the created runtime animation instance
-
tick
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
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:
trueif the animation should end; otherwisefalse
-
cleanUp
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
-