Modern KeyBinding
This modification brings the KeyModifier and KeyConflictContext functionality from newer Minecraft versions back to Fabric and early Forge platforms.
Main Features
You can now assign key combinations using modifiers. For example, "Ctrl + G" or "Alt + S" - such combinations become available for configuration.
Keys with the same activation but different conflict contexts no longer interfere with each other. This solves the problem of overlapping assignments.
The "non-conflicting keys" feature (disabled by default) allows all assignments with the same key to be activated when it is pressed.
Important Information
The mod is incompatible with NEI. Instead, it is recommended to use NEI Unofficial from GTNH.
Connection via Gradle
repositories {
//...
maven {
url "https://maven.nova-committee.cn/releases"
}
}
dependencies {
//...
// Forge
implementation "committee.nova.mkb.forge:mkb-${mc_version}:${mod_version}"
// Fabric
modImplementation "committee.nova.mkb.fabric:mkb-${mc_version}:${mod_version}"
}
Key Combination Registration
Example of creating an assignment that:
- Activates when Alt and C are pressed
- Works only in interfaces
ClientProxy.java
public class ClientProxy {
public void init(final FMLInitializationEvent event) {
//...
yourKeyBinding = KeyBindingRegistry.INSTANCE.registerKeyBinding("key.exampleKey", KeyConflictContext.GUI, KeyModifier.ALT, Keyboard.KEY_C, "key.categories.example");
}
}
Changing Properties of Existing Assignment
ClientProxy.java
public class ClientProxy {
//...
public void postInit(final FMLPostInitializationEvent event) {
final IKeyBinding extended = (IKeyBinding) yourKeyBinding;
// Changing default key code and modifier
extended.setInitialKeyModifierAndCode(KeyModifier.ALT, Keyboard.KEY_E);
// Changing current key code and modifier
extended.setKeyModifierAndCode(KeyModifier.ALT, Keyboard.KEY_E);
// Changing conflict context
extended.setKeyConflictContext(KeyConflictContext.IN_GAME);
}
}