我正在尝试将键绑定到数字行上的 1、2 和 3 键,但如果这些键绑定已注册,那么用于选择快捷栏插槽的原版键绑定将停止工作。我怎样才能让两者一起工作?
我正在使用 KeyBindingHelper 在 Fabric 中注册我的键绑定。
注册:
hotbarKeys = new KeyBinding[3];
hotbarKeys[0] = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.hotbarexpander.hotbar_1",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_1,
"category.hotbarexpander.hotbarexpander"
));
hotbarKeys[1] = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.hotbarexpander.hotbar_2",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_2,
"category.hotbarexpander.hotbarexpander"
));
hotbarKeys[2] = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.hotbarexpander.hotbar_3",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_3,
"category.hotbarexpander.hotbarexpander"
));
expandHotbar = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.hotbarexpander.expand_hotbar",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_LEFT_ALT,
"category.hotbarexpander.hotbarexpander"
));;
即使删除处理按键的代码也无济于事:
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (expandHotbar.isPressed()) {
HotbarExpanderClient.renderHotbars = true;
for (int i = 0; i < 3; i++) {
if (hotbarKeys[i].isPressed()) {
HotbarExpanderClient.selectedHotbar = i + 1;
}
}
} else {
if (renderHotbars == true) {
replaceHotbar(selectedHotbar);
renderHotbars = false;
selectedHotbar = 0;
}
}
});
我想我必须创建一个 mixin 来阻止键绑定发生冲突,但我找不到游戏在哪里处理它。否则我将不得不以不同的方式制作这些键绑定,但我不知道如何。