diff options
| author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-10-16 15:50:41 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-16 15:50:41 -0400 |
| commit | 7c00af18febf6c0b833c7633b4fb60a9a1bb93af (patch) | |
| tree | f02de145362d6a1399651ade4a130d565d7f0ba3 /src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java | |
| parent | b11742988dec635b5c5da7c2363803cbfafb37b1 (diff) | |
| download | notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.tar.gz notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.tar.bz2 notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.zip | |
Code Clean Up (#2)
* intellij code clean up
* optimize imports
* format
* intellij suggestions
* fix empty catch issues
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java b/src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java index 83fa1a6d..e66e0edb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java @@ -4,7 +4,7 @@ public class LerpingFloat { private int timeSpent; private long lastMillis; - private int timeToReachTarget; + private final int timeToReachTarget; private float targetValue; private float lerpValue; @@ -22,23 +22,23 @@ public class LerpingFloat { int lastTimeSpent = timeSpent; this.timeSpent += System.currentTimeMillis() - lastMillis; - float lastDistPercentToTarget = lastTimeSpent/(float)timeToReachTarget; - float distPercentToTarget = timeSpent/(float)timeToReachTarget; - float fac = (1-lastDistPercentToTarget)/lastDistPercentToTarget; + float lastDistPercentToTarget = lastTimeSpent / (float) timeToReachTarget; + float distPercentToTarget = timeSpent / (float) timeToReachTarget; + float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget; - float startValue = lerpValue - (targetValue - lerpValue)/fac; + float startValue = lerpValue - (targetValue - lerpValue) / fac; float dist = targetValue - startValue; - if(dist == 0) return; + if (dist == 0) return; float oldLerpValue = lerpValue; - if(distPercentToTarget >= 1) { + if (distPercentToTarget >= 1) { lerpValue = targetValue; } else { - lerpValue = startValue + dist*distPercentToTarget; + lerpValue = startValue + dist * distPercentToTarget; } - if(lerpValue == oldLerpValue) { + if (lerpValue == oldLerpValue) { timeSpent = lastTimeSpent; } else { this.lastMillis = System.currentTimeMillis(); |
