aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/garden
diff options
context:
space:
mode:
authorDavid Cole <40234707+DavidArthurCole@users.noreply.github.com>2024-07-15 13:56:21 -0400
committerGitHub <noreply@github.com>2024-07-15 19:56:21 +0200
commit9716ad9e545fb92918ecfab6dfe16f4179dbce09 (patch)
tree8a12d526b33fdfd18b7c1c455952878370803c78 /src/main/java/at/hannibal2/skyhanni/features/garden
parentba091f8c3cfa665e83c789e1a5845d1ae0f26b6b (diff)
downloadskyhanni-9716ad9e545fb92918ecfab6dfe16f4179dbce09.tar.gz
skyhanni-9716ad9e545fb92918ecfab6dfe16f4179dbce09.tar.bz2
skyhanni-9716ad9e545fb92918ecfab6dfe16f4179dbce09.zip
Fix: Farming ETA Duration "NaN" (#2217)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt5
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 {