diff options
3 files changed, 24 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/optimalspeed/OptimalSpeedConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/optimalspeed/OptimalSpeedConfig.java index 6e44ecfec..e7a11de1f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/optimalspeed/OptimalSpeedConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/optimalspeed/OptimalSpeedConfig.java @@ -17,7 +17,7 @@ public class OptimalSpeedConfig { public boolean showOnHUD = false; @Expose - @ConfigOption(name = "Warning Title", desc = "Warn via title when you don't have the optimal speed.") + @ConfigOption(name = "Wrong Speed Warning", desc = "Warn via title and chat message when you don't have the optimal speed.") @ConfigEditorBoolean public boolean warning = false; diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt index 5eb89a138..337f64675 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt @@ -8,9 +8,13 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils +import at.hannibal2.skyhanni.utils.HypixelCommands +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isRancherSign +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SimpleTimeMark @@ -33,6 +37,7 @@ object GardenOptimalSpeed { private var sneakingTime = 0.seconds private val sneaking get() = Minecraft.getMinecraft().thePlayer.isSneaking private val sneakingPersistent get() = sneakingSince.passedSince() > 5.seconds + private val rancherBoots = "RANCHERS_BOOTS".asInternalName() /** * This speed value represents the walking speed, not the speed stat. @@ -175,21 +180,26 @@ object GardenOptimalSpeed { if (speed != currentSpeed && !recentlySwitchedTool && !recentlyStartedSneaking) warn(speed) } - private fun warn(speed: Int) { + private fun warn(optimalSpeed: Int) { if (!Minecraft.getMinecraft().thePlayer.onGround) return if (GardenAPI.onBarnPlot) return if (!config.warning) return + if (!GardenAPI.isCurrentlyFarming()) return + if (InventoryUtils.getBoots()?.getInternalNameOrNull() != rancherBoots) return if (lastWarnTime.passedSince() < 20.seconds) return lastWarnTime = SimpleTimeMark.now() LorenzUtils.sendTitle("§cWrong speed!", 3.seconds) - cropInHand?.let { - var text = "Wrong speed for ${it.cropName}: §f$currentSpeed" - if (sneaking) text += " §7[Sneaking]" - text += " §e(§f$speed §eis optimal)" - - ChatUtils.chat(text) - } + val cropInHand = cropInHand ?: return + + var text = "§cWrong speed while farming ${cropInHand.cropName} detected!" + text += "\n§eCurrent Speed: §f$currentSpeed§e, Optimal Speed: §f$optimalSpeed" + ChatUtils.clickToActionOrDisable( + text, + config::warning, + actionName = "change the speed", + action = { HypixelCommands.setMaxSpeed() }, + ) } private fun isRancherOverlayEnabled() = GardenAPI.inGarden() && config.signEnabled diff --git a/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt b/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt index a7fca2ce7..c788d019a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt @@ -136,6 +136,11 @@ object HypixelCommands { send("pq $quality") } + // Changes the speed of rancher boots in garden + fun setMaxSpeed() { + send("setmaxspeed") + } + fun showRng(major: String? = null, minor: String? = null) = when { major == null || minor == null -> send("rng") else -> send("rng $major $minor") |