Skip to content

Commit 8eeeaaf

Browse files
committed
Revert "InventoryMove with proper keybinds"
This reverts commit 59b1071.
1 parent d1175fc commit 8eeeaaf

File tree

6 files changed

+35
-67
lines changed

6 files changed

+35
-67
lines changed

src/main/java/com/lambda/mixin/MinecraftClientMixin.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
package com.lambda.mixin;
1919

20+
import com.lambda.Lambda;
2021
import com.lambda.event.EventFlow;
2122
import com.lambda.event.events.ClientEvent;
2223
import com.lambda.event.events.InventoryEvent;
2324
import com.lambda.event.events.TickEvent;
2425
import com.lambda.gui.DearImGui;
2526
import com.lambda.module.modules.player.Interact;
26-
import com.lambda.module.modules.player.InventoryMove;
2727
import com.lambda.module.modules.player.PacketMine;
2828
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
2929
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
@@ -33,7 +33,6 @@
3333
import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider;
3434
import net.minecraft.client.network.ClientPlayerEntity;
3535
import net.minecraft.client.network.ClientPlayerInteractionManager;
36-
import net.minecraft.client.option.KeyBinding;
3736
import net.minecraft.client.render.WorldRenderer;
3837
import net.minecraft.client.sound.SoundManager;
3938
import net.minecraft.util.Hand;
@@ -56,9 +55,6 @@ public class MinecraftClientMixin {
5655
@Nullable
5756
public HitResult crosshairTarget;
5857

59-
@Shadow
60-
public int itemUseCooldown;
61-
6258
@Inject(method = "close", at = @At("HEAD"))
6359
void closeImGui(CallbackInfo ci) {
6460
DearImGui.INSTANCE.destroy();
@@ -155,19 +151,6 @@ boolean redirectMultiActon(ClientPlayerInteractionManager instance) {
155151
void injectFastPlace(CallbackInfo ci) {
156152
if (!Interact.INSTANCE.isEnabled()) return;
157153

158-
itemUseCooldown = Interact.getPlaceDelay();
159-
}
160-
161-
@Redirect(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;unpressAll()V"))
162-
private void redirectUnPressAll() {
163-
if (InventoryMove.getShouldMove()) {
164-
KeyBinding.unpressAll();
165-
return;
166-
}
167-
for (KeyBinding bind : KeyBinding.KEYS_BY_ID.values()) {
168-
if (!InventoryMove.isKeyMovementRelated(bind.boundKey.getCode())) {
169-
bind.reset();
170-
}
171-
}
154+
Lambda.getMc().itemUseCooldown = Interact.getPlaceDelay();
172155
}
173156
}

src/main/java/com/lambda/mixin/input/KeyboardMixin.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919

2020
import com.lambda.event.EventFlow;
2121
import com.lambda.event.events.KeyboardEvent;
22-
import com.lambda.module.modules.player.InventoryMove;
2322
import net.minecraft.client.Keyboard;
24-
import net.minecraft.client.option.KeyBinding;
25-
import net.minecraft.client.util.InputUtil;
2623
import org.spongepowered.asm.mixin.Mixin;
2724
import org.spongepowered.asm.mixin.injection.At;
2825
import org.spongepowered.asm.mixin.injection.Inject;
@@ -43,11 +40,4 @@ private void onChar(long window, int codePoint, int modifiers, CallbackInfo ci)
4340
EventFlow.post(new KeyboardEvent.Char(c));
4441
}
4542
}
46-
47-
@Inject(method = "onKey", at = @At("RETURN"))
48-
private void onKeyTail(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) {
49-
if (!InventoryMove.getShouldMove() || !InventoryMove.isKeyMovementRelated(key)) return;
50-
InputUtil.Key fromCode = InputUtil.fromKeyCode(key, scancode);
51-
KeyBinding.setKeyPressed(fromCode, action != 0);
52-
}
5343
}

src/main/kotlin/com/lambda/config/AbstractSetting.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,6 @@ abstract class AbstractSetting<T : Any>(
158158
groups.add(path.toList())
159159
}
160160

161-
fun group(path: NamedEnum?) = apply {
162-
if (path != null) {
163-
groups.add(listOf(path))
164-
}
165-
}
166-
167161
fun reset(silent: Boolean = false) {
168162
if (!silent && value == defaultValue) {
169163
ConfigCommand.info(notChangedMessage())

src/main/kotlin/com/lambda/config/groups/RotationSettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import kotlin.random.Random
3030

3131
class RotationSettings(
3232
c: Configurable,
33-
baseGroup: NamedEnum? = null,
33+
baseGroup: NamedEnum,
3434
vis: () -> Boolean = { true }
3535
) : RotationConfig {
3636
override var rotationMode by c.setting("Mode", RotationMode.Sync, "How the player is being rotated on interaction", vis).group(baseGroup)

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

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818
package 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
2221
import com.lambda.event.events.UpdateManagerEvent
2322
import com.lambda.event.listener.SafeListener.Companion.listen
2423
import com.lambda.gui.LambdaScreen
@@ -29,49 +28,68 @@ import com.lambda.interaction.request.rotating.visibilty.lookAt
2928
import com.lambda.module.Module
3029
import com.lambda.module.tag.ModuleTag
3130
import com.lambda.util.KeyboardUtils.isKeyPressed
32-
import com.lambda.util.NamedEnum
31+
import com.lambda.util.math.MathUtils.toDouble
3332
import com.lambda.util.math.MathUtils.toFloatSign
33+
import com.lambda.util.player.MovementUtils.update
3434
import net.minecraft.client.gui.screen.ChatScreen
3535
import net.minecraft.client.gui.screen.Screen
36-
import net.minecraft.client.gui.screen.ingame.AbstractCommandBlockScreen
37-
import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen
3836
import 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
3941
import org.lwjgl.glfw.GLFW.GLFW_KEY_DOWN
4042
import org.lwjgl.glfw.GLFW.GLFW_KEY_KP_2
4143
import org.lwjgl.glfw.GLFW.GLFW_KEY_KP_4
4244
import org.lwjgl.glfw.GLFW.GLFW_KEY_KP_6
4345
import org.lwjgl.glfw.GLFW.GLFW_KEY_KP_8
4446
import 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
4549
import 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
4652
import org.lwjgl.glfw.GLFW.GLFW_KEY_UP
53+
import org.lwjgl.glfw.GLFW.GLFW_KEY_W
4754

4855
object 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
}

src/main/resources/lambda.accesswidener

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ transitive-accessible field net/minecraft/client/input/Input movementVector Lnet
99
transitive-accessible field net/minecraft/client/MinecraftClient renderTaskQueue Ljava/util/Queue;
1010
transitive-accessible field net/minecraft/client/option/KeyBinding boundKey Lnet/minecraft/client/util/InputUtil$Key;
1111
transitive-accessible method net/minecraft/client/MinecraftClient getWindowTitle ()Ljava/lang/String;
12-
transitive-accessible field net/minecraft/client/option/KeyBinding KEYS_BY_ID Ljava/util/Map;
13-
transitive-accessible method net/minecraft/client/option/KeyBinding reset ()V
1412

1513
# World
1614
transitive-accessible field net/minecraft/client/world/ClientWorld entityManager Lnet/minecraft/world/entity/ClientEntityManager;

0 commit comments

Comments
 (0)