Search in sources :

Example 1 with ItemSelectionWand

use of com.builtbroken.mc.core.content.tool.ItemSelectionWand in project Engine by VoltzEngine-Project.

the class Engine method preInit.

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    // Init API values
    VoltzEngineAPI.massRegistry = new MassRegistry();
    // Init run time references
    References.GLOBAL_CONFIG_FOLDER = event.getModConfigurationDirectory();
    References.ROOT_FOLDER = References.GLOBAL_CONFIG_FOLDER.getParentFile();
    References.BBM_CONFIG_FOLDER = new File(event.getModConfigurationDirectory(), "bbm");
    // Load config files
    config = new Configuration(new File(References.BBM_CONFIG_FOLDER, "ve/VoltzEngine.cfg"));
    heatDataConfig = new Configuration(new File(event.getModConfigurationDirectory(), "bbm/ve/HeatMap.cfg"));
    explosiveConfig = new Configuration(new File(event.getModConfigurationDirectory(), "bbm/ve/Explosives.cfg"));
    loader = new LoadableHandler();
    manager = new ModManager().setPrefix(References.DOMAIN).setTab(CreativeTabs.tabAllSearch);
    config.load();
    heatDataConfig.load();
    explosiveConfig.load();
    References.LOGGER = logger;
    ConfigScanner.instance().generateSets(event.getAsmData());
    ConfigHandler.sync(getConfig(), References.DOMAIN);
    NetworkRegistry.INSTANCE.registerGuiHandler(this, proxy);
    MinecraftForge.EVENT_BUS.register(this);
    MinecraftForge.EVENT_BUS.register(proxy);
    MinecraftForge.EVENT_BUS.register(SaveManager.instance());
    MinecraftForge.EVENT_BUS.register(new InteractionHandler());
    MinecraftForge.EVENT_BUS.register(SelectionHandler.INSTANCE);
    MinecraftForge.EVENT_BUS.register(RadarRegistry.INSTANCE);
    FMLCommonHandler.instance().bus().register(RadarRegistry.INSTANCE);
    MinecraftForge.EVENT_BUS.register(RadioRegistry.INSTANCE);
    FMLCommonHandler.instance().bus().register(RadioRegistry.INSTANCE);
    FMLCommonHandler.instance().bus().register(new WorldActionQue());
    FMLCommonHandler.instance().bus().register(TileTaskTickHandler.INSTANCE);
    FMLCommonHandler.instance().bus().register(SelectionHandler.INSTANCE);
    FMLCommonHandler.instance().bus().register(proxy);
    // Load heat configs
    enabledHeatMap = heatDataConfig.getBoolean("EnabledHeatMap", Configuration.CATEGORY_GENERAL, true, "Heat map handles interaction of heat based energy and the world. Disable only if it causes issues or you want to reduce world file size. If disabled it can prevent machines from working.");
    // Load explosive configs
    log_registering_explosives = explosiveConfig.getBoolean("EnableRegisterLogging", Configuration.CATEGORY_GENERAL, false, "Adds debug each time a mod registers an explosive handler. Should only be enabled to figure out which mod is overriding another mod's explosive");
    MachineRecipeType.ITEM_SMELTER.setHandler(new MRSmelterHandler());
    MachineRecipeType.ITEM_GRINDER.setHandler(new MRHandlerItemStack(MachineRecipeType.ITEM_GRINDER.INTERNAL_NAME));
    MachineRecipeType.ITEM_CRUSHER.setHandler(new MRHandlerItemStack(MachineRecipeType.ITEM_CRUSHER.INTERNAL_NAME));
    MachineRecipeType.ITEM_WASHER.setHandler(new MRHandlerItemStack(MachineRecipeType.ITEM_WASHER.INTERNAL_NAME));
    MachineRecipeType.ITEM_SAWMILL.setHandler(new MRHandlerItemStack(MachineRecipeType.ITEM_SAWMILL.INTERNAL_NAME));
    MachineRecipeType.FLUID_SMELTER.setHandler(new MRHandlerFluidStack(MachineRecipeType.FLUID_SMELTER.INTERNAL_NAME));
    MachineRecipeType.FLUID_CAST.setHandler(new MRHandlerCast());
    RecipeSorter.register(References.PREFIX + "sheetMetalTools", RecipeSheetMetal.class, SHAPED, "after:minecraft:shaped");
    RecipeSorter.register(References.PREFIX + "Tools", RecipeTool.class, SHAPED, "after:minecraft:shaped");
    // Internal systems
    if (config.getBoolean("ASMTestingEnabled", "Internal", true, "Enables the testing of the internally used ASM code, used to ensure quality of the game. Only disable if you know the ASM is functional or there are issues with it running. Normally though if the ASM test fails then the ASM code itself was not injected. Which will result in several features of the mod not functioning correctly.")) {
        loader.applyModule(new ProxyASMTest());
    }
    loader.applyModule(getProxy());
    loader.applyModule(packetHandler);
    loader.applyModule(GroupProfileHandler.GLOBAL);
    // Recipes
    loader.applyModule(SmeltingRecipeLoad.class);
    loader.applyModule(CrusherRecipeLoad.class);
    loader.applyModule(GrinderRecipeLoad.class);
    loader.applyModule(FluidSmelterRecipeLoad.class);
    loader.applyModule(CastRecipeLoader.class);
    loader.applyModule(GearRecipeLoader.class);
    loader.applyModule(RodRecipeLoader.class);
    loader.applyModule(PlateRecipeLoader.class);
    loader.applyModule(NuggetRecipeLoader.class);
    loader.applyModule(WireRecipeLoader.class);
    loader.applyModule(ScrewRecipeLoader.class);
    loader.applyModule(JsonContentLoader.INSTANCE);
    // Mod Support
    config.setCategoryComment("Mod_Support", "If true the proxy class for the mod will be loaded enabling support, set to false if support is not required or breaks the game.");
    // Uses reflection instead of API files
    loader.applyModule(NEIProxy.class);
    loader.applyModule(OCProxy.class, Mods.OC.isLoaded());
    loader.applyModule(TinkerProxy.class, Mods.TINKERS.isLoaded());
    loader.applyModule(AEProxy.class, Mods.AE.isLoaded());
    loader.applyModule(ICProxy.class, Mods.IC2.isLoaded());
    loader.applyModule(BCProxy.class, Mods.BC.isLoaded());
    loader.applyModule(MekProxy.class, Mods.MEKANISM.isLoaded());
    loader.applyModule(ProjectEProxy.class, Mods.PROJECT_E.isLoaded());
    TriggerCauseRegistry.register("entity", new TriggerNBTBuilder("entity"));
    TriggerCauseRegistry.register("impactEntity", new TriggerNBTBuilder("impactEntity"));
    TriggerCauseRegistry.register("entityImpactBlock", new TriggerNBTBuilder("entityImpactBlock"));
    TriggerCauseRegistry.register("entityImpactEntity", new TriggerNBTBuilder("entityImpactEntity"));
    TriggerCauseRegistry.register("explosion", new TriggerNBTBuilder("explosion"));
    TriggerCauseRegistry.register("fire", new TriggerNBTBuilder("fire"));
    TriggerCauseRegistry.register("redstone", new TriggerNBTBuilder("redstone"));
    // Load dev only content
    if (runningAsDev) {
        loader.applyModule(new DevWorldLoader());
    }
    // Check if RF api exists
    boolean shouldLoadRFHandler = true;
    for (String s : new String[] { "IEnergyConnection", "IEnergyContainerItem", "IEnergyHandler", "IEnergyProvider", "IEnergyReceiver", "IEnergyStorage" }) {
        try {
            Class clazz = Class.forName("cofh.api.energy." + s, false, this.getClass().getClassLoader());
            if (clazz == null) {
                shouldLoadRFHandler = false;
                break;
            }
        } catch (ClassNotFoundException e) {
            shouldLoadRFHandler = false;
            logger().error("Not loading RF support as we couldn't detect " + "cofh.api.energy." + s + " class or interface.");
            break;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if (shouldLoadRFHandler) {
        loader.applyModule(RFLoader.class);
        loader.applyModule(TEProxy.class, Mods.TF_EXPANSION.isLoaded());
    }
    PotionUtility.resizePotionArray();
    // Manually registered configs TODO setup threw sync system (once the system is tested)
    CommandVE.disableCommands = getConfig().getBoolean("DisableServerCommands", "Commands", false, "Turns off all commands built into Voltz Engine");
    CommandVE.disableButcherCommand = getConfig().getBoolean("DisableButcherCommands", "Commands", false, "Turns off butcher command");
    CommandVE.disableClearCommand = getConfig().getBoolean("DisableClearCommands", "Commands", false, "Turns off clear command");
    CommandVE.disableRemoveCommand = getConfig().getBoolean("DisableRemoverCommands", "Commands", false, "Turns off remove command");
    ToolMode.REGISTRY.add(new ToolModeGeneral());
    ToolMode.REGISTRY.add(new ToolModeRotation());
    /**
     * Multiblock Handling
     */
    if (getConfig().get("Content", "LoadInstantHole", runningAsDev, "This is a developer tool for checking if ores generated correctly. It creates a chunk sized hole in the ground replacing stone with air, and air with glass. Never enable or give this to normal users as it can be used for greifing.").getBoolean(runningAsDev)) {
        instaHole = contentRegistry.newItem("ve.instanthole", new ItemInstaHole());
    }
    if (getConfig().get("Content", "LoadDevDataTool", runningAsDev, "This is a developer tool for checking data on blocks and tile").getBoolean(runningAsDev)) {
        itemDevTool = contentRegistry.newItem("ve.devTool", new ItemDevData());
    }
    if (getConfig().get("Content", "LoadScrewDriver", true, "Basic tool for configuring, rotating, and picking up machines.").getBoolean(true)) {
        itemWrench = getManager().newItem("ve.screwdriver", new ItemScrewdriver());
    }
    if (getConfig().get("Content", "LoadSelectionTool", true, "Admin tool for selecting areas on the ground for world manipulation or other tasks.").getBoolean(true)) {
        itemSelectionTool = getManager().newItem("ve.selectiontool", new ItemSelectionWand());
    }
    if (Engine.runningAsDev) {
        blockInfInventory = getManager().newBlock(TileInfInv.class);
    }
    ExplosiveRegistry.registerOrGetExplosive(References.DOMAIN, "TNT", new ExplosiveHandlerTNT());
    final int tntValue = 8;
    ExplosiveRegistry.registerExplosiveItem(new ItemStack(Blocks.tnt), ExplosiveRegistry.get("TNT"), tntValue);
    ExplosiveRegistry.registerExplosiveItem(new ItemStack(Items.gunpowder), ExplosiveRegistry.get("TNT"), tntValue / 5.0);
    // Creeper skull
    ExplosiveRegistry.registerExplosiveItem(new ItemStack(Items.skull, 1, 4), ExplosiveRegistry.get("TNT"), tntValue / 10.0);
    loader.preInit();
    OreDictionary.registerOre(OreNames.WOOD_STICK, Items.stick);
    OreDictionary.registerOre(OreNames.STRING, Items.string);
    OreDictionary.registerOre(OreNames.FLINT, Items.flint);
    Calendar calendar = Calendar.getInstance();
    if (calendar.get(2) + 1 == 12 && calendar.get(5) >= 24 && calendar.get(5) <= 26) {
        XMAS = true;
    }
}
Also used : Configuration(net.minecraftforge.common.config.Configuration) TriggerNBTBuilder(com.builtbroken.mc.prefab.trigger.TriggerNBTBuilder) ProxyASMTest(com.builtbroken.mc.core.asm.ProxyASMTest) ModManager(com.builtbroken.mc.core.registry.ModManager) ItemDevData(com.builtbroken.mc.core.content.debug.ItemDevData) MRSmelterHandler(com.builtbroken.mc.prefab.recipe.item.MRSmelterHandler) LoadableHandler(com.builtbroken.mc.lib.mod.loadable.LoadableHandler) WorldActionQue(com.builtbroken.mc.lib.world.edit.thread.WorldActionQue) ItemSelectionWand(com.builtbroken.mc.core.content.tool.ItemSelectionWand) MRHandlerItemStack(com.builtbroken.mc.prefab.recipe.item.MRHandlerItemStack) ExplosiveHandlerTNT(com.builtbroken.mc.prefab.explosive.handler.ExplosiveHandlerTNT) ItemScrewdriver(com.builtbroken.mc.core.content.tool.ItemScrewdriver) MRHandlerCast(com.builtbroken.mc.prefab.recipe.cast.MRHandlerCast) ItemInstaHole(com.builtbroken.mc.core.content.debug.ItemInstaHole) TileInfInv(com.builtbroken.mc.core.content.debug.TileInfInv) ToolModeRotation(com.builtbroken.mc.core.content.tool.screwdriver.ToolModeRotation) InteractionHandler(com.builtbroken.mc.core.handler.InteractionHandler) MassRegistry(com.builtbroken.mc.core.registry.MassRegistry) ItemStack(net.minecraft.item.ItemStack) MRHandlerItemStack(com.builtbroken.mc.prefab.recipe.item.MRHandlerItemStack) File(java.io.File) ToolModeGeneral(com.builtbroken.mc.core.content.tool.screwdriver.ToolModeGeneral) MRHandlerFluidStack(com.builtbroken.mc.prefab.recipe.fluid.MRHandlerFluidStack) DevWorldLoader(com.builtbroken.mc.core.content.world.DevWorldLoader) EventHandler(cpw.mods.fml.common.Mod.EventHandler)

Aggregations

ProxyASMTest (com.builtbroken.mc.core.asm.ProxyASMTest)1 ItemDevData (com.builtbroken.mc.core.content.debug.ItemDevData)1 ItemInstaHole (com.builtbroken.mc.core.content.debug.ItemInstaHole)1 TileInfInv (com.builtbroken.mc.core.content.debug.TileInfInv)1 ItemScrewdriver (com.builtbroken.mc.core.content.tool.ItemScrewdriver)1 ItemSelectionWand (com.builtbroken.mc.core.content.tool.ItemSelectionWand)1 ToolModeGeneral (com.builtbroken.mc.core.content.tool.screwdriver.ToolModeGeneral)1 ToolModeRotation (com.builtbroken.mc.core.content.tool.screwdriver.ToolModeRotation)1 DevWorldLoader (com.builtbroken.mc.core.content.world.DevWorldLoader)1 InteractionHandler (com.builtbroken.mc.core.handler.InteractionHandler)1 MassRegistry (com.builtbroken.mc.core.registry.MassRegistry)1 ModManager (com.builtbroken.mc.core.registry.ModManager)1 LoadableHandler (com.builtbroken.mc.lib.mod.loadable.LoadableHandler)1 WorldActionQue (com.builtbroken.mc.lib.world.edit.thread.WorldActionQue)1 ExplosiveHandlerTNT (com.builtbroken.mc.prefab.explosive.handler.ExplosiveHandlerTNT)1 MRHandlerCast (com.builtbroken.mc.prefab.recipe.cast.MRHandlerCast)1 MRHandlerFluidStack (com.builtbroken.mc.prefab.recipe.fluid.MRHandlerFluidStack)1 MRHandlerItemStack (com.builtbroken.mc.prefab.recipe.item.MRHandlerItemStack)1 MRSmelterHandler (com.builtbroken.mc.prefab.recipe.item.MRSmelterHandler)1 TriggerNBTBuilder (com.builtbroken.mc.prefab.trigger.TriggerNBTBuilder)1