@@ -20,31 +20,34 @@ package com.lambda.module.modules.player
2020import com.lambda.event.events.MovementEvent
2121import com.lambda.event.listener.SafeListener.Companion.listen
2222import com.lambda.gui.LambdaScreen
23+ import com.lambda.interaction.request.rotation.Rotation
24+ import com.lambda.interaction.request.rotation.RotationConfig
25+ import com.lambda.interaction.request.rotation.RotationManager.onRotate
26+ import com.lambda.interaction.request.rotation.RotationMode
27+ import com.lambda.interaction.request.rotation.visibilty.lookAt
2328import com.lambda.module.Module
2429import com.lambda.module.tag.ModuleTag
2530import com.lambda.util.KeyboardUtils.isKeyPressed
2631import com.lambda.util.math.MathUtils.toDouble
32+ import com.lambda.util.math.MathUtils.toFloatSign
2733import com.lambda.util.player.MovementUtils.buildMovementInput
2834import com.lambda.util.player.MovementUtils.mergeFrom
2935import net.minecraft.client.gui.screen.ChatScreen
3036import net.minecraft.client.gui.screen.Screen
3137import net.minecraft.client.gui.screen.ingame.AnvilScreen
3238import net.minecraft.client.gui.screen.ingame.CommandBlockScreen
39+ import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen
3340import net.minecraft.client.gui.screen.ingame.SignEditScreen
34- import org.lwjgl.glfw.GLFW.GLFW_KEY_A
35- import org.lwjgl.glfw.GLFW.GLFW_KEY_D
36- import org.lwjgl.glfw.GLFW.GLFW_KEY_LEFT_CONTROL
37- import org.lwjgl.glfw.GLFW.GLFW_KEY_LEFT_SHIFT
38- import org.lwjgl.glfw.GLFW.GLFW_KEY_S
39- import org.lwjgl.glfw.GLFW.GLFW_KEY_SPACE
40- import org.lwjgl.glfw.GLFW.GLFW_KEY_W
41+ import net.minecraft.client.network.ClientPlayerEntity
42+ import org.lwjgl.glfw.GLFW.*
4143
4244object InventoryMove : Module(
4345 name = " InventoryMove" ,
4446 description = " Allows you to move with GUIs opened" ,
4547 defaultTags = setOf(ModuleTag .PLAYER , ModuleTag .MOVEMENT )
4648) {
47- private val rotationSpeed by setting(" Rotation Speed" , 5 , 1 .. 20 , 1 , unit = " °/tick" )
49+ private val speed by setting(" Rotation Speed" , 5 , 1 .. 20 , 1 , unit = " °/tick" )
50+ private val rotationConfig = RotationConfig .Instant (RotationMode .Lock )
4851
4952 /* *
5053 * Whether the current screen has text inputs or is null
@@ -70,18 +73,21 @@ object InventoryMove : Module(
7073 val jump = isKeyPressed(GLFW_KEY_SPACE )
7174 val sneak = isKeyPressed(GLFW_KEY_LEFT_SHIFT )
7275
73- /*
74- val pitch = rotationSpeed * (isKeyPressed(GLFW_KEY_DOWN).toFloatSign() -
75- isKeyPressed(GLFW_KEY_UP).toFloatSign())
76- val yaw = rotationSpeed * (isKeyPressed(GLFW_KEY_RIGHT).toFloatSign() -
77- isKeyPressed(GLFW_KEY_LEFT).toFloatSign())
78-
79- player.pitch = (player.pitch + pitch).coerceIn(-90f, 90f)
80- player.yaw += yaw
81- */
82-
8376 player.isSprinting = isKeyPressed(GLFW_KEY_LEFT_CONTROL )
8477 event.input.mergeFrom(buildMovementInput(forward, strafe, jump, sneak))
8578 }
79+
80+ onRotate {
81+ if (mc.currentScreen.hasInputOrNull) return @onRotate
82+
83+ val pitch = (isKeyPressed(GLFW_KEY_DOWN , GLFW_KEY_KP_2 ).toFloatSign() -
84+ isKeyPressed(GLFW_KEY_UP , GLFW_KEY_KP_8 ).toFloatSign()) * speed
85+ val yaw = (isKeyPressed(GLFW_KEY_RIGHT , GLFW_KEY_KP_6 ).toFloatSign() -
86+ isKeyPressed(GLFW_KEY_LEFT , GLFW_KEY_KP_4 ).toFloatSign()) * speed
87+
88+ lookAt(
89+ Rotation (player.yaw + yaw, (player.pitch + pitch).coerceIn(- 90f , 90f ))
90+ ).requestBy(rotationConfig)
91+ }
8692 }
8793}
0 commit comments