aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-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 {