Search in sources :

Example 1 with FabricKeyBinding

use of net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding in project fabric by FabricMC.

the class KeyBindingRegistryImpl method process.

public KeyBinding[] process(KeyBinding[] keysAll) {
    List<KeyBinding> newKeysAll = new ArrayList<>();
    for (KeyBinding binding : keysAll) {
        if (!(binding instanceof FabricKeyBinding)) {
            newKeysAll.add(binding);
        }
    }
    newKeysAll.addAll(fabricKeyBindingList);
    return newKeysAll.toArray(new KeyBinding[0]);
}
Also used : FabricKeyBinding(net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding) FabricKeyBinding(net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding) KeyBinding(net.minecraft.client.options.KeyBinding) ArrayList(java.util.ArrayList)

Example 2 with FabricKeyBinding

use of net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding in project fabric by FabricMC.

the class KeyBindingRegistryImpl method register.

@Override
public boolean register(FabricKeyBinding binding) {
    for (KeyBinding exBinding : fabricKeyBindingList) {
        if (exBinding == binding) {
            return false;
        } else if (exBinding.getId().equals(binding.getId())) {
            throw new RuntimeException("Attempted to register two key bindings with equal ID: " + binding.getId() + "!");
        }
    }
    if (!hasCategory(binding.getCategory())) {
        LOGGER.warn("Tried to register key binding with unregistered category '" + binding.getCategory() + "' - please use addCategory to ensure intended category ordering!");
        addCategory(binding.getCategory());
    }
    fabricKeyBindingList.add(binding);
    return true;
}
Also used : FabricKeyBinding(net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding) KeyBinding(net.minecraft.client.options.KeyBinding)

Aggregations

FabricKeyBinding (net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding)2 KeyBinding (net.minecraft.client.options.KeyBinding)2 ArrayList (java.util.ArrayList)1