Skip to content

Commit

Permalink
Merge branch '1.21' of https://github.com/FoundryMC/Veil into 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocelot5836 committed Nov 22, 2024
2 parents ece8f9f + d784d45 commit 429a143
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ public TimedAnimationEntry<P, T> addTimedAnimation(Animation<P, T> animation, in
return entry;
}

public void tick(P parent) {
public void tick() {
this.skeleton.tick();
this.skeleton.bones.forEach((name, bone) -> bone.reset());
this.animate(parent);
this.animate();
this.animations.forEach(animation -> animation.apply(this.parent, this.skeleton));
this.constraints.forEach(constraintEntry -> constraintEntry.constraint.apply());
this.animatePostConstraints(parent);
this.animatePostConstraints();
}
public void animate(P parent) {}
public void animatePostConstraints(P parent) {}
public void animate() {}
public void animatePostConstraints() {}

record ConstraintEntry(Constraint constraint, int priority) {}

Expand Down Expand Up @@ -89,13 +89,16 @@ private TimedAnimationEntry(Animation<P, T> animation, int priority, int lengthI
}

public void begin() { this.time = 0; this.resume(); }
public void resume() { this.playing = true; }
public void resume() {
if (!this.playing && this.time > this.lengthInTicks) this.time = 0; // restart an animation if it is past its length and resumed.
this.playing = true;
}
public void rewind() { this.rewinding = true; }
public void stop() { this.playing = false; this.rewinding = false; }

private void updateTime(P parent, T skeleton) {
if (this.playing && this.animation.running(parent, skeleton, mixFactor, time)) this.time += (this.rewinding ? -1.0F : 1.0F) / lengthInTicks;
if ((this.time > 1 && !rewinding) || (time < 0 && rewinding)) this.stop();
if (this.playing && this.animation.running(parent, skeleton, mixFactor, time)) this.time += (this.rewinding ? -1.0F : 1.0F);
if ((this.time > lengthInTicks && !rewinding) || (time < 0 && rewinding)) this.stop();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class LevelRendererMixin {
if (this.level == null) return;
for (Entity entity : this.level.entitiesForRendering()) {
if (entity instanceof SkeletonParent parent) {
if (parent.getAnimator() != null) parent.getAnimator().tick(parent);
if (parent.getAnimator() != null) parent.getAnimator().tick();
}
}
}
Expand Down

0 comments on commit 429a143

Please sign in to comment.