1717
1818package com.lambda.module.modules.player
1919
20- import com.lambda.event.events.MovementEvent
21- import com.lambda.event.listener.SafeListener.Companion.listen
20+ import com.lambda.Lambda.mc
2221import com.lambda.gui.LambdaScreen
2322import com.lambda.interaction.request.rotation.Rotation
2423import com.lambda.interaction.request.rotation.RotationConfig
@@ -28,57 +27,33 @@ import com.lambda.interaction.request.rotation.visibilty.lookAt
2827import com.lambda.module.Module
2928import com.lambda.module.tag.ModuleTag
3029import com.lambda.util.KeyboardUtils.isKeyPressed
31- import com.lambda.util.math.MathUtils.toDouble
3230import com.lambda.util.math.MathUtils.toFloatSign
33- import com.lambda.util.player.MovementUtils.buildMovementInput
34- import com.lambda.util.player.MovementUtils.mergeFrom
3531import net.minecraft.client.gui.screen.ChatScreen
3632import net.minecraft.client.gui.screen.Screen
3733import net.minecraft.client.gui.screen.ingame.AnvilScreen
3834import net.minecraft.client.gui.screen.ingame.CommandBlockScreen
39- import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen
4035import net.minecraft.client.gui.screen.ingame.SignEditScreen
41- import net.minecraft.client.network.ClientPlayerEntity
42- import org.lwjgl.glfw.GLFW.*
36+ import org.lwjgl.glfw.GLFW.GLFW_KEY_DOWN
37+ import org.lwjgl.glfw.GLFW.GLFW_KEY_KP_2
38+ import org.lwjgl.glfw.GLFW.GLFW_KEY_KP_4
39+ import org.lwjgl.glfw.GLFW.GLFW_KEY_KP_6
40+ import org.lwjgl.glfw.GLFW.GLFW_KEY_KP_8
41+ import org.lwjgl.glfw.GLFW.GLFW_KEY_LEFT
42+ import org.lwjgl.glfw.GLFW.GLFW_KEY_RIGHT
43+ import org.lwjgl.glfw.GLFW.GLFW_KEY_UP
4344
4445object InventoryMove : Module(
4546 name = " InventoryMove" ,
4647 description = " Allows you to move with GUIs opened" ,
4748 defaultTags = setOf(ModuleTag .PLAYER , ModuleTag .MOVEMENT )
4849) {
49- private val speed by setting(" Rotation Speed" , 5 , 1 .. 20 , 1 , unit = " °/tick" )
50+ private val arrowKeys by setting(" Arrow Keys" , false , " Allows rotating the players camera using the arrow keys" )
51+ private val speed by setting(" Rotation Speed" , 5 , 1 .. 20 , 1 , unit = " °/tick" ) { arrowKeys }
5052 private val rotationConfig = RotationConfig .Instant (RotationMode .Lock )
5153
52- /* *
53- * Whether the current screen has text inputs or is null
54- */
55- val Screen ?.hasInputOrNull: Boolean
56- get() = this is ChatScreen ||
57- this is SignEditScreen ||
58- this is AnvilScreen ||
59- this is CommandBlockScreen ||
60- this is LambdaScreen ||
61- this == null
62-
6354 init {
64- listen<MovementEvent .InputUpdate >(20250415 ) { event ->
65- if (mc.currentScreen.hasInputOrNull) return @listen
66-
67- val forward = isKeyPressed(GLFW_KEY_W ).toDouble() -
68- isKeyPressed(GLFW_KEY_S ).toDouble()
69-
70- val strafe = isKeyPressed(GLFW_KEY_A ).toDouble() -
71- isKeyPressed(GLFW_KEY_D ).toDouble()
72-
73- val jump = isKeyPressed(GLFW_KEY_SPACE )
74- val sneak = isKeyPressed(GLFW_KEY_LEFT_SHIFT )
75-
76- player.isSprinting = isKeyPressed(GLFW_KEY_LEFT_CONTROL )
77- event.input.mergeFrom(buildMovementInput(forward, strafe, jump, sneak))
78- }
79-
8055 onRotate {
81- if (mc.currentScreen.hasInputOrNull ) return @onRotate
56+ if (! arrowKeys || hasInputOrNull( mc.currentScreen) ) return @onRotate
8257
8358 val pitch = (isKeyPressed(GLFW_KEY_DOWN , GLFW_KEY_KP_2 ).toFloatSign() -
8459 isKeyPressed(GLFW_KEY_UP , GLFW_KEY_KP_8 ).toFloatSign()) * speed
@@ -90,4 +65,31 @@ object InventoryMove : Module(
9065 ).requestBy(rotationConfig)
9166 }
9267 }
68+
69+ /* *
70+ * Whether the current screen has text inputs or is null
71+ */
72+ @JvmStatic
73+ fun hasInputOrNull (screen : Screen ? ) =
74+ screen is ChatScreen ||
75+ screen is SignEditScreen ||
76+ screen is AnvilScreen ||
77+ screen is CommandBlockScreen ||
78+ screen is LambdaScreen ||
79+ screen == null
80+
81+ @JvmStatic
82+ fun isKeyMovementRelated (key : Int ): Boolean {
83+ val options = mc.options
84+ return when (key) {
85+ options.forwardKey.boundKey.code,
86+ options.backKey.boundKey.code,
87+ options.leftKey.boundKey.code,
88+ options.rightKey.boundKey.code,
89+ options.jumpKey.boundKey.code,
90+ options.sprintKey.boundKey.code,
91+ options.sneakKey.boundKey.code -> true
92+ else -> false
93+ }
94+ }
9395}
0 commit comments