From c630877d373f1e2313cd2fa78df7130dff3d7382 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 26 Apr 2023 13:21:30 +0200 Subject: Added command /shclearcropspeed - Manually reset all crop speed data. --- .../hannibal2/skyhanni/config/commands/Commands.kt | 2 + .../skyhanni/features/garden/GardenAPI.kt | 18 +++++++- .../features/garden/farming/CropMoneyDisplay.kt | 11 ++--- .../features/garden/farming/GardenBestCropTime.kt | 54 +++++++++++++--------- .../farming/GardenBurrowingSporesNotifier.kt | 2 + .../garden/farming/GardenCropMilestoneDisplay.kt | 4 +- .../farming/WildStrawberryDyeNotification.kt | 3 ++ .../garden/visitor/GardenVisitorFeatures.kt | 4 ++ 8 files changed, 65 insertions(+), 33 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 986ad0405..452b038e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.data.GuiEditManager import at.hannibal2.skyhanni.features.bingo.BingoCardDisplay import at.hannibal2.skyhanni.features.bingo.BingoNextStepHelper import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper +import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenCropTimeCommand import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay import at.hannibal2.skyhanni.features.garden.farming.CropSpeedMeter @@ -59,6 +60,7 @@ object Commands { registerCommand("shcropspeedmeter") { CropSpeedMeter.toggle() } registerCommand("shcroptime") { GardenCropTimeCommand.onCommand(it) } registerCommand("shtestcomposter") { ComposterOverlay.onCommand(it) } + registerCommand("shclearcropspeed") { GardenAPI.clearCropSpeed() } } private fun registerCommand(name: String, function: (Array) -> Unit) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index 46f7c1fe1..fb00e729f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay +import at.hannibal2.skyhanni.features.garden.farming.GardenBestCropTime import at.hannibal2.skyhanni.features.garden.inventory.SkyMartCopperPrice import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils @@ -21,6 +22,7 @@ object GardenAPI { private val cropsPerSecond: MutableMap get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond var toolInHand: String? = null + var itemInHand: ItemStack? = null var cropInHand: CropType? = null var mushroomCowPet = false var onBarnPlot = false @@ -61,6 +63,10 @@ object GardenAPI { } } + private fun updateGardenTool() { + GardenToolChangeEvent(cropInHand, itemInHand).postAndCatch() + } + private fun checkItemInHand() { val toolItem = Minecraft.getMinecraft().thePlayer.heldItem val crop = toolItem?.getCropType() @@ -68,7 +74,8 @@ object GardenAPI { if (toolInHand != newTool) { toolInHand = newTool cropInHand = crop - GardenToolChangeEvent(crop, toolItem).postAndCatch() + itemInHand = toolItem + updateGardenTool() } } @@ -137,4 +144,13 @@ object GardenAPI { fun isSpeedDataEmpty() = cropsPerSecond.values.sum() < 0 fun hideExtraGuis() = ComposterOverlay.inInventory || AnitaMedalProfit.inInventory || SkyMartCopperPrice.inInventory + + fun clearCropSpeed() { + for (type in CropType.values()) { + type.setSpeed(-1) + } + GardenBestCropTime.reset() + updateGardenTool() + LorenzUtils.chat("§e[SkyHanni] Manually reset all crop speed data!") + } } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt index 1181170d0..7a35c8ab4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt @@ -30,7 +30,7 @@ class CropMoneyDisplay { var multipliers = mapOf() } - private var display = mutableListOf>() + private var display = listOf>() private val config get() = SkyHanniMod.feature.garden private var tick = 0 private var loaded = false @@ -69,7 +69,7 @@ class CropMoneyDisplay { display = drawDisplay() } - private fun drawDisplay(): MutableList> { + private fun drawDisplay(): List> { val newDisplay = mutableListOf>() val title = if (config.moneyPerHourCompact) { @@ -86,9 +86,7 @@ class CropMoneyDisplay { if (!hasCropInHand && !config.moneyPerHourAlwaysOn) return newDisplay - if (!config.moneyPerHourHideTitle) { - newDisplay.addAsSingletonList(fullTitle(title)) - } + newDisplay.addAsSingletonList(fullTitle(title)) if (!config.cropMilestoneProgress) { newDisplay.addAsSingletonList("§cCrop Milestone Progress Display is disabled!") @@ -170,8 +168,7 @@ class CropMoneyDisplay { newDisplay.add(list) } - - return newDisplay + return if (config.moneyPerHourHideTitle) newDisplay.drop(1) else newDisplay } private fun fullTitle(title: String): String { 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 23ea2e33b..29e7411e5 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 @@ -13,9 +13,39 @@ import at.hannibal2.skyhanni.utils.TimeUtils class GardenBestCropTime { var display = listOf>() - val timeTillNextCrop = mutableMapOf() private val config get() = SkyHanniMod.feature.garden + companion object { + val timeTillNextCrop = mutableMapOf() + + fun reset() { + timeTillNextCrop.clear() + updateTimeTillNextCrop() + } + + fun updateTimeTillNextCrop() { + for (crop in CropType.values()) { + val speed = crop.getSpeed() + if (speed == -1) continue + + val counter = crop.getCounter() + val currentTier = GardenCropMilestones.getTierForCrops(counter) + + val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier) + val nextTier = currentTier + 1 + val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier) + + val have = counter - cropsForCurrentTier + val need = cropsForNextTier - cropsForCurrentTier + + val missing = need - have + val missingTimeSeconds = missing / speed + val millis = missingTimeSeconds * 1000 + timeTillNextCrop[crop] = millis + } + } + } + fun drawBestDisplay(currentCrop: CropType?): List> { val newList = mutableListOf>() if (timeTillNextCrop.size < CropType.values().size) { @@ -88,26 +118,4 @@ class GardenBestCropTime { } private fun getGardenExpForTier(gardenLevel: Int) = if (gardenLevel > 30) 300 else gardenLevel * 10 - - fun updateTimeTillNextCrop() { - for (crop in CropType.values()) { - val speed = crop.getSpeed() - if (speed == -1) continue - - val counter = crop.getCounter() - val currentTier = GardenCropMilestones.getTierForCrops(counter) - - val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier) - val nextTier = currentTier + 1 - val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier) - - val have = counter - cropsForCurrentTier - val need = cropsForNextTier - cropsForCurrentTier - - val missing = need - have - val missingTimeSeconds = missing / speed - val millis = missingTimeSeconds * 1000 - timeTillNextCrop[crop] = millis - } - } } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBurrowingSporesNotifier.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBurrowingSporesNotifier.kt index 0d91abe60..73d5bcaea 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBurrowingSporesNotifier.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBurrowingSporesNotifier.kt @@ -15,6 +15,8 @@ class GardenBurrowingSporesNotifier { if (event.message.endsWith("§6§lVERY RARE CROP! §r§f§r§9Burrowing Spores")) { TitleUtils.sendTitle("§9Burrowing Spores!", 5_000) + // would be sent too often, nothing special then +// ItemBlink.setBlink(NEUItems.getItemStackOrNull("BURROWING_SPORES"), 5_000) } } } \ 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 02172ac8e..6e7cd2014 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 @@ -80,7 +80,7 @@ class GardenCropMilestoneDisplay { @SubscribeEvent fun onCropMilestoneUpdate(event: CropMilestoneUpdateEvent) { needsInventory = false - bestCropTime.updateTimeTillNextCrop() + GardenBestCropTime.updateTimeTillNextCrop() update() } @@ -276,7 +276,7 @@ class GardenCropMilestoneDisplay { val missing = need - have val missingTimeSeconds = missing / farmingFortuneSpeed val millis = missingTimeSeconds * 1000 - bestCropTime.timeTillNextCrop[crop] = millis + GardenBestCropTime.timeTillNextCrop[crop] = millis val duration = TimeUtils.formatDuration(millis) if (config.cropMilestoneWarnClose) { if (millis < 5_900) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt index cc86819a6..507aa229b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt @@ -5,9 +5,11 @@ import at.hannibal2.skyhanni.data.TitleUtils import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.OwnInventorItemUpdateEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.utils.ItemBlink import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.SoundUtils import io.github.moulberry.notenoughupdates.util.MinecraftExecutor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -37,6 +39,7 @@ class WildStrawberryDyeNotification { TitleUtils.sendTitle(name, 5_000) LorenzUtils.chat("§e[SkyHanni] You found a $name§e!") SoundUtils.playBeepSound() + ItemBlink.setBlink(NEUItems.getItemStackOrNull("DYE_WILD_STRAWBERRY"), 5_000) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt index 33c4b0e5a..4025fa9a0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt @@ -433,6 +433,10 @@ class GardenVisitorFeatures { logger.log("Jerry!") ItemBlink.setBlink(NEUItems.getItemStackOrNull("JERRY;4"), 5_000) } + if (name.removeColor().contains("Spaceman")) { + logger.log("Spaceman!") + ItemBlink.setBlink(NEUItems.getItemStackOrNull("DCTR_SPACE_HELM"), 5_000) + } } } -- cgit