diff --git a/src/main/java/noppes/npcs/controllers/data/Animation.java b/src/main/java/noppes/npcs/controllers/data/Animation.java index 41f05c971..be05ef4e1 100644 --- a/src/main/java/noppes/npcs/controllers/data/Animation.java +++ b/src/main/java/noppes/npcs/controllers/data/Animation.java @@ -250,9 +250,9 @@ public class Animation implements IAnimation { return compound; } - public void increaseTime() { + public boolean increaseTime() { if (paused) - return; + return false; if (this.parent != null && this.currentFrame < this.frames.size()) { this.parent.finishedFrame = this.currentFrame; @@ -289,6 +289,8 @@ public class Animation implements IAnimation { this.parent.finishedTime = this.parent.getMCEntity().getAge(); } } + + return true; } @SideOnly(Side.CLIENT) diff --git a/src/main/java/noppes/npcs/controllers/data/AnimationData.java b/src/main/java/noppes/npcs/controllers/data/AnimationData.java index 966789d9a..a7d120672 100644 --- a/src/main/java/noppes/npcs/controllers/data/AnimationData.java +++ b/src/main/java/noppes/npcs/controllers/data/AnimationData.java @@ -88,13 +88,14 @@ public class AnimationData implements IAnimationData { if(sendingEntity.dimension != sendingEntity.worldObj.provider.dimensionId) sendingEntity.dimension = sendingEntity.worldObj.provider.dimensionId; + this.animatingTime = 0; + boolean prevIsClientAnimating = this.isClientAnimating && this.currentClientAnimation.currentFrame() != null; this.isClientAnimating = this.allowAnimation && this.animation != null; if (prevIsClientAnimating && (!this.isClientAnimating || this.animation != this.currentClientAnimation)) { EventHooks.onAnimationEnded(this.currentClientAnimation); } if (this.isClientAnimating) { - this.animatingTime = 0; this.currentClientAnimation = this.animation; } @@ -163,10 +164,18 @@ public class AnimationData implements IAnimationData { } public void increaseTime() { + Animation updateAnimation = null; if (this.isActive()) { - this.animation.increaseTime(); + updateAnimation = this.animation; } else if (this.isActive(animation.parent.currentClientAnimation)) { - this.currentClientAnimation.increaseTime(); + updateAnimation = this.currentClientAnimation; + } + + if (updateAnimation != null && updateAnimation.increaseTime()) { + Frame frame = (Frame) updateAnimation.currentFrame(); + if (frame != null) { + this.animatingTime += frame.customized ? frame.tickDuration : updateAnimation.tickDuration; + } } }