Search in sources :

Example 6 with KeyBinding

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

the class OptionListener method registerKeyBindings.

@Environment(EnvType.CLIENT)
@EventListener
public void registerKeyBindings(KeyBindingRegisterEvent event) {
    testBind = new KeyBinding("key.sltest.testBind", 21);
    event.keyBindings.add(testBind);
}
Also used : KeyBinding(net.minecraft.client.options.KeyBinding) Environment(net.fabricmc.api.Environment) EventListener(net.mine_diver.unsafeevents.listener.EventListener)

Example 7 with KeyBinding

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

the class SpeedRunIGT method onInitializeClient.

@Override
public void onInitializeClient() {
    MOD_VERSION = (FabricLoader.getInstance().getModContainer(SpeedRunIGT.MOD_ID).isPresent() ? FabricLoader.getInstance().getModContainer(SpeedRunIGT.MOD_ID).get().getMetadata().getVersion().getFriendlyString() : "Unknown+Unknown");
    // init default option buttons
    SpeedRunOption.addOptionButtonFactories(new OptionButtonsImpl().createOptionButtons().toArray(new OptionButtonFactory[0]));
    // init default categories
    new CategoryRegistryImpl().registerCategories().forEach(RunCategory::registerCategory);
    // Registry API's
    for (EntrypointContainer<SpeedRunIGTApi> entryPoint : FabricLoader.getInstance().getEntrypointContainers("speedrunigt", SpeedRunIGTApi.class)) {
        SpeedRunIGTApi api = entryPoint.getEntrypoint();
        // Registry single option button
        OptionButtonFactory singleFactory = api.createOptionButton();
        if (singleFactory != null)
            SpeedRunOption.addOptionButtonFactories(singleFactory);
        // Registry multiple option buttons
        Collection<OptionButtonFactory> multipleFactory = api.createOptionButtons();
        if (multipleFactory != null)
            SpeedRunOption.addOptionButtonFactories(multipleFactory.toArray(new OptionButtonFactory[0]));
        // Registry single category
        RunCategory singleCategory = api.registerCategory();
        if (singleCategory != null)
            RunCategory.registerCategory(singleCategory);
        // Registry multiple categories
        Collection<RunCategory> multipleCategories = api.registerCategories();
        if (multipleCategories != null)
            multipleCategories.forEach(RunCategory::registerCategory);
        API_PROVIDERS.add(entryPoint.getProvider());
    }
    // Options initialize
    SpeedRunOption.init();
    // Translate initialize
    try {
        TranslateHelper.init();
    } catch (Throwable e) {
        e.printStackTrace();
    }
    // Key Bindings initialize
    timerResetKeyBinding = KeyBindingRegistry.registerKeyBinding(new KeyBinding("speedrunigt.controls.start_timer", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_U, "speedrunigt.title.options"));
    timerStopKeyBinding = KeyBindingRegistry.registerKeyBinding(new KeyBinding("speedrunigt.controls.stop_timer", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_I, "speedrunigt.title.options"));
    // End initializing
    isInitialized = true;
    // Update checking
    SpeedRunIGTInfoScreen.checkUpdate();
    // Add default fonts
    FontUtils.copyDefaultFonts();
}
Also used : KeyBinding(net.minecraft.client.options.KeyBinding) OptionButtonFactory(com.redlimerl.speedrunigt.api.OptionButtonFactory) CategoryRegistryImpl(com.redlimerl.speedrunigt.impl.CategoryRegistryImpl) SpeedRunIGTApi(com.redlimerl.speedrunigt.api.SpeedRunIGTApi) OptionButtonsImpl(com.redlimerl.speedrunigt.impl.OptionButtonsImpl) RunCategory(com.redlimerl.speedrunigt.timer.running.RunCategory)

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