Skip to content

Commit

Permalink
hopefully fix keybinding issues for armor?
Browse files Browse the repository at this point in the history
  • Loading branch information
desht committed Sep 15, 2023
1 parent 77caa24 commit 35d40d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,20 +306,22 @@ public static class KeyDispatcher {
@SubscribeEvent
public static void onKeyPress(InputEvent.Key event) {
if (Minecraft.getInstance().screen == null && event.getAction() == GLFW.GLFW_PRESS) {
processInput(KEY_BINDING_MAP.getAll(InputConstants.Type.KEYSYM.getOrCreate(event.getKey())));
InputConstants.Key key = InputConstants.Type.KEYSYM.getOrCreate(event.getKey());
processInput(key, KEY_BINDING_MAP.getAll(key));
}
}

@SubscribeEvent
public static void onMouseClick(InputEvent.MouseButton event) {
if (Minecraft.getInstance().screen == null && event.getAction() == GLFW.GLFW_PRESS) {
processInput(KEY_BINDING_MAP.getAll(InputConstants.Type.MOUSE.getOrCreate(event.getButton())));
InputConstants.Key key = InputConstants.Type.MOUSE.getOrCreate(event.getButton());
processInput(key, KEY_BINDING_MAP.getAll(key));
}
}

private static void processInput(List<KeyMapping> mappingList) {
private static void processInput(InputConstants.Key key, List<KeyMapping> mappingList) {
mappingList.stream()
.filter(binding -> binding.getKeyModifier() == KeyModifier.getActiveModifier())
.filter(binding -> binding.isActiveAndMatches(key) && binding.getKeyModifier() == KeyModifier.getActiveModifier())
.forEach(binding -> getBoundWidget(binding.getName()).ifPresent(WidgetKeybindCheckBox::handleClick));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ public IArmorUpgradeClientHandler<?> getClientHandler(ResourceLocation id) {
}

public Optional<IArmorUpgradeClientHandler<?>> getTriggeredHandler(KeyMapping keyBinding) {
return Optional.ofNullable(triggerKeyBindMap.get(keyBinding.getName()));
return keyBinding.getKeyModifier() == KeyModifier.getActiveModifier() ?
Optional.ofNullable(triggerKeyBindMap.get(keyBinding.getName())) :
Optional.empty();
}

/**
Expand Down

0 comments on commit 35d40d7

Please sign in to comment.