Added getAnimatingTime() function to AnimationData.

This commit is contained in:
luisc committed 2024-04-05 13:20:44 -05:00
1 parent 8b3571339b
commit 17c81c512f
2 files changed
+16 -5

No files matched your search

@@ -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)
@@ -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;
}
}
}