Enhance ability animation handling: track ability animation state, clear orphaned animations on login, and ensure proper animation continuation

This commit is contained in:
Kam committed 2026-02-15 22:03:32 -05:00
1 parent 3beaf68815
commit 248dbf66da
2 files changed
+40 -5

No files matched your search

@@ -95,13 +95,21 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
private boolean specialKeyDown = false;
public void onLogin() {
// Continue playing animation for self when re-logging
// Handle animation state from previous session
AnimationData animationData = this.animationData;
if (animationData != null && animationData.isClientAnimating()) {
Animation currentAnimation = animationData.currentClientAnimation;
NBTTagCompound compound = currentAnimation.writeToNBT();
animationData.viewAnimation(currentAnimation, animationData, compound,
animationData.isClientAnimating(), currentAnimation.currentFrame, currentAnimation.currentFrameTime);
if (abilityData.isPlayingAbilityAnimation()) {
// Ability animation was playing when player disconnected.
// Ability state is transient (lost on disconnect), so this animation
// is orphaned - clear it instead of replaying a stuck animation.
abilityData.clearOrphanedAbilityAnimation();
} else {
// Non-ability animation (e.g. script-driven) - continue playing
Animation currentAnimation = animationData.currentClientAnimation;
NBTTagCompound compound = currentAnimation.writeToNBT();
animationData.viewAnimation(currentAnimation, animationData, compound,
animationData.isClientAnimating(), currentAnimation.currentFrame, currentAnimation.currentFrameTime);
}
}
CustomEffectController controller = CustomEffectController.getInstance();