Search in sources :

Example 31 with EventHandler

use of cpw.mods.fml.common.Mod.EventHandler 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"));
    manager = new ModManager().setPrefix(References.DOMAIN).setTab(CreativeTabs.tabAllSearch);
    config.load();
    heatDataConfig.load();
    explosiveConfig.load();
    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(TileMapRegistry.INSTANCE);
    FMLCommonHandler.instance().bus().register(TileMapRegistry.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");
    RecipeSorter.register(References.PREFIX + "shapedLarge", RecipeShapedOreLarge.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.")) {
        //TODO check for Bukkit and disable
        loader.applyModule(new ProxyASMTest());
    }
    loader.applyModule(getProxy());
    loader.applyModule(packetHandler);
    loader.applyModule(GroupProfileHandler.GLOBAL);
    loader.applyModule(GlobalAccessSystem.instance);
    //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");
    //Map commands
    enableExtendedMetaPacketSync = getConfig().getBoolean("EnableExtendedBlockMetaPacketSync", "Map_data", true, "While on extended meta values will be synced to the client. Can be disabled on both sides to save on bandwidth but will result in rendering issues if disabled.");
    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);
    //Call loader
    loader.preInit();
    //Claim json content
    JsonContentLoader.INSTANCE.claimContent(this);
    //Ore dictionary registry
    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.lib.recipe.item.MRSmelterHandler) WorldActionQue(com.builtbroken.mc.lib.world.edit.thread.WorldActionQue) ItemSelectionWand(com.builtbroken.mc.core.content.tool.ItemSelectionWand) Calendar(java.util.Calendar) MRHandlerItemStack(com.builtbroken.mc.lib.recipe.item.MRHandlerItemStack) ExplosiveHandlerTNT(com.builtbroken.mc.prefab.explosive.handler.ExplosiveHandlerTNT) ItemScrewdriver(com.builtbroken.mc.core.content.tool.ItemScrewdriver) MRHandlerCast(com.builtbroken.mc.lib.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.lib.data.mass.MassRegistry) MRHandlerItemStack(com.builtbroken.mc.lib.recipe.item.MRHandlerItemStack) ItemStack(net.minecraft.item.ItemStack) File(java.io.File) ToolModeGeneral(com.builtbroken.mc.core.content.tool.screwdriver.ToolModeGeneral) MRHandlerFluidStack(com.builtbroken.mc.lib.recipe.fluid.MRHandlerFluidStack) DevWorldLoader(com.builtbroken.mc.core.content.world.DevWorldLoader) EventHandler(cpw.mods.fml.common.Mod.EventHandler)

Example 32 with EventHandler

use of cpw.mods.fml.common.Mod.EventHandler in project Engine by VoltzEngine-Project.

the class Engine method serverStopping.

@EventHandler
public void serverStopping(FMLServerStoppingEvent event) {
    //TODO save qued objects
    synchronized (VoltzEngineAPI.WORKER_THREADS) {
        for (IWorkerThread thread : VoltzEngineAPI.WORKER_THREADS.values()) {
            logger().info("Killing thread " + thread);
            thread.kill();
        }
    }
}
Also used : IWorkerThread(com.builtbroken.mc.api.process.IWorkerThread) EventHandler(cpw.mods.fml.common.Mod.EventHandler)

Example 33 with EventHandler

use of cpw.mods.fml.common.Mod.EventHandler in project BluePower by Qmunity.

the class BluePower method postInit.

@EventHandler
public void postInit(FMLPostInitializationEvent event) {
    CompatibilityUtils.postInit(event);
    proxy.initRenderers();
    Recipes.init(CraftingManager.getInstance());
    AlloyFurnaceRegistry.getInstance().generateRecyclingRecipes();
    RedstoneApi.getInstance().registerRedstoneProvider(new RedstoneProviderVanilla());
}
Also used : RedstoneProviderVanilla(com.bluepowermod.redstone.RedstoneProviderVanilla) BPEventHandler(com.bluepowermod.event.BPEventHandler) WorldConversionEventHandler(com.bluepowermod.convert.WorldConversionEventHandler) EventHandler(cpw.mods.fml.common.Mod.EventHandler)

Example 34 with EventHandler

use of cpw.mods.fml.common.Mod.EventHandler in project BluePower by Qmunity.

the class BluePower method event.

@EventHandler
public void event(FMLMissingMappingsEvent event) {
    for (MissingMapping mapping : event.get()) {
        String name = mapping.name;
        if (mapping.name.startsWith("bluepower:lamp")) {
            name = name.replace("silver", "light_gray");
            if (mapping.type == Type.BLOCK) {
                mapping.remap(GameData.getBlockRegistry().getObject(name));
            } else {
                mapping.remap(GameData.getItemRegistry().getObject(name));
            }
            continue;
        }
        if (mapping.name.equals("bluepower:bluepower_multipart")) {
            mapping.ignore();
            continue;
        }
        name = name.replace("silver", "light_gray");
        name = name.replace("bluestoneWire", "wire.bluestone");
        name = name.replace("cagelamp", "cagelamp.").replace("fixture", "fixture.");
        if (name.contains("inverted"))
            name = "bluepower:part." + name.substring("bluepower:part.inverted".length()) + ".inverted";
        if (name.equals("bluepower:stone_wire"))
            name = "bluepower:bluestone_wire_tile";
        if (name.equals("bluepower:stone_cathode"))
            name = "bluepower:bluestone_cathode_tile";
        if (name.equals("bluepower:stone_anode"))
            name = "bluepower:bluestone_anode_tile";
        if (name.equals("bluepower:stone_pointer"))
            name = "bluepower:bluestone_pointer_tile";
        if (name.equals("bluepower:silicon_chip"))
            name = "bluepower:silicon_chip_tile";
        if (name.equals("bluepower:taintedsilicon_chip"))
            name = "bluepower:tainted_silicon_chip_tile";
        if (name.equals("bluepower:quartz_resonator"))
            name = "bluepower:quartz_resonator_tile";
        Item item = GameData.getItemRegistry().getObject(name);
        if (item == null)
            continue;
        mapping.remap(item);
    }
}
Also used : Item(net.minecraft.item.Item) MissingMapping(cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping) BPEventHandler(com.bluepowermod.event.BPEventHandler) WorldConversionEventHandler(com.bluepowermod.convert.WorldConversionEventHandler) EventHandler(cpw.mods.fml.common.Mod.EventHandler)

Aggregations

EventHandler (cpw.mods.fml.common.Mod.EventHandler)34 ItemStack (net.minecraft.item.ItemStack)9 WorldConversionEventHandler (com.bluepowermod.convert.WorldConversionEventHandler)4 BPEventHandler (com.bluepowermod.event.BPEventHandler)4 MRHandlerItemStack (com.builtbroken.mc.lib.recipe.item.MRHandlerItemStack)4 Configuration (net.minecraftforge.common.config.Configuration)4 ServerCommandManager (net.minecraft.command.ServerCommandManager)3 IWorkerThread (com.builtbroken.mc.api.process.IWorkerThread)2 MissingMapping (cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping)2 ICommandManager (net.minecraft.command.ICommandManager)2 AMConfig (am2.configuration.AMConfig)1 SkillConfiguration (am2.configuration.SkillConfiguration)1 GUIHandler (com.bluepowermod.client.gui.GUIHandler)1 Config (com.bluepowermod.init.Config)1 RedstoneProviderQmunityLib (com.bluepowermod.redstone.RedstoneProviderQmunityLib)1 RedstoneProviderVanilla (com.bluepowermod.redstone.RedstoneProviderVanilla)1 WorldGenerationHandler (com.bluepowermod.world.WorldGenerationHandler)1 ProxyASMTest (com.builtbroken.mc.core.asm.ProxyASMTest)1 BlockHeatedStone (com.builtbroken.mc.core.content.blocks.BlockHeatedStone)1 ItemDevData (com.builtbroken.mc.core.content.debug.ItemDevData)1