diff options
author | David Cole <40234707+DavidArthurCole@users.noreply.github.com> | 2024-07-15 13:56:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-15 19:56:21 +0200 |
commit | 9716ad9e545fb92918ecfab6dfe16f4179dbce09 (patch) | |
tree | 8a12d526b33fdfd18b7c1c455952878370803c78 /src/main/java/at | |
parent | ba091f8c3cfa665e83c789e1a5845d1ae0f26b6b (diff) | |
download | skyhanni-9716ad9e545fb92918ecfab6dfe16f4179dbce09.tar.gz skyhanni-9716ad9e545fb92918ecfab6dfe16f4179dbce09.tar.bz2 skyhanni-9716ad9e545fb92918ecfab6dfe16f4179dbce09.zip |
Fix: Farming ETA Duration "NaN" (#2217)
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt index a2ca09f15..60f665760 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt @@ -372,6 +372,9 @@ object FarmingWeightDisplay { private fun isEtaEnabled() = config.overtakeETA fun addCrop(crop: CropType, addedCounter: Int) { + //Prevent div-by-0 errors + if (addedCounter == 0) return; + val before = getExactWeight() localCounter[crop] = crop.getLocalCounter() + addedCounter val after = getExactWeight() @@ -384,7 +387,7 @@ object FarmingWeightDisplay { private fun updateWeightPerSecond(crop: CropType, before: Double, after: Double, diff: Int) { val speed = crop.getSpeed() ?: return val weightDiff = (after - before) * 1000 - weightPerSecond = weightDiff / diff * speed / 1000 + weightPerSecond = ((weightDiff / diff) * (speed / 1000)) } private fun getExactWeight(): Double { |