aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/garden
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-12 15:22:34 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-12 15:22:34 +0200
commit233b5d9b79afce09b830df22b89bc99180b5b991 (patch)
tree31c663e3c4d87f8197223a89bac31120c8acda84 /src/main/java/at/hannibal2/skyhanni/features/garden
parent82105f1f293268c739e0bdd0075e20a9d7218cfa (diff)
downloadskyhanni-233b5d9b79afce09b830df22b89bc99180b5b991.tar.gz
skyhanni-233b5d9b79afce09b830df22b89bc99180b5b991.tar.bz2
skyhanni-233b5d9b79afce09b830df22b89bc99180b5b991.zip
Time Format and Maxed Milestone options for Best Crop Time and Crop Milestones
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt39
2 files changed, 38 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt
index 10726fc44..360819e30 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt
@@ -9,13 +9,14 @@ import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest
import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.LorenzUtils.sorted
+import at.hannibal2.skyhanni.utils.TimeUnit
import at.hannibal2.skyhanni.utils.TimeUtils
class GardenBestCropTime {
var display = listOf<List<Any>>()
- private val config get() = SkyHanniMod.feature.garden
companion object {
+ private val config get() = SkyHanniMod.feature.garden
val timeTillNextCrop = mutableMapOf<CropType, Long>()
fun reset() {
@@ -32,7 +33,7 @@ class GardenBestCropTime {
val currentTier = GardenCropMilestones.getTierForCrops(counter)
val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier)
- val nextTier = currentTier + 1
+ val nextTier = if (config.cropMilestoneBestShowMaxedNeeded.get()) 46 else currentTier + 1
val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier)
val have = counter - cropsForCurrentTier
@@ -89,7 +90,8 @@ class GardenBestCropTime {
var number = 0
for (crop in sorted.keys) {
val millis = timeTillNextCrop[crop]!!
- val duration = TimeUtils.formatDuration(millis, maxUnits = 2)
+ val biggestUnit = TimeUnit.values()[config.cropMilestoneHighestTimeFormat.get()]
+ val duration = TimeUtils.formatDuration(millis, biggestUnit, maxUnits = 2)
val isCurrent = crop == currentCrop
number++
if (number > config.cropMilestoneShowOnlyBest && (!config.cropMilestoneShowCurrent || !isCurrent)) continue
@@ -102,10 +104,12 @@ class GardenBestCropTime {
val color = if (isCurrent) "§e" else "§7"
val contestFormat = if (GardenNextJacobContest.isNextCrop(crop)) "§n" else ""
- val nextTier = GardenCropMilestones.getTierForCrops(crop.getCounter()) + 1
+ val currentTier = GardenCropMilestones.getTierForCrops(crop.getCounter())
+ val nextTier = if (config.cropMilestoneBestShowMaxedNeeded.get()) 46 else currentTier + 1
+
val cropName = if (!config.cropMilestoneBestCompact) crop.cropName + " " else ""
- val cropNameDisplay = "$color$contestFormat$cropName$nextTier§r"
+ val cropNameDisplay = "$color$contestFormat$cropName$currentTier->$nextTier§r"
list.add("$cropNameDisplay §b$duration")
if (gardenExp && !config.cropMilestoneBestCompact) {
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 b2e63c497..de8d299fd 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
@@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.SoundUtils
+import at.hannibal2.skyhanni.utils.TimeUnit
import at.hannibal2.skyhanni.utils.TimeUtils
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -43,6 +44,17 @@ object GardenCropMilestoneDisplay {
}
@SubscribeEvent
+ fun onConfigLoad(event: ConfigLoadEvent) {
+ LorenzUtils.onToggle(
+ config.cropMilestoneBestShowMaxedNeeded,
+ config.cropMilestoneHighestTimeFormat,
+ ) {
+ GardenBestCropTime.updateTimeTillNextCrop()
+ update()
+ }
+ }
+
+ @SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
if (!isEnabled()) return
if (GardenAPI.hideExtraGuis()) return
@@ -126,7 +138,7 @@ object GardenCropMilestoneDisplay {
return
}
currentCrop?.let {
- progressDisplay = drawProgressDisplay(it, it.getCounter())
+ progressDisplay = drawProgressDisplay(it)
}
if (config.cropMilestoneBestDisplay) {
@@ -136,23 +148,28 @@ object GardenCropMilestoneDisplay {
}
}
- private fun drawProgressDisplay(crop: CropType, counter: Long): MutableList<List<Any>> {
+ private fun drawProgressDisplay(crop: CropType): MutableList<List<Any>> {
+ val counter = crop.getCounter()
val lineMap = HashMap<Int, List<Any>>()
lineMap[0] = Collections.singletonList("§6Crop Milestones")
val currentTier = GardenCropMilestones.getTierForCrops(counter)
- val nextTier = currentTier + 1
+ val nextTier = if (config.cropMilestoneBestShowMaxedNeeded.get()) 46 else currentTier + 1
val list = mutableListOf<Any>()
list.addCropIcon(crop)
- list.add("§7" + crop.cropName + " Tier $nextTier")
+ list.add("§7" + crop.cropName + " $currentTier->$nextTier")
lineMap[1] = list
- val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier)
val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier)
-
- val have = counter - cropsForCurrentTier
- val need = cropsForNextTier - cropsForCurrentTier
+ val (have, need) = if (config.cropMilestoneBestShowMaxedNeeded.get()) {
+ Pair(counter, cropsForNextTier)
+ } else {
+ val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier)
+ val have = counter - cropsForCurrentTier
+ val need = cropsForNextTier - cropsForCurrentTier
+ Pair(have, need)
+ }
val haveFormat = LorenzUtils.formatInteger(have)
val needFormat = LorenzUtils.formatInteger(need)
@@ -168,7 +185,8 @@ object GardenCropMilestoneDisplay {
val missingTimeSeconds = missing / farmingFortuneSpeed
val millis = missingTimeSeconds * 1000
GardenBestCropTime.timeTillNextCrop[crop] = millis
- val duration = TimeUtils.formatDuration(millis)
+ val biggestUnit = TimeUnit.values()[config.cropMilestoneHighestTimeFormat.get()]
+ val duration = TimeUtils.formatDuration(millis, biggestUnit)
if (config.cropMilestoneWarnClose) {
if (millis < 5_900) {
if (System.currentTimeMillis() > lastPlaySoundTime + 1_000) {
@@ -252,7 +270,8 @@ object GardenCropMilestoneDisplay {
val missingTimeSeconds = missing / blocksPerSecond
val millis = missingTimeSeconds * 1000
- val duration = TimeUtils.formatDuration(millis.toLong())
+ val biggestUnit = TimeUnit.values()[config.cropMilestoneHighestTimeFormat.get()]
+ val duration = TimeUtils.formatDuration(millis.toLong(), biggestUnit)
lineMap[3] = Collections.singletonList("§7In §b$duration")
}