aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorAlexia Luna <me@alexia.lol>2024-03-26 18:14:23 +0100
committerGitHub <noreply@github.com>2024-03-26 18:14:23 +0100
commitf60b9e4c0b71901b362b54959a729d03898aa838 (patch)
treebd2cb16cd189bd00f6e98bf5304d701fff8dc92a /src/main/java/at
parent9bf83a33b570b88326a8b37c2e019f5879eda4b4 (diff)
downloadskyhanni-f60b9e4c0b71901b362b54959a729d03898aa838.tar.gz
skyhanni-f60b9e4c0b71901b362b54959a729d03898aa838.tar.bz2
skyhanni-f60b9e4c0b71901b362b54959a729d03898aa838.zip
Improvement: Get current speed without tab list (#1277)
Co-authored-by: hannibal2 <24389977+hannibal002@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt24
1 files changed, 4 insertions, 20 deletions
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 a057082ad..437d69883 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
@@ -29,21 +29,11 @@ class GardenOptimalSpeed {
private val config get() = GardenAPI.config.optimalSpeeds
- private val currentSpeedPattern by RepoPattern.pattern(
- "garden.optimalspeed.currentspeed",
- " Speed: §r§f✦(?<speed>.*)"
- )
-
private val configCustomSpeed get() = config.customSpeed
private var sneakingTime = 0.seconds
private val sneaking get() = Minecraft.getMinecraft().thePlayer.isSneaking
private val sneakingPersistent get() = sneakingTime > 5.seconds
- private var _currentSpeed = 100
- private var currentSpeed: Int
- get() = (_currentSpeed * (if (sneaking) 0.3 else 1.0)).toInt()
- set(value) {
- _currentSpeed = value
- }
+ private var currentSpeed = 100
private var optimalSpeed = -1
private var lastWarnTime = 0L
private var cropInHand: CropType? = null
@@ -52,7 +42,10 @@ class GardenOptimalSpeed {
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
+ currentSpeed = (Minecraft.getMinecraft().thePlayer.capabilities.walkSpeed * 1000).toInt()
+
if (sneaking) {
+ currentSpeed = (currentSpeed * 0.3).toInt()
sneakingTime += 50.milliseconds
} else {
sneakingTime = 0.seconds
@@ -60,15 +53,6 @@ class GardenOptimalSpeed {
}
@SubscribeEvent
- fun onTabListUpdate(event: TabListUpdateEvent) {
- for (line in event.tabList) {
- currentSpeedPattern.matchMatcher(line) {
- currentSpeed = group("speed").toInt()
- }
- }
- }
-
- @SubscribeEvent
fun onGuiOpen(event: GuiOpenEvent) {
if (!isRancherOverlayEnabled()) return
val gui = event.gui