aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-22 02:47:10 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-22 02:47:10 +0200
commita466b61b6bad9d884ed0fa20d30334a840455e33 (patch)
tree0bd0e83839dcca263a2380596d29fce4b69202fc /src/main/java/at/hannibal2/skyhanni/features
parente82ae67285539475a33f2942ed6c3b35d7ad65fe (diff)
downloadskyhanni-a466b61b6bad9d884ed0fa20d30334a840455e33.tar.gz
skyhanni-a466b61b6bad9d884ed0fa20d30334a840455e33.tar.bz2
skyhanni-a466b61b6bad9d884ed0fa20d30334a840455e33.zip
Using farming fortune to calculate more exact next crop milestone ETA that does not bounce around
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt46
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt5
2 files changed, 31 insertions, 20 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
index 22e330281..1f2f32115 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
@@ -26,22 +26,11 @@ import kotlin.math.floor
import kotlin.math.log10
class FarmingFortuneDisplay {
- private val config get() = SkyHanniMod.feature.garden
private val tabFortunePattern = " Farming Fortune: §r§6☘(\\d+)".toRegex()
private var display = listOf<List<Any>>()
private var accessoryProgressDisplay = ""
- private var currentCrop: CropType? = null
-
- private var tabFortune: Double = 0.0
- private var toolFortune: Double = 0.0
- private val baseFortune: Double get() = if (config.farmingFortuneDropMultiplier) 100.0 else 0.0
- private val upgradeFortune: Double? get() = currentCrop?.getUpgradeLevel()?.let { it * 5.0 }
- private val accessoryFortune: Double?
- get() = currentCrop?.let {
- CropAccessoryData.cropAccessory?.getFortune(it)
- }
private var lastToolSwitch: Long = 0
private var ticks: Int = 0
@@ -89,7 +78,10 @@ class FarmingFortuneDisplay {
fun onRenderOverlay(event: GuiRenderEvent.ChestBackgroundRenderEvent) {
if (!isEnabled()) return
if (!CropAccessoryData.isLoadingAccessories) return
- SkyHanniMod.feature.misc.inventoryLoadPos.renderString(accessoryProgressDisplay, posLabel = "Load Accessory Bags")
+ SkyHanniMod.feature.misc.inventoryLoadPos.renderString(
+ accessoryProgressDisplay,
+ posLabel = "Load Accessory Bags"
+ )
}
@SubscribeEvent
@@ -103,14 +95,12 @@ class FarmingFortuneDisplay {
val recentlySwitchedTool = System.currentTimeMillis() < lastToolSwitch + 1000
it.add(
"§6Farming Fortune§7: §e" + if (!recentlySwitchedTool) {
- val upgradeFortune = upgradeFortune ?: 0.0
- val accessoryFortune = accessoryFortune ?: 0.0
- val totalFortune = baseFortune + upgradeFortune + tabFortune + toolFortune + accessoryFortune
- LorenzUtils.formatDouble(totalFortune, 0)
- } else "?")
+ LorenzUtils.formatDouble(getCurrentFarmingFortune(), 0)
+ } else "?"
+ )
})
- if (this.upgradeFortune == null) {
+ if (upgradeFortune == null) {
updatedDisplay.addAsSingletonList("§cOpen §e/cropupgrades§c for more exact data!")
}
if (accessoryFortune == null) {
@@ -139,8 +129,20 @@ class FarmingFortuneDisplay {
companion object {
- private val collectionPattern = "§7You have §6\\+([\\d]{1,3})☘ Farming Fortune".toRegex()
+ private val config get() = SkyHanniMod.feature.garden
+
+ private var currentCrop: CropType? = null
+ private var tabFortune: Double = 0.0
+ private var toolFortune: Double = 0.0
+ private val baseFortune: Double get() = if (config.farmingFortuneDropMultiplier) 100.0 else 0.0
+ private val upgradeFortune: Double? get() = currentCrop?.getUpgradeLevel()?.let { it * 5.0 }
+ private val accessoryFortune: Double?
+ get() = currentCrop?.let {
+ CropAccessoryData.cropAccessory?.getFortune(it)
+ }
+
+ private val collectionPattern = "§7You have §6\\+([\\d]{1,3})☘ Farming Fortune".toRegex()
fun getToolFortune(tool: ItemStack?): Double {
val internalName = tool?.getInternalName() ?: return 0.0
@@ -184,6 +186,12 @@ class FarmingFortuneDisplay {
return dedicationMultiplier * cropMilestone
}
+ fun getCurrentFarmingFortune(alwaysBaseFortune: Boolean = false): Double {
+ val upgradeFortune = upgradeFortune ?: 0.0
+ val accessoryFortune = accessoryFortune ?: 0.0
+ val baseFortune = if (alwaysBaseFortune) 100.0 else baseFortune
+ return baseFortune + upgradeFortune + tabFortune + toolFortune + accessoryFortune
+ }
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt
index 48947d823..ab811b586 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt
@@ -279,10 +279,13 @@ class GardenCropMilestoneDisplay {
}
}
+ val farmingFortune = FarmingFortuneDisplay.getCurrentFarmingFortune(true)
+ val farmingFortuneSpeed = farmingFortune * crop.baseDrops * crop.multiplier * 20 / 100
+
if (averageSpeedPerSecond != 0) {
crop.setSpeed(averageSpeedPerSecond)
val missing = need - have
- val missingTimeSeconds = missing / averageSpeedPerSecond
+ val missingTimeSeconds = missing / farmingFortuneSpeed.toInt()
val millis = missingTimeSeconds * 1000
bestCropTime.timeTillNextCrop[crop] = millis
val duration = TimeUtils.formatDuration(millis)