Search in sources :

Example 1 with IMCMessage

use of net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage in project EnderIO by SleepyTrousers.

the class EnderIO method processImc.

void processImc(ImmutableList<IMCMessage> messages) {
    for (IMCMessage msg : messages) {
        String key = msg.key;
        Log.info("Processing IMC message " + key + " from " + msg.getSender());
        try {
            if (msg.isStringMessage()) {
                String value = msg.getStringValue();
                if (value == null) {
                    return;
                }
                if (IMC.XML_RECIPE.equals(key)) {
                    RecipeLoader.addIMCRecipe(value);
                } else if (IMC.TELEPORT_BLACKLIST_ADD.equals(key)) {
                    Config.TRAVEL_BLACKLIST.add(value);
                } else if (IMC.REDSTONE_CONNECTABLE_ADD.equals(key)) {
                    ConnectivityTool.registerRedstoneAware(value);
                }
            } else if (msg.isResourceLocationMessage()) {
                ResourceLocation value = msg.getResourceLocationValue();
                if (IMC.SOUL_VIAL_BLACKLIST.equals(key)) {
                    CapturedMob.addToBlackList(value);
                } else if (IMC.SOUL_VIAL_UNSPAWNABLELIST.equals(key)) {
                    CapturedMob.addToUnspawnableList(value);
                }
            } else if (msg.isNBTMessage()) {
                final NBTTagCompound nbtValue = msg.getNBTValue();
                if (nbtValue == null) {
                    return;
                }
                if (IMC.SOUL_BINDER_RECIPE.equals(key)) {
                    SoulBinderRecipeManager.getInstance().addRecipeFromNBT(nbtValue);
                } else if (IMC.FLUID_FUEL_ADD.equals(key)) {
                    FluidFuelRegister.instance.addFuel(nbtValue);
                } else if (IMC.FLUID_COOLANT_ADD.equals(key)) {
                    FluidFuelRegister.instance.addCoolant(nbtValue);
                }
            } else if (msg.isItemStackMessage()) {
                if (IMC.PAINTER_WHITELIST_ADD.equals(key)) {
                    PaintSourceValidator.instance.addToWhitelist(msg.getItemStackValue());
                } else if (IMC.PAINTER_BLACKLIST_ADD.equals(key)) {
                    PaintSourceValidator.instance.addToBlacklist(msg.getItemStackValue());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Log.error("Error occurred handling IMC message " + key + " from " + msg.getSender());
        }
    }
}
Also used : IMCMessage(net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage) ResourceLocation(net.minecraft.util.ResourceLocation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 2 with IMCMessage

use of net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage in project BiomeTweaker by superckl.

the class BiomeTweaker method onPreInit.

@EventHandler
public void onPreInit(final FMLPreInitializationEvent e) {
    final ProgressBar bar = ProgressManager.push("BiomeTweaker PreInitialization", 6, true);
    LogHelper.setLogger(e.getModLog());
    bar.step("Reading config");
    if (!this.signed) {
        LogHelper.warn("Hey... uhm... this is awkward but, it looks like you're using an unofficial version of BiomeTweaker. Where exactly did you get this from?");
        LogHelper.warn("Unless I (superckl) sent you this version, don't expect to get any support for it.");
    }
    this.config = new Config(new File(Loader.instance().getConfigDir(), ModData.MOD_NAME + "/"));
    this.config.loadValues();
    final List<IMCMessage> messages = FMLInterModComms.fetchRuntimeMessages(ModData.MOD_ID);
    for (final IMCMessage message : messages) if (message.key.equals("enableTweak") && message.isStringMessage()) {
        LogHelper.debug("Received enableTweak IMC message from " + message.getSender() + ", enabling tweak: " + message.getStringValue());
        this.enabledTweaks.add(message.getStringValue());
    }
    bar.step("Initializing scripting enviroment");
    final File scripts = new File(this.config.getBtConfigFolder(), "scripts/");
    scripts.mkdirs();
    this.commandManager = new BasicScriptCommandManager();
    ScriptCommandRegistry.INSTANCE.registerScriptCommandManager(ModData.MOD_ID, this.commandManager);
    BiomeTweaker.proxy.initProperties();
    BiomeTweaker.proxy.setupScripts(e.getAsmData());
    bar.step("Pre-Initializing Integration");
    IntegrationManager.INSTANCE.preInit();
    bar.step("Registering handlers");
    BiomeTweaker.proxy.registerHandlers();
    bar.step("Parsing scripts");
    this.parseScripts();
    bar.step("Applying scripts");
    this.commandManager.applyCommandsFor(ApplicationStage.PRE_INIT);
    ProgressManager.pop(bar);
}
Also used : IMCMessage(net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage) Config(me.superckl.biometweaker.config.Config) BasicScriptCommandManager(me.superckl.api.superscript.script.command.BasicScriptCommandManager) ProgressBar(net.minecraftforge.fml.common.ProgressManager.ProgressBar) File(java.io.File) EventHandler(net.minecraftforge.fml.common.Mod.EventHandler)

Aggregations

IMCMessage (net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage)2 File (java.io.File)1 BasicScriptCommandManager (me.superckl.api.superscript.script.command.BasicScriptCommandManager)1 Config (me.superckl.biometweaker.config.Config)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 EventHandler (net.minecraftforge.fml.common.Mod.EventHandler)1 ProgressBar (net.minecraftforge.fml.common.ProgressManager.ProgressBar)1