Search in sources :

Example 1 with KeyBinding

use of net.minecraft.client.options.KeyBinding in project SpeedRunIGT by RedLime.

the class KeyBindingMixin method onPress.

@Inject(method = "setKeyPressed", at = @At("TAIL"))
private static void onPress(InputUtil.Key key, boolean pressed, CallbackInfo ci) {
    InGameTimer timer = InGameTimer.getInstance();
    KeyBinding keyBinding = keyToBindings.get(key);
    if (timer.getStatus() == TimerStatus.NONE || timer.getStatus() == TimerStatus.COMPLETED_LEGACY)
        return;
    if (keyBinding != null && pressed) {
        if (// Advancement
        keyBinding == MinecraftClient.getInstance().options.keyAdvancements || Objects.equals(keyBinding.getCategory(), "key.categories.inventory") || Objects.equals(keyBinding.getCategory(), "key.categories.gameplay")) {
            if (InGameTimerUtils.canUnpauseTimer(false)) {
                timer.setPause(false, "pressed key");
            }
            timer.updateFirstInput();
        }
        if (keyBinding == SpeedRunIGT.timerResetKeyBinding) {
            if (timer.getCategory() == RunCategories.CUSTOM && timer.isResettable()) {
                InGameTimer.reset();
            }
        }
        if (keyBinding == SpeedRunIGT.timerStopKeyBinding) {
            if (timer.getCategory() == RunCategories.CUSTOM && timer.isStarted()) {
                InGameTimer.complete();
            }
        }
    }
}
Also used : KeyBinding(net.minecraft.client.options.KeyBinding) InGameTimer(com.redlimerl.speedrunigt.timer.InGameTimer) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with KeyBinding

use of net.minecraft.client.options.KeyBinding 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 3 with KeyBinding

use of net.minecraft.client.options.KeyBinding 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)

Example 4 with KeyBinding

use of net.minecraft.client.options.KeyBinding in project BedrockIfy by juancarloscp52.

the class BedrockifyClient method onInitializeClient.

@Override
public void onInitializeClient() {
    LOGGER.info("Initializing BedrockIfy Client.");
    overlay = new Overlay((MinecraftClient.getInstance()));
    reachAroundPlacement = new ReachAroundPlacement(MinecraftClient.getInstance());
    heldItemTooltips = new HeldItemTooltips();
    settingsGUI = new SettingsGUI();
    keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding("bedrockIfy.key.settings", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_B, "BedrockIfy"));
    ClientTickEvents.END_CLIENT_TICK.register(client -> {
        while (keyBinding.wasPressed()) {
            client.openScreen(settingsGUI.getConfigScreen(client.currentScreen, true));
        }
    });
    instance = this;
}
Also used : KeyBinding(net.minecraft.client.options.KeyBinding) SettingsGUI(me.juancarloscp52.bedrockify.client.gui.SettingsGUI) Overlay(me.juancarloscp52.bedrockify.client.gui.overlay.Overlay) ReachAroundPlacement(me.juancarloscp52.bedrockify.client.features.ReachAroundPlacement) HeldItemTooltips(me.juancarloscp52.bedrockify.client.features.HeldItemTooltips.HeldItemTooltips)

Example 5 with KeyBinding

use of net.minecraft.client.options.KeyBinding in project StationAPI by ModificationStation.

the class MixinGameOptions method initKeyBindings.

@Unique
private void initKeyBindings() {
    List<KeyBinding> keyBindingList = new ArrayList<>(Arrays.asList(keyBindings));
    StationAPI.EVENT_BUS.post(new KeyBindingRegisterEvent(keyBindingList));
    keyBindings = keyBindingList.toArray(new KeyBinding[0]);
}
Also used : KeyBinding(net.minecraft.client.options.KeyBinding) KeyBindingRegisterEvent(net.modificationstation.stationapi.api.client.event.option.KeyBindingRegisterEvent) Unique(org.spongepowered.asm.mixin.Unique)

Aggregations

KeyBinding (net.minecraft.client.options.KeyBinding)7 FabricKeyBinding (net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding)2 OptionButtonFactory (com.redlimerl.speedrunigt.api.OptionButtonFactory)1 SpeedRunIGTApi (com.redlimerl.speedrunigt.api.SpeedRunIGTApi)1 CategoryRegistryImpl (com.redlimerl.speedrunigt.impl.CategoryRegistryImpl)1 OptionButtonsImpl (com.redlimerl.speedrunigt.impl.OptionButtonsImpl)1 InGameTimer (com.redlimerl.speedrunigt.timer.InGameTimer)1 RunCategory (com.redlimerl.speedrunigt.timer.running.RunCategory)1 ArrayList (java.util.ArrayList)1 HeldItemTooltips (me.juancarloscp52.bedrockify.client.features.HeldItemTooltips.HeldItemTooltips)1 ReachAroundPlacement (me.juancarloscp52.bedrockify.client.features.ReachAroundPlacement)1 SettingsGUI (me.juancarloscp52.bedrockify.client.gui.SettingsGUI)1 Overlay (me.juancarloscp52.bedrockify.client.gui.overlay.Overlay)1 Environment (net.fabricmc.api.Environment)1 EventListener (net.mine_diver.unsafeevents.listener.EventListener)1 KeyBindingRegisterEvent (net.modificationstation.stationapi.api.client.event.option.KeyBindingRegisterEvent)1 Unique (org.spongepowered.asm.mixin.Unique)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1