1717
1818package com.lambda.module.modules.player
1919
20- import com.lambda.Lambda.mc
21- import com.lambda.config.groups.RotationSettings
20+ import com.lambda.event.events.MovementEvent
2221import com.lambda.event.events.UpdateManagerEvent
2322import com.lambda.event.listener.SafeListener.Companion.listen
2423import com.lambda.gui.LambdaScreen
@@ -29,49 +28,68 @@ import com.lambda.interaction.request.rotating.visibilty.lookAt
2928import com.lambda.module.Module
3029import com.lambda.module.tag.ModuleTag
3130import com.lambda.util.KeyboardUtils.isKeyPressed
32- import com.lambda.util.NamedEnum
31+ import com.lambda.util.math.MathUtils.toDouble
3332import com.lambda.util.math.MathUtils.toFloatSign
33+ import com.lambda.util.player.MovementUtils.update
3434import net.minecraft.client.gui.screen.ChatScreen
3535import net.minecraft.client.gui.screen.Screen
36- import net.minecraft.client.gui.screen.ingame.AbstractCommandBlockScreen
37- import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen
3836import net.minecraft.client.gui.screen.ingame.AnvilScreen
37+ import net.minecraft.client.gui.screen.ingame.CommandBlockScreen
38+ import net.minecraft.client.gui.screen.ingame.SignEditScreen
39+ import org.lwjgl.glfw.GLFW.GLFW_KEY_A
40+ import org.lwjgl.glfw.GLFW.GLFW_KEY_D
3941import org.lwjgl.glfw.GLFW.GLFW_KEY_DOWN
4042import org.lwjgl.glfw.GLFW.GLFW_KEY_KP_2
4143import org.lwjgl.glfw.GLFW.GLFW_KEY_KP_4
4244import org.lwjgl.glfw.GLFW.GLFW_KEY_KP_6
4345import org.lwjgl.glfw.GLFW.GLFW_KEY_KP_8
4446import org.lwjgl.glfw.GLFW.GLFW_KEY_LEFT
47+ import org.lwjgl.glfw.GLFW.GLFW_KEY_LEFT_CONTROL
48+ import org.lwjgl.glfw.GLFW.GLFW_KEY_LEFT_SHIFT
4549import org.lwjgl.glfw.GLFW.GLFW_KEY_RIGHT
50+ import org.lwjgl.glfw.GLFW.GLFW_KEY_S
51+ import org.lwjgl.glfw.GLFW.GLFW_KEY_SPACE
4652import org.lwjgl.glfw.GLFW.GLFW_KEY_UP
53+ import org.lwjgl.glfw.GLFW.GLFW_KEY_W
4754
4855object InventoryMove : Module(
4956 name = " InventoryMove" ,
5057 description = " Allows you to move with GUIs opened" ,
5158 tag = ModuleTag .PLAYER ,
5259) {
53- private val arrowKeys by setting(" Arrow Keys" , false , " Allows rotating the players camera using the arrow keys" )
54- private val speed by setting(" Rotation Speed" , 5 , 1 .. 20 , 1 , unit = " °/tick" ) { arrowKeys }
60+ private val speed by setting(" Rotation Speed" , 5 , 1 .. 20 , 1 , unit = " °/tick" )
5561 private val rotationConfig = RotationConfig .Instant (RotationMode .Lock )
5662
57- @JvmStatic
58- val shouldMove get() = isEnabled && ! mc.currentScreen.hasInputOrNull
59-
6063 /* *
6164 * Whether the current screen has text inputs or is null
6265 */
63- @JvmStatic
6466 val Screen ?.hasInputOrNull: Boolean
6567 get() = this is ChatScreen ||
66- this is AbstractSignEditScreen ||
68+ this is SignEditScreen ||
6769 this is AnvilScreen ||
68- this is AbstractCommandBlockScreen ||
70+ this is CommandBlockScreen ||
6971 this is LambdaScreen ||
7072 this == null
7173
7274 init {
75+ listen<MovementEvent .InputUpdate >(20250415 ) { event ->
76+ if (mc.currentScreen.hasInputOrNull) return @listen
77+
78+ val forward = isKeyPressed(GLFW_KEY_W ).toDouble() -
79+ isKeyPressed(GLFW_KEY_S ).toDouble()
80+
81+ val strafe = isKeyPressed(GLFW_KEY_A ).toDouble() -
82+ isKeyPressed(GLFW_KEY_D ).toDouble()
83+
84+ val jump = isKeyPressed(GLFW_KEY_SPACE )
85+ val sneak = isKeyPressed(GLFW_KEY_LEFT_SHIFT )
86+ val sprint = isKeyPressed(GLFW_KEY_LEFT_CONTROL )
87+
88+ event.input.update(forward, strafe, jump, sneak, sprint)
89+ }
90+
7391 listen<UpdateManagerEvent .Rotation > {
74- if (! arrowKeys || mc.currentScreen.hasInputOrNull) return @listen
92+ if (mc.currentScreen.hasInputOrNull) return @listen
7593
7694 val pitch = (isKeyPressed(GLFW_KEY_DOWN , GLFW_KEY_KP_2 ).toFloatSign() -
7795 isKeyPressed(GLFW_KEY_UP , GLFW_KEY_KP_8 ).toFloatSign()) * speed
@@ -83,19 +101,4 @@ object InventoryMove : Module(
83101 ).requestBy(rotationConfig)
84102 }
85103 }
86-
87- @JvmStatic
88- fun isKeyMovementRelated (key : Int ): Boolean {
89- val options = mc.options
90- return when (key) {
91- options.forwardKey.boundKey.code,
92- options.backKey.boundKey.code,
93- options.leftKey.boundKey.code,
94- options.rightKey.boundKey.code,
95- options.jumpKey.boundKey.code,
96- options.sprintKey.boundKey.code,
97- options.sneakKey.boundKey.code -> true
98- else -> false
99- }
100- }
101104}
0 commit comments