diff options
4 files changed, 45 insertions, 23 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java index 856ba0d05..a88e79023 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java @@ -89,6 +89,12 @@ public class ChocolateFactoryConfig { public boolean extraTooltipStats = true; @Expose + @ConfigOption(name = "Duplicate Rabbit Time", desc = "Show the production time of chocolate gained from duplicate rabbits.") + @ConfigEditorBoolean + @FeatureToggle + public boolean showDuplicateTime = false; + + @Expose @ConfigOption(name = "Time Tower Warning", desc = "Notification when you have a new time tower usage available and " + "continuously warn when your time tower is full.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt index 9351dac40..053af704b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt @@ -25,29 +25,9 @@ enum class ChocolateAmount(val chocolate: () -> Long) { } fun timeUntilGoal(goal: Long): Duration { - val profileStorage = ChocolateFactoryAPI.profileStorage ?: return Duration.ZERO - + val profileStorage = profileStorage ?: return Duration.ZERO val updatedAgo = SimpleTimeMark(profileStorage.lastDataSave).passedSince().inWholeSeconds - - val baseMultiplier = profileStorage.rawChocolateMultiplier - val rawChocolatePerSecond = profileStorage.rawChocPerSecond - val timeTowerMultiplier = baseMultiplier + profileStorage.timeTowerLevel * 0.1 - - if (rawChocolatePerSecond == 0) return Duration.INFINITE - - var needed = goal - chocolate() - val secondsUntilTowerExpires = ChocolateFactoryTimeTowerManager.timeTowerActiveDuration().inWholeSeconds - - val timeTowerChocPerSecond = rawChocolatePerSecond * timeTowerMultiplier - - val secondsAtRate = needed / timeTowerChocPerSecond - if (secondsAtRate < secondsUntilTowerExpires) { - return secondsAtRate.seconds - updatedAgo.seconds - } - - needed -= (secondsUntilTowerExpires * timeTowerChocPerSecond).toLong() - val basePerSecond = rawChocolatePerSecond * baseMultiplier - return (needed / basePerSecond + secondsUntilTowerExpires).seconds - updatedAgo.seconds + return ChocolateFactoryAPI.timeUntilNeed(goal - chocolate()) - updatedAgo.seconds } companion object { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt index c9fa506b3..7418f3b39 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.formatLong +import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SkyblockSeason import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches @@ -20,6 +21,8 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.UtilsPatterns import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration +import kotlin.time.Duration.Companion.seconds object ChocolateFactoryAPI { @@ -142,4 +145,30 @@ object ChocolateFactoryAPI { fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled fun isHoppityEvent() = SkyblockSeason.getCurrentSeason() == SkyblockSeason.SPRING + + fun timeUntilNeed(goal: Long): Duration { + var needed = goal + val profileStorage = profileStorage ?: return Duration.ZERO + + val updatedAgo = SimpleTimeMark(profileStorage.lastDataSave).passedSince().inWholeSeconds + + val baseMultiplier = profileStorage.rawChocolateMultiplier + val rawChocolatePerSecond = profileStorage.rawChocPerSecond + val timeTowerMultiplier = baseMultiplier + profileStorage.timeTowerLevel * 0.1 + + if (rawChocolatePerSecond == 0) return Duration.INFINITE + + val secondsUntilTowerExpires = ChocolateFactoryTimeTowerManager.timeTowerActiveDuration().inWholeSeconds + + val timeTowerChocPerSecond = rawChocolatePerSecond * timeTowerMultiplier + + val secondsAtRate = needed / timeTowerChocPerSecond + if (secondsAtRate < secondsUntilTowerExpires) { + return secondsAtRate.seconds - updatedAgo.seconds + } + + needed -= (secondsUntilTowerExpires * timeTowerChocPerSecond).toLong() + val basePerSecond = rawChocolatePerSecond * baseMultiplier + return (needed / basePerSecond + secondsUntilTowerExpires).seconds + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt index 5d0a5c817..2d49fce3e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -50,7 +51,13 @@ object ChocolateFactoryBarnManager { rabbitDuplicatePattern.matchMatcher(event.message) { HoppityEggsManager.shareWaypointPrompt() - ChocolateAmount.addToAll(group("amount").formatLong()) + val amount = group("amount").formatLong() + if (config.showDuplicateTime) { + val format = ChocolateFactoryAPI.timeUntilNeed(amount).format(maxUnits = 2) + event.chatComponent.appendText("\n§7(§a+§b$format §aof production§7)") + ChocolateAmount.averageChocPerSecond() + } + ChocolateAmount.addToAll(amount) } rabbitCrashedPattern.matchMatcher(event.message) { |