Search in sources :

Example 1 with SpeedRunIGTApi

use of com.redlimerl.speedrunigt.api.SpeedRunIGTApi 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

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 RunCategory (com.redlimerl.speedrunigt.timer.running.RunCategory)1 KeyBinding (net.minecraft.client.options.KeyBinding)1