From a07a33c06878b55d60318b45e1b08097ce334148 Mon Sep 17 00:00:00 2001 From: "Luis C.M." <42545778+c0508383@users.noreply.github.com> Date: Thu, 4 Apr 2024 22:36:11 -0500 Subject: [PATCH] Fixed animations not transitioning correctly when updating from a looping animation. --- src/main/java/noppes/npcs/controllers/data/Animation.java | 2 +- .../java/noppes/npcs/controllers/data/AnimationData.java | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/noppes/npcs/controllers/data/Animation.java b/src/main/java/noppes/npcs/controllers/data/Animation.java index 29dd816e7..5de123d88 100644 --- a/src/main/java/noppes/npcs/controllers/data/Animation.java +++ b/src/main/java/noppes/npcs/controllers/data/Animation.java @@ -251,7 +251,7 @@ public class Animation implements IAnimation { } this.currentFrameTime++; - if (this.currentFrameTime == this.currentFrame().getDuration()) { + if (this.currentFrame() != null && this.currentFrameTime == this.currentFrame().getDuration()) { EventHooks.onAnimationFrameExited(this, this.currentFrame()); Frame prevFrame = (Frame) this.currentFrame(); diff --git a/src/main/java/noppes/npcs/controllers/data/AnimationData.java b/src/main/java/noppes/npcs/controllers/data/AnimationData.java index 112a461cf..ba7fde579 100644 --- a/src/main/java/noppes/npcs/controllers/data/AnimationData.java +++ b/src/main/java/noppes/npcs/controllers/data/AnimationData.java @@ -264,10 +264,13 @@ public class AnimationData implements IAnimationData { CommonProxy.clientPlayingAnimations.add(newAnim); } } + + Animation prevAnim = this.animation; this.animation = newAnim; - if (this.isActive() && newAnim != null && !newAnim.frames.isEmpty()) { - Frame frame = (Frame) this.animation.currentFrame(); + if (this.getMCEntity() != null && this.getMCEntity().worldObj.isRemote && + this.isActive() && prevAnim != null && newAnim != null && !newAnim.frames.isEmpty()) { + Frame frame = (Frame) prevAnim.currentFrame(); if (frame != null) { Frame firstFrame = newAnim.frames.get(0); for (Map.Entry entry : frame.frameParts.entrySet()) {