From 70dfeb1e6b3f241731063d7014207b02b074bd8e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 12 Apr 2023 22:31:06 +0200 Subject: Added mayor election data and added Finnegan Farming Simulator support for crop milestone display --- .../skyhanni/features/garden/GardenCropMilestoneDisplay.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features') diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt index 18b408666..78f3bf836 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.setCounter +import at.hannibal2.skyhanni.data.MayorElectionData import at.hannibal2.skyhanni.data.SendTitleHelper import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.features.garden.CropType.Companion.getCropType @@ -25,6 +26,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.* import kotlin.concurrent.fixedRateTimer +import kotlin.random.Random class GardenCropMilestoneDisplay { private var progressDisplay = listOf>() @@ -127,7 +129,8 @@ class GardenCropMilestoneDisplay { val crop = item.getCropType() ?: return if (cultivatingData.containsKey(crop)) { val old = cultivatingData[crop]!! - val addedCounter = counter - old + val finneganPerkFactor = if (finneganPerkActive() && Random.nextDouble() <= 0.25) 0.5 else 1.0 + val addedCounter = ((counter - old) * finneganPerkFactor).toInt() if (GardenCropMilestones.cropCounter.isEmpty()) { for (innerCrop in CropType.values()) { @@ -154,6 +157,9 @@ class GardenCropMilestoneDisplay { } } + private fun finneganPerkActive() = + config.forcefullyEnabledAlwaysFinnegan || MayorElectionData.isPerkActive("Finnegan", "Farming Simulator") + @SubscribeEvent fun onBlockClick(event: BlockClickEvent) { if (!isEnabled()) return -- cgit