diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/LinearTransitionMode.java b/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/LinearTransitionMode.java index 074ecb1d..db681241 100644 --- a/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/LinearTransitionMode.java +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/LinearTransitionMode.java @@ -7,7 +7,6 @@ public class LinearTransitionMode implements TransitionMode { private boolean active; private final double minimumLinearStep; private final double maximumLinearStep; - private float fovMultiplier; private float internalMultiplier; private float lastInternalMultiplier; private float internalFade; @@ -25,13 +24,12 @@ public LinearTransitionMode(double minimumLinearStep, double maximumLinearStep) @Override public boolean getActive() { - return this.active; + return this.active || this.internalMultiplier != 1.0F || this.internalFade != 1.0F; } @Override public float applyZoom(float fov, float tickDelta) { - fovMultiplier = Mth.lerp(tickDelta, this.lastInternalMultiplier, this.internalMultiplier); - return fov * fovMultiplier; + return fov * Mth.lerp(tickDelta, this.lastInternalMultiplier, this.internalMultiplier); } @Override @@ -51,9 +49,7 @@ public void tick(boolean active, double divisor) { this.internalMultiplier = Mth.approach(this.internalMultiplier, (float) zoomMultiplier, (float) linearStep); this.internalFade = Mth.approach(this.internalFade, (float) fadeMultiplier, (float) linearStep); - if (active || fovMultiplier == this.internalMultiplier) { - this.active = active; - } + this.active = active; } @Override diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/SmoothTransitionMode.java b/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/SmoothTransitionMode.java index f4f831a4..9ea95b11 100644 --- a/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/SmoothTransitionMode.java +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/SmoothTransitionMode.java @@ -5,7 +5,6 @@ public class SmoothTransitionMode implements TransitionMode { private boolean active; private final float smoothMultiplier; - private float fovMultiplier; private float internalMultiplier; private float lastInternalMultiplier; private float internalFade; @@ -26,13 +25,12 @@ public SmoothTransitionMode() { @Override public boolean getActive() { - return this.active; + return this.active || this.internalMultiplier != 1.0F || this.internalFade != 1.0F; } @Override public float applyZoom(float fov, float tickDelta) { - fovMultiplier = Mth.lerp(tickDelta, this.lastInternalMultiplier, this.internalMultiplier); - return fov * fovMultiplier; + return fov * Mth.lerp(tickDelta, this.lastInternalMultiplier, this.internalMultiplier); } @Override @@ -42,18 +40,16 @@ public float getFade(float tickDelta) { @Override public void tick(boolean active, double divisor) { - double zoomMultiplier = 1.0 / divisor; - double fadeMultiplier = active ? 1.0 : 0.0; + float zoomMultiplier = (float) (1.0 / divisor); + float fadeMultiplier = active ? 1.0F : 0.0F; this.lastInternalMultiplier = this.internalMultiplier; this.lastInternalFade = this.internalFade; - this.internalMultiplier += (float) ((zoomMultiplier - this.internalMultiplier) * this.smoothMultiplier); - this.internalFade += (float) ((fadeMultiplier - this.internalFade) * this.smoothMultiplier); + this.internalMultiplier += (zoomMultiplier - this.internalMultiplier) * this.smoothMultiplier; + this.internalFade += (fadeMultiplier - this.internalFade) * this.smoothMultiplier; - if (active || fovMultiplier == this.internalMultiplier) { - this.active = active; - } + this.active = active; } @Override