diff options
8 files changed, 65 insertions, 33 deletions
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<String>) -> 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<CropType, Int> 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<String, Int>() } - private var display = mutableListOf<List<Any>>() + private var display = listOf<List<Any>>() 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<List<Any>> { + private fun drawDisplay(): List<List<Any>> { val newDisplay = mutableListOf<List<Any>>() 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<List<Any>>() - val timeTillNextCrop = mutableMapOf<CropType, Long>() private val config get() = SkyHanniMod.feature.garden + companion object { + val timeTillNextCrop = mutableMapOf<CropType, Long>() + + 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<List<Any>> { val newList = mutableListOf<List<Any>>() 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) + } } } |