Skip to content

Commit 2197068

Browse files
authored
Animation controller fixes (#77)
1 parent c3631b2 commit 2197068

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

core/src/main/java/com/zigythebird/playeranimcore/animation/AnimationController.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -865,20 +865,28 @@ public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
865865
return IAnimation.DEFAULT_FIRST_PERSON_CONFIG;
866866
}
867867

868-
public void setFirstPersonMode(FirstPersonMode mode) {
868+
public AnimationController setFirstPersonMode(FirstPersonMode mode) {
869869
firstPersonMode = (controller) -> mode;
870+
871+
return this;
870872
}
871873

872-
public void setFirstPersonModeHandler(Function<AnimationController, FirstPersonMode> modeHandler) {
874+
public AnimationController setFirstPersonModeHandler(Function<AnimationController, FirstPersonMode> modeHandler) {
873875
firstPersonMode = modeHandler;
876+
877+
return this;
874878
}
875879

876-
public void setFirstPersonConfiguration(FirstPersonConfiguration config) {
880+
public AnimationController setFirstPersonConfiguration(FirstPersonConfiguration config) {
877881
firstPersonConfiguration = (controller) -> config;
882+
883+
return this;
878884
}
879885

880-
public void setFirstPersonConfigurationHandler(Function<AnimationController, FirstPersonConfiguration> configHandler) {
886+
public AnimationController setFirstPersonConfigurationHandler(Function<AnimationController, FirstPersonConfiguration> configHandler) {
881887
firstPersonConfiguration = configHandler;
888+
889+
return this;
882890
}
883891

884892
@Override
@@ -890,7 +898,12 @@ public void tick(AnimationData state) {
890898
}
891899
if (!modifiers.isEmpty())
892900
modifiers.getFirst().tick(state);
893-
else if (this.animationState == State.RUNNING) tick += 1;
901+
else {
902+
handleAnimation(state);
903+
if (this.animationState == State.RUNNING) {
904+
tick += 1;
905+
}
906+
}
894907
}
895908

896909
@Override
@@ -1042,6 +1055,7 @@ private InternalAnimationAccessor(AnimationController controller) {
10421055

10431056
@Override
10441057
public void tick(AnimationData state) {
1058+
this.anim.handleAnimation(state);
10451059
if (this.anim.animationState == State.RUNNING) this.anim.tick += 1;
10461060
}
10471061

core/src/main/java/com/zigythebird/playeranimcore/animation/HumanoidAnimationController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ public void process(AnimationData state) {
110110
this.torsoBend = bones.get("torso").getBend();
111111
float absBend = Math.abs(this.torsoBend);
112112
if (absBend > 0.001 && (this.currentAnimation != null && this.currentAnimation.animation().data().getNullable(ExtraAnimationData.APPLY_BEND_TO_OTHER_BONES_KEY) == Boolean.TRUE)) {
113-
this.torsoBendSign = (int) MochaMath.sign(this.torsoBend);
114-
this.torsoBendYPosMultiplier = -(1 - MochaMath.cos(absBend));
115-
this.torsoBendZPosMultiplier = 1 - MochaMath.sin(absBend);
113+
this.torsoBendSign = (int) Math.signum(this.torsoBend);
114+
this.torsoBendYPosMultiplier = (float) -(1 - Math.cos(absBend));
115+
this.torsoBendZPosMultiplier = (float) (1 - Math.sin(absBend));
116116
} else this.torsoBendSign = 0;
117117
}
118118

0 commit comments

Comments
 (0)