From fd7412148db945354dc989acd331dff473fabccb Mon Sep 17 00:00:00 2001 From: "Luis C.M" <42545778+c0508383@users.noreply.github.com> Date: Mon, 19 Feb 2024 18:24:39 -0600 Subject: [PATCH] Fixed animation interpolation not working after animations are stopped. --- .../npcs/client/PacketHandlerClient.java | 26 +++++++++---------- .../npcs/controllers/data/AnimationData.java | 2 +- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index 3cb666e93..76a1414a4 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -318,21 +318,19 @@ public class PacketHandlerClient extends PacketHandlerServer{ } if (animationData != null) { - animationData.readFromNBT(compound); - int animationId; - if (compound.hasKey("AnimationID")) { - animationId = compound.getInteger("AnimationID"); - } else { - Animation animation = new Animation(); - animation.readFromNBT(compound.getCompoundTag("Animation")); - ClientCacheHandler.animationCache.put(animation.getID(), animation); - animationId = animation.getID(); - } + int animationId; + if (compound.hasKey("AnimationID")) { + animationId = compound.getInteger("AnimationID"); + } else { + Animation animation = new Animation(); + animation.readFromNBT(compound.getCompoundTag("Animation")); + ClientCacheHandler.animationCache.put(animation.getID(), animation); + animationId = animation.getID(); + } - if (animationData.allowAnimation) { - animationData.setAnimation(ClientCacheHandler.animationCache.get(animationId)); - Client.sendData(EnumPacketServer.CacheAnimation, animationId); - } + animationData.setAnimation(ClientCacheHandler.animationCache.get(animationId)); + animationData.readFromNBT(compound); + Client.sendData(EnumPacketServer.CacheAnimation, animationId); } } else if(type == EnumPacketClient.DISABLE_MOUSE_INPUT) { diff --git a/src/main/java/noppes/npcs/controllers/data/AnimationData.java b/src/main/java/noppes/npcs/controllers/data/AnimationData.java index 928b81fd3..7ea4dc836 100644 --- a/src/main/java/noppes/npcs/controllers/data/AnimationData.java +++ b/src/main/java/noppes/npcs/controllers/data/AnimationData.java @@ -153,7 +153,7 @@ public class AnimationData implements IAnimationData { } else { Animation newAnim = new Animation(); newAnim.readFromNBT(((Animation) animation).writeToNBT()); - if (this.animation != null && newAnim.frames.size() > 0) { + if (this.isActive() && !newAnim.frames.isEmpty()) { Frame frame = (Frame) this.animation.currentFrame(); if (frame != null) { Frame firstFrame = newAnim.frames.get(0);