|
17 | 17 |
|
18 | 18 | package com.lambda.module.modules.player |
19 | 19 |
|
20 | | -import com.lambda.event.events.MovementEvent |
21 | | -import com.lambda.event.listener.SafeListener.Companion.listen |
| 20 | +import com.lambda.Lambda.mc |
22 | 21 | import 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 |
28 | 22 | import com.lambda.module.Module |
29 | 23 | import com.lambda.module.tag.ModuleTag |
30 | | -import com.lambda.util.KeyboardUtils.isKeyPressed |
31 | | -import com.lambda.util.math.MathUtils.toDouble |
32 | | -import com.lambda.util.math.MathUtils.toFloatSign |
33 | | -import com.lambda.util.player.MovementUtils.buildMovementInput |
34 | | -import com.lambda.util.player.MovementUtils.mergeFrom |
35 | 24 | import net.minecraft.client.gui.screen.ChatScreen |
36 | 25 | import net.minecraft.client.gui.screen.Screen |
37 | 26 | import net.minecraft.client.gui.screen.ingame.AnvilScreen |
38 | 27 | import net.minecraft.client.gui.screen.ingame.CommandBlockScreen |
39 | | -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen |
40 | 28 | import net.minecraft.client.gui.screen.ingame.SignEditScreen |
41 | | -import net.minecraft.client.network.ClientPlayerEntity |
42 | | -import org.lwjgl.glfw.GLFW.* |
43 | 29 |
|
44 | 30 | object InventoryMove : Module( |
45 | 31 | name = "InventoryMove", |
46 | 32 | description = "Allows you to move with GUIs opened", |
47 | 33 | defaultTags = setOf(ModuleTag.PLAYER, ModuleTag.MOVEMENT) |
48 | 34 | ) { |
49 | 35 | private val speed by setting("Rotation Speed", 5, 1..20, 1, unit = "°/tick") |
50 | | - private val rotationConfig = RotationConfig.Instant(RotationMode.Lock) |
51 | 36 |
|
52 | 37 | /** |
53 | 38 | * Whether the current screen has text inputs or is null |
54 | 39 | */ |
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 | | - |
63 | | - 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 | | - |
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) |
| 40 | + @JvmStatic |
| 41 | + fun hasInputOrNull(screen: Screen?) = |
| 42 | + screen is ChatScreen || |
| 43 | + screen is SignEditScreen || |
| 44 | + screen is AnvilScreen || |
| 45 | + screen is CommandBlockScreen || |
| 46 | + screen is LambdaScreen || |
| 47 | + screen == null |
| 48 | + |
| 49 | + @JvmStatic |
| 50 | + fun isKeyMovementRelated(key: Int): Boolean { |
| 51 | + val options = mc.options |
| 52 | + return when (key) { |
| 53 | + options.forwardKey.boundKey.code, |
| 54 | + options.backKey.boundKey.code, |
| 55 | + options.leftKey.boundKey.code, |
| 56 | + options.rightKey.boundKey.code, |
| 57 | + options.jumpKey.boundKey.code, |
| 58 | + options.sprintKey.boundKey.code, |
| 59 | + options.sneakKey.boundKey.code -> true |
| 60 | + else -> false |
91 | 61 | } |
92 | 62 | } |
93 | 63 | } |
0 commit comments