From 9716ad9e545fb92918ecfab6dfe16f4179dbce09 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:56:21 -0400 Subject: Fix: Farming ETA Duration "NaN" (#2217) --- .../skyhanni/features/garden/farming/FarmingWeightDisplay.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/main/java/at') 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 { -- cgit