Search in sources :

Example 1 with FMLInitializationEvent

use of net.minecraftforge.fml.common.event.FMLInitializationEvent in project Charset by CharsetMC.

the class CharsetTablet method onInit.

@Mod.EventHandler
public void onInit(FMLInitializationEvent event) {
    ICommand spaceCommand = ((typesetter, tokenizer) -> typesetter.write(new WordText(" ")));
    TabletAPI.INSTANCE.registerRouter(new RouterIndex());
    TabletAPI.INSTANCE.registerRouter(new RouterSearch());
    TabletAPI.INSTANCE.registerRouter(new RouterModDocumentation("charset", "Book - Charset"));
    TabletAPI.INSTANCE.addBook("Book of Charset", "mod://charset/index");
    if (Loader.isModLoaded("simplelogic")) {
        TabletAPI.INSTANCE.registerRouter(new RouterModDocumentation("simplelogic", "Book - SimpleLogic"));
        TabletAPI.INSTANCE.addBook("The Rules of SimpleLogic", "mod://simplelogic/index");
    }
    TabletAPI.INSTANCE.registerCommand("\\", spaceCommand);
    TabletAPI.INSTANCE.registerCommand("\\ ", spaceCommand);
    TabletAPI.INSTANCE.registerCommand("\\nl", ((typesetter, tokenizer) -> typesetter.write(new WordNewline(1))));
    TabletAPI.INSTANCE.registerCommand("\\p", ((typesetter, tokenizer) -> typesetter.write(new WordNewline(2))));
    TabletAPI.INSTANCE.registerCommand("\\\\", (((typesetter, tokenizer) -> typesetter.write(new WordText("\\")))));
    TabletAPI.INSTANCE.registerCommand("\\-", (((typesetter, tokenizer) -> {
        String padS = tokenizer.getOptionalParameter();
        typesetter.write(new WordBullet(padS != null ? Integer.parseInt(padS) : 0));
    })));
    TabletAPI.INSTANCE.registerCommand("\\scale", ((typesetter, tokenizer) -> {
        String scaleS = tokenizer.getParameter("\\scale scaling amount");
        String content = tokenizer.getParameter("\\scale content");
        typesetter.pushStyle(new StyleScale(Float.parseFloat(scaleS)));
        typesetter.write(content);
        typesetter.popStyle(1);
    }));
    TabletAPI.INSTANCE.registerCommand("\\local", ((typesetter, tokenizer) -> typesetter.write(new WordTextLocalized(tokenizer.getParameter("text")))));
    TabletAPI.INSTANCE.registerCommand("\\title", ((typesetter, tokenizer) -> {
        typesetter.pushStyle(StyleFormat.ITALIC, StyleFormat.UNDERLINE, new StyleScale(2.0f));
        typesetter.write(tokenizer.getParameter("text"));
        typesetter.popStyle(3);
    }));
    TabletAPI.INSTANCE.registerCommand("\\header", ((typesetter, tokenizer) -> {
        typesetter.pushStyle(StyleFormat.BOLD, StyleFormat.UNDERLINE);
        typesetter.write(tokenizer.getParameter("text"));
        typesetter.popStyle(2);
    }));
    TabletAPI.INSTANCE.registerCommand("\\b", ((typesetter, tokenizer) -> {
        typesetter.pushStyle(StyleFormat.BOLD);
        typesetter.write(tokenizer.getParameter("text"));
        typesetter.popStyle();
    }));
    TabletAPI.INSTANCE.registerCommand("\\i", ((typesetter, tokenizer) -> {
        typesetter.pushStyle(StyleFormat.ITALIC);
        typesetter.write(tokenizer.getParameter("text"));
        typesetter.popStyle();
    }));
    TabletAPI.INSTANCE.registerCommand("\\u", ((typesetter, tokenizer) -> {
        typesetter.pushStyle(StyleFormat.UNDERLINE);
        typesetter.write(tokenizer.getParameter("text"));
        typesetter.popStyle();
    }));
    TabletAPI.INSTANCE.registerCommand("\\del", ((typesetter, tokenizer) -> {
        typesetter.pushStyle(StyleFormat.STRIKETHROUGH);
        typesetter.write(tokenizer.getParameter("text"));
        typesetter.popStyle();
    }));
    TabletAPI.INSTANCE.registerCommand("\\checkmods", new CommandCheckMods());
    TabletAPI.INSTANCE.registerCommand("\\img", new CommandImg());
    TabletAPI.INSTANCE.registerCommand("\\item", new CommandItem());
    TabletAPI.INSTANCE.registerCommand("\\url", new CommandURL());
    TabletAPI.INSTANCE.registerCommand("\\urlmissing", new CommandURLMissing());
    for (TextPrinterFormat format : TextPrinterFormat.values()) {
        TabletAPI.INSTANCE.registerPrinterStyle(format, StyleFormat.class, new StylePrinterTextFormat(format));
    }
    TabletAPI.INSTANCE.registerPrinterText(TextPrinterFormat.HTML, WordText.class, (c, w) -> ((WordText) w).getText());
}
Also used : Loader(net.minecraftforge.fml.common.Loader) ModCharset(pl.asie.charset.ModCharset) Item(net.minecraft.item.Item) ModelRegistryEvent(net.minecraftforge.client.event.ModelRegistryEvent) ModuleProfile(pl.asie.charset.lib.loader.ModuleProfile) FMLPostInitializationEvent(net.minecraftforge.fml.common.event.FMLPostInitializationEvent) pl.asie.charset.module.tablet.format.commands(pl.asie.charset.module.tablet.format.commands) pl.asie.charset.module.tablet.format.words(pl.asie.charset.module.tablet.format.words) TabletAPI(pl.asie.charset.module.tablet.format.api.TabletAPI) Side(net.minecraftforge.fml.relauncher.Side) RegistryUtils(pl.asie.charset.lib.utils.RegistryUtils) RegistryEvent(net.minecraftforge.event.RegistryEvent) FMLPreInitializationEvent(net.minecraftforge.fml.common.event.FMLPreInitializationEvent) Mod(net.minecraftforge.fml.common.Mod) FMLInitializationEvent(net.minecraftforge.fml.common.event.FMLInitializationEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) StylePrinterTextFormat(pl.asie.charset.module.tablet.format.words.text.StylePrinterTextFormat) CharsetLoadConfigEvent(pl.asie.charset.lib.config.CharsetLoadConfigEvent) pl.asie.charset.module.tablet.format.words.minecraft(pl.asie.charset.module.tablet.format.words.minecraft) MinecraftForge(net.minecraftforge.common.MinecraftForge) TextPrinterFormat(pl.asie.charset.module.tablet.format.api.TextPrinterFormat) ICommand(pl.asie.charset.module.tablet.format.api.ICommand) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) TabletAPIClient(pl.asie.charset.module.tablet.format.api.TabletAPIClient) Configuration(net.minecraftforge.common.config.Configuration) CharsetModule(pl.asie.charset.lib.loader.CharsetModule) pl.asie.charset.module.tablet.format.routers(pl.asie.charset.module.tablet.format.routers) TextPrinterFormat(pl.asie.charset.module.tablet.format.api.TextPrinterFormat) StylePrinterTextFormat(pl.asie.charset.module.tablet.format.words.text.StylePrinterTextFormat) ICommand(pl.asie.charset.module.tablet.format.api.ICommand)

Aggregations

Item (net.minecraft.item.Item)1 ModelRegistryEvent (net.minecraftforge.client.event.ModelRegistryEvent)1 MinecraftForge (net.minecraftforge.common.MinecraftForge)1 Configuration (net.minecraftforge.common.config.Configuration)1 RegistryEvent (net.minecraftforge.event.RegistryEvent)1 Loader (net.minecraftforge.fml.common.Loader)1 Mod (net.minecraftforge.fml.common.Mod)1 FMLInitializationEvent (net.minecraftforge.fml.common.event.FMLInitializationEvent)1 FMLPostInitializationEvent (net.minecraftforge.fml.common.event.FMLPostInitializationEvent)1 FMLPreInitializationEvent (net.minecraftforge.fml.common.event.FMLPreInitializationEvent)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 Side (net.minecraftforge.fml.relauncher.Side)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 ModCharset (pl.asie.charset.ModCharset)1 CharsetLoadConfigEvent (pl.asie.charset.lib.config.CharsetLoadConfigEvent)1 CharsetModule (pl.asie.charset.lib.loader.CharsetModule)1 ModuleProfile (pl.asie.charset.lib.loader.ModuleProfile)1 RegistryUtils (pl.asie.charset.lib.utils.RegistryUtils)1 ICommand (pl.asie.charset.module.tablet.format.api.ICommand)1 TabletAPI (pl.asie.charset.module.tablet.format.api.TabletAPI)1