diff options
Diffstat (limited to 'src')
4 files changed, 58 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java index 6deb9876d..0115b956b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java @@ -46,6 +46,12 @@ public class Hidden { public Map<CropType, Integer> gardenCropsPerSecond = new HashMap<>(); @Expose + public Map<CropType, Double> gardenLatestBlocksPerSecond = new HashMap<>(); + + @Expose + public Map<CropType, Double> gardenLatestTrueFarmingFortune = new HashMap<>(); + + @Expose public int gardenExp = -1; @Expose 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 ae1c61564..65b92f8d2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -25,7 +25,6 @@ import kotlin.math.floor import kotlin.math.log10 class FarmingFortuneDisplay { - private val tabFortunePattern = " Farming Fortune: §r§6☘(\\d+)".toRegex() private var display = listOf<List<Any>>() @@ -96,6 +95,9 @@ class FarmingFortuneDisplay { LorenzUtils.formatDouble(getCurrentFarmingFortune(), 0) } else "?" ) + if (GardenAPI.toolInHand != null) { + latestTrueFarmingFortune[displayCrop] = getCurrentFarmingFortune(true) + } }) if (upgradeFortune == null) { @@ -128,6 +130,8 @@ class FarmingFortuneDisplay { companion object { private val config get() = SkyHanniMod.feature.garden + private val hidden get() = SkyHanniMod.feature.hidden + private val latestTrueFarmingFortune: MutableMap<CropType, Double> get() = hidden.gardenLatestTrueFarmingFortune private var currentCrop: CropType? = null @@ -191,5 +195,7 @@ class FarmingFortuneDisplay { val baseFortune = if (alwaysBaseFortune) 100.0 else baseFortune return baseFortune + upgradeFortune + tabFortune + toolFortune + accessoryFortune } + + fun CropType.getLatestTrueFarmingFortune() = latestTrueFarmingFortune[this] } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt index e80c0a03f..2528cf1dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt @@ -5,10 +5,13 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.RenderItemTooltipEvent import at.hannibal2.skyhanni.features.garden.CropType +import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay.Companion.getLatestTrueFarmingFortune +import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getLatestBlocksPerSecond import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems @@ -56,24 +59,54 @@ class JacobContestFFNeededDisplay { addAsSingletonList("") val crop = contest.crop - add(listOf("For this ", crop.icon, "${crop.cropName} contest:")) + add(listOf("§7For this ", crop.icon, "§7${crop.cropName} contest:")) for (rank in ContestRank.values()) { addAsSingletonList(getLine(rank, contest.ranks, crop)) } addAsSingletonList("") val (size, averages) = calculateAverages(crop) - add(listOf("For the last $size ", crop.icon, "${crop.cropName} contests:")) + add(listOf("§7For the last §e$size ", crop.icon, "§7${crop.cropName} contests:")) for (rank in ContestRank.values()) { addAsSingletonList(getLine(rank, averages, crop)) } + addAsSingletonList("") + + val blocksPerSecond = crop.getLatestBlocksPerSecond() + if (blocksPerSecond == null) { + add(listOf("§cNo ", crop.icon, "§cblocks/second data,")) + addAsSingletonList("§cassuming 20.") + } else { + add(listOf("§7Using latest ", crop.icon, "§7blocks/second: §e${blocksPerSecond.round(2)}")) + } + addAsSingletonList("") + + val trueFF = crop.getLatestTrueFarmingFortune() + if (trueFF == null) { + addAsSingletonList("§cNo latest true FF saved!") + } else { + val farmingFortune = formatFarmingFortune(trueFF) + add(listOf("§6Your ", crop.icon, "§6FF: $farmingFortune")) + } + } + + private fun formatFarmingFortune(farmingFortune: Double): String { + var ff = farmingFortune + if (!config.farmingFortuneDropMultiplier) { + ff -= 100 + if (ff < 100) { + ff = 0.0 + } + } + return ceil(ff).addSeparators() } private fun getLine(rank: ContestRank, map: Map<ContestRank, Int>, crop: CropType): String { val counter = map[rank]!! - val cropsPerSecond = counter.toDouble() / 20 / 60 - val farmingFortune = ceil(cropsPerSecond * 100 / 20 / crop.baseDrops) - return " ${rank.displayName}§f: §6${farmingFortune.addSeparators()} FF §7(${counter.addSeparators()} crops)" + val blocksPerSecond = crop.getLatestBlocksPerSecond() ?: 20.0 + val cropsPerSecond = counter.toDouble() / blocksPerSecond / 60 + val farmingFortune = formatFarmingFortune(cropsPerSecond * 100 / 20 / crop.baseDrops) + return " ${rank.displayName}§f: §6$farmingFortune FF §7(${counter.addSeparators()} crops)" } private fun calculateAverages(crop: CropType): Pair<Int, Map<ContestRank, Int>> { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt index 41c743289..9cf1d20e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt @@ -20,7 +20,7 @@ object GardenCropSpeed { private val config get() = SkyHanniMod.feature.garden private val hidden get() = SkyHanniMod.feature.hidden private val cropsPerSecond: MutableMap<CropType, Int> get() = hidden.gardenCropsPerSecond - + private val latestBlocksPerSecond: MutableMap<CropType, Double> get() = hidden.gardenLatestBlocksPerSecond var lastBrokenCrop: CropType? = null var averageBlocksPerSecond = 0.0 @@ -78,6 +78,10 @@ object GardenCropSpeed { blocksSpeedList.removeFirst() } averageBlocksPerSecond = blocksSpeedList.average() + GardenAPI.getCurrentlyFarmedCrop()?.let { + latestBlocksPerSecond[it] = averageBlocksPerSecond + } + } lastBlocksBroken = blocksBroken @@ -121,5 +125,7 @@ object GardenCropSpeed { cropsPerSecond[this] = speed } + fun CropType.getLatestBlocksPerSecond() = latestBlocksPerSecond[this] + fun isSpeedDataEmpty() = cropsPerSecond.values.sum() < 0 }
\ No newline at end of file |