Skip to content

Commit b49929b

Browse files
committed
Fixed movement vector
1 parent 0fca8d6 commit b49929b

File tree

6 files changed

+18
-42
lines changed

6 files changed

+18
-42
lines changed

src/main/kotlin/com/lambda/interaction/request/rotating/RotationManager.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ object RotationManager : RequestHandler<RotationRequest>(
6161
var activeRequest: RotationRequest? = null
6262
private var changedThisTick = false
6363

64-
fun Any.onRotate(
65-
alwaysListen: Boolean = false,
66-
priority: Int = 0,
67-
block: SafeContext.() -> Unit
68-
) = this.listen<UpdateManagerEvent.Rotation>(priority, alwaysListen) {
69-
block()
70-
}
71-
7264
override fun load(): String {
7365
super.load()
7466

src/main/kotlin/com/lambda/module/modules/movement/Speed.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ package com.lambda.module.modules.movement
2020
import com.lambda.context.SafeContext
2121
import com.lambda.event.events.ClientEvent
2222
import com.lambda.event.events.MovementEvent
23+
import com.lambda.event.events.UpdateManagerEvent
2324
import com.lambda.event.listener.SafeListener.Companion.listen
2425
import com.lambda.interaction.request.rotating.Rotation
2526
import com.lambda.interaction.request.rotating.RotationConfig
26-
import com.lambda.interaction.request.rotating.RotationManager.onRotate
2727
import com.lambda.interaction.request.rotating.RotationMode
2828
import com.lambda.interaction.request.rotating.visibilty.lookAt
2929
import com.lambda.module.Module
@@ -130,14 +130,14 @@ object Speed : Module(
130130
}
131131
}
132132

133-
onRotate {
134-
if (mode != Mode.GRIM_STRAFE) return@onRotate
135-
if (!shouldWork()) return@onRotate
133+
listen<UpdateManagerEvent.Rotation> {
134+
if (mode != Mode.GRIM_STRAFE) return@listen
135+
if (!shouldWork()) return@listen
136136

137137
var yaw = player.yaw
138138
val input = newMovementInput()
139139

140-
if (!input.isInputting) return@onRotate
140+
if (!input.isInputting) return@listen
141141

142142
run {
143143
if (!diagonal) return@run

src/main/kotlin/com/lambda/module/modules/player/Freecam.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ import com.lambda.event.events.ConnectionEvent
2222
import com.lambda.event.events.MovementEvent
2323
import com.lambda.event.events.PlayerEvent
2424
import com.lambda.event.events.RenderEvent
25+
import com.lambda.event.events.UpdateManagerEvent
2526
import com.lambda.event.listener.SafeListener.Companion.listen
2627
import com.lambda.interaction.request.rotating.Rotation
2728
import com.lambda.interaction.request.rotating.RotationConfig
28-
import com.lambda.interaction.request.rotating.RotationManager.onRotate
2929
import com.lambda.interaction.request.rotating.RotationMode
3030
import com.lambda.interaction.request.rotating.visibilty.lookAtHit
3131
import com.lambda.module.Module
3232
import com.lambda.module.tag.ModuleTag
33-
import com.lambda.util.extension.partialTicks
3433
import com.lambda.util.extension.rotation
3534
import com.lambda.util.math.interpolate
3635
import com.lambda.util.math.plus
@@ -98,8 +97,8 @@ object Freecam : Module(
9897
mc.options.perspective = lastPerspective
9998
}
10099

101-
onRotate {
102-
if (!rotateToTarget) return@onRotate
100+
listen<UpdateManagerEvent.Rotation> {
101+
if (!rotateToTarget) return@listen
103102

104103
mc.crosshairTarget?.let {
105104
lookAtHit(it)?.requestBy(rotationConfig)

src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
package com.lambda.module.modules.player
1919

2020
import com.lambda.event.events.MovementEvent
21+
import com.lambda.event.events.UpdateManagerEvent
2122
import com.lambda.event.listener.SafeListener.Companion.listen
2223
import com.lambda.gui.LambdaScreen
2324
import com.lambda.interaction.request.rotating.Rotation
2425
import com.lambda.interaction.request.rotating.RotationConfig
25-
import com.lambda.interaction.request.rotating.RotationManager.onRotate
2626
import com.lambda.interaction.request.rotating.RotationMode
2727
import com.lambda.interaction.request.rotating.visibilty.lookAt
2828
import com.lambda.module.Module
@@ -88,8 +88,8 @@ object InventoryMove : Module(
8888
event.input.update(forward, strafe, jump, sneak, sprint)
8989
}
9090

91-
onRotate {
92-
if (mc.currentScreen.hasInputOrNull) return@onRotate
91+
listen<UpdateManagerEvent.Rotation> {
92+
if (mc.currentScreen.hasInputOrNull) return@listen
9393

9494
val pitch = (isKeyPressed(GLFW_KEY_DOWN, GLFW_KEY_KP_2).toFloatSign() -
9595
isKeyPressed(GLFW_KEY_UP, GLFW_KEY_KP_8).toFloatSign()) * speed

src/main/kotlin/com/lambda/module/modules/player/Replay.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ import com.lambda.core.TimerManager
3131
import com.lambda.event.EventFlow.lambdaScope
3232
import com.lambda.event.events.KeyboardEvent
3333
import com.lambda.event.events.MovementEvent
34+
import com.lambda.event.events.UpdateManagerEvent
3435
import com.lambda.event.listener.SafeListener.Companion.listen
3536
import com.lambda.interaction.request.rotating.Rotation
3637
import com.lambda.interaction.request.rotating.RotationConfig
37-
import com.lambda.interaction.request.rotating.RotationManager.onRotate
3838
import com.lambda.interaction.request.rotating.RotationMode
3939
import com.lambda.interaction.request.rotating.visibilty.lookAt
4040
import com.lambda.module.Module
@@ -179,7 +179,7 @@ object Replay : Module(
179179
}
180180
}
181181

182-
onRotate {
182+
listen<UpdateManagerEvent.Rotation> {
183183
when (state) {
184184
State.RECORDING -> {
185185
buffer?.rotation?.add(player.rotation)

src/main/kotlin/com/lambda/util/player/MovementUtils.kt

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package com.lambda.util.player
2020
import com.lambda.context.SafeContext
2121
import com.lambda.interaction.request.rotating.RotationManager
2222
import com.lambda.util.math.MathUtils.toDegree
23-
import com.lambda.util.math.MathUtils.toInt
23+
import com.lambda.util.math.MathUtils.toDouble
2424
import com.lambda.util.math.MathUtils.toRadian
2525
import com.lambda.util.math.plus
2626
import com.lambda.util.math.times
@@ -73,22 +73,8 @@ object MovementUtils {
7373
): Input {
7474
if (assumeBaritone && player.input.handledByBaritone) return player.input
7575

76-
val newInput = KeyboardInput(mc.options)
77-
78-
if (!slowdownCheck) return newInput.apply { tick() }
79-
80-
newInput.movementVector = player.applyMovementSpeedFactors(player.input.movementVector)
81-
82-
return newInput
83-
}
84-
85-
@Deprecated(
86-
message = "mergeFrom is deprecated in favor of Input.update",
87-
replaceWith = ReplaceWith("this.update()")
88-
)
89-
fun Input.mergeFrom(input: Input) {
90-
playerInput = input.playerInput
91-
movementVector = input.movementVector
76+
// ToDo: Add slowdown
77+
return KeyboardInput(mc.options).apply { tick() }
9278
}
9379

9480
fun Input.update(
@@ -99,7 +85,6 @@ object MovementUtils {
9985
sprint: Boolean = playerInput.sprint,
10086
) {
10187
val input = buildMovementInput(forward, strafe, jump, sneak, sprint)
102-
10388
movementVector = input.movementVector
10489
playerInput = input.playerInput
10590
}
@@ -111,7 +96,7 @@ object MovementUtils {
11196
sneak: Boolean = false,
11297
sprint: Boolean = false,
11398
) = Input().apply {
114-
movementVector = Vec2f(strafe.toFloat(), forward.toFloat())
99+
movementVector = Vec2f(strafe.toFloat(), forward.toFloat()).normalize()
115100
playerInput = PlayerInput(
116101
forward > 0.0,
117102
forward < 0.0,
@@ -127,7 +112,7 @@ object MovementUtils {
127112
update(0.0, 0.0, !vertical, !vertical, false)
128113

129114
val Input.verticalMovement
130-
get() = (playerInput.jump.toInt() - playerInput.sneak.toInt()).toDouble()
115+
get() = jumping.toDouble() - sneaking.toDouble()
131116

132117
private fun inputMoveOffset(
133118
moveForward: Double,

0 commit comments

Comments
 (0)