Skip to content

Improvement: use minecraft's keybind structure for inventory move - #131

Closed
beanbag44 wants to merge 4 commits into
1.21.5from
improvement/inventory-move
Closed

Improvement: use minecraft's keybind structure for inventory move#131
beanbag44 wants to merge 4 commits into
1.21.5from
improvement/inventory-move

Conversation

@beanbag44

Copy link
Copy Markdown
Member

alters the inventory move module to use the players keybinds over default, and lets minecraft handle the movement logic

@github-actionsgithub-actionsBot added the triage Requires labelling or review label Jul 29, 2025
@emyfops

Copy link
Copy Markdown
Contributor

This is a regression as the user is no longer able to rotate using the arrow keys

@beanbag44

Copy link
Copy Markdown
MemberAuthor

oh sorry i didn't mean to remove that feature. I'll fix it. I don't think any of the changes i made should affect it

…nto improvement/inventory-move
# Conflicts:
#	common/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt
@emyfops
emyfops requested a review from CopilotAugust 2, 2025 09:56

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the InventoryMove module by switching from manual movement input handling to using Minecraft's native keybind system. This allows the module to respect player-configured keybinds and delegates movement logic to Minecraft's built-in systems.

  • Removed custom movement input handling and replaced it with keybind-based movement detection
  • Added keyboard input interception to maintain movement key states when inventory screens are open
  • Introduced selective key unpressing to preserve movement keys while clearing other keybinds during screen transitions

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

FileDescription
lambda.accesswidenerExposes KeyBinding internals for accessing key mappings and reset functionality
InventoryMove.ktRefactored from manual input handling to keybind detection with arrow key rotation option
KeyboardMixin.javaAdded input interception to maintain movement key states during inventory screens
MinecraftClientMixin.javaModified key unpressing behavior to preserve movement keys during screen transitions


@Redirect(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;unpressAll()V"))
private void redirectUnPressAll() {
if (InventoryMove.INSTANCE.isDisabled() || InventoryMove.hasInputOrNull(currentScreen)) {

CopilotAIAug 2, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition InventoryMove.INSTANCE.isDisabled() || InventoryMove.hasInputOrNull(currentScreen) is duplicated in KeyboardMixin. Consider extracting this logic into a utility method to reduce code duplication.

Suggested change
if (InventoryMove.INSTANCE.isDisabled() || InventoryMove.hasInputOrNull(currentScreen)) {
if (shouldUnpressAll(currentScreen)) {

Copilot uses AI. Check for mistakes.
Comment on lines +102 to +106
KeyBinding.KEYS_BY_ID.values().forEach(bind -> {
if (!InventoryMove.isKeyMovementRelated(bind.boundKey.getCode())) {
bind.reset();
}
});

CopilotAIAug 2, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using forEach with a lambda on every screen transition could be inefficient. Consider using a traditional for-each loop or caching the filtered keybindings for better performance.

Suggested change
KeyBinding.KEYS_BY_ID.values().forEach(bind -> {
if (!InventoryMove.isKeyMovementRelated(bind.boundKey.getCode())) {
bind.reset();
}
});
for (KeyBindingbind : KeyBinding.KEYS_BY_ID.values()) {
if (!InventoryMove.isKeyMovementRelated(bind.boundKey.getCode())) {
bind.reset();
}
}

Copilot uses AI. Check for mistakes.
@Avanatiker
Avanatiker changed the base branch from master to 1.21.5September 5, 2025 01:45
@lambda-clientlambda-client deleted a comment from CopilotAISep 5, 2025
@Avanatiker

Copy link
Copy Markdown
Member

Thanks but i had to redo it from scratch due to massively outdated target branch :/

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triageRequires labelling or review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@beanbag44@emyfops@Avanatiker