Java 类cpw.mods.fml.common.event.FMLInterModComms.IMCEvent 实例源码

项目:MagicBees    文件:IMCManager.java   
public static void handle(IMCEvent event)
{
    for (IMCMessage message : event.getMessages())
    {
        try
        {
            if (message.key.equals("addCrumblePair"))
            {
                handleCrumbleBlock(message);
            }
            else
            {
                FMLLog.warning("Magic Bees recieved an IMC Message from a mod %s " +
                                "but does not support messages keyed with %s.",
                        message.getSender(), message.key);
            }
        }
        catch (Exception e)
        {
            FMLLog.warning("Magic Bees recieved an invalid IMC Message from a mod %s! Please inform " +
                            "the author of %s that they may not be correctly implementing message for key '%s'. Error details follow.",
                    message.getSender(), message.key);
            FMLLog.info(e.getMessage());
        }
    }
}
项目:RandomThoughtsMod    文件:RandomThoughtsMod.java   
@Mod.EventHandler
public void onIMCMessages(IMCEvent event){
    for(IMCMessage message : event.getMessages()) {
        if(message.key.equalsIgnoreCase("camoMineBlacklist")) {
            if(message.isItemStackMessage()) {
                ItemStack blacklistedStack = message.getItemStackValue();
                if(blacklistedStack.getItem() != null) {
                    TileEntityCamoMine.camouflageBlacklist.add(blacklistedStack);
                    LogHelper.info(String.format("Mod %s added %s to be blacklisted as camouflage for the Camo Mine", message.getSender(), blacklistedStack.toString()));
                } else {
                    throw new IllegalStateException(String.format("ItemStack tried to be used in registry by the mod %s has a null item.", message.getSender()));
                }
            } else {
                LogHelper.warn(String.format("Mod %s sent a non-ItemStack message, where an ItemStack was expected.", message.getSender()));
            }
        } else {
            LogHelper.warn(String.format("Mod %s used an invalid IMC key: %s", message.getSender(), message.key));
        }
    }
}
项目:AdvancedMod    文件:AdvancedMod.java   
@Mod.EventHandler
public void onIMCMessages(IMCEvent event){
    Log.info("Receiving IMC");
    for(IMCMessage message : event.getMessages()) {
        if(message.key.equalsIgnoreCase("camoMineBlacklist")) {
            if(message.isItemStackMessage()) {
                ItemStack blacklistedStack = message.getItemStackValue();
                if(blacklistedStack.getItem() != null) {
                    TileEntityCamoMine.camouflageBlacklist.add(blacklistedStack);
                    Log.info(String.format("Mod %s added %s to be blacklisted as camouflage for the Camo Mine", message.getSender(), blacklistedStack.toString()));
                } else {
                    throw new IllegalStateException(String.format("ItemStack tried to be used in registry by the mod %s has a null item.", message.getSender()));
                }
            } else {
                Log.warn(String.format("Mod %s sent a non-ItemStack message, where an ItemStack message was expected.", message.getSender()));
            }
        } else {
            Log.warn(String.format("Mod %s used an invalid IMC key: %s", message.getSender(), message.key));
        }
    }
}
项目:ForgeUpdater    文件:ForgeUpdater.java   
@EventHandler
public void interModMessages(IMCEvent event)
{
    for (IMCMessage message : event.getMessages())
    {
        if (message.key.equalsIgnoreCase("updaterInfo"))
        {
            if (message.isStringMessage())
            {
                System.out.println("The mod " + message.getSender() + " has sent the following message: " + message.getStringValue());
                try {
                    MessageDecoder.decodeMessage(message.getSender(), message.getStringValue());
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
项目:endernet    文件:EnderNet.java   
@EventHandler
public void receiveMessages(IMCEvent event) {
    ImmutableList<IMCMessage> messages = event.getMessages();
    for(IMCMessage msg : messages) {
        if(msg.key.equals("WhitelistItemNBT")) {
            EnderID.whitelistedNBTItems.add(EnderID.getItemIdentifierFor(msg.getItemStackValue()));
        }
        if(msg.key.equals("BlacklistItem")) {
            EnderID.blacklistedItems.add(EnderID.getItemIdentifierFor(msg.getItemStackValue()));
        }
        if(msg.key.equals("RegisterURIHandler")) {
            try {
                Class handlerClass = this.getClass().getClassLoader().loadClass(msg.getStringValue());
                httpServer.registerHandler((IURIHandler)handlerClass.newInstance());
            } catch(Exception e) {
                e.printStackTrace();
                log.error("Could not load handler " + msg.getStringValue() + "!");
            }
        }
    }
}
项目:connor41-etfuturum2    文件:EtFuturum.java   
@EventHandler
public void processIMCRequests(IMCEvent event) {
    for (IMCMessage message : event.getMessages())
        if (message.key.equals("register-brewing-fuel")) {
            NBTTagCompound nbt = message.getNBTValue();
            ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("Fuel"));
            int brews = nbt.getInteger("Brews");
            BrewingFuelRegistry.registerFuel(stack, brews);
        }
}
项目:EnderCore    文件:IMCRegistry.java   
public void handleEvent(IMCEvent event) {
  for (IIMC handler : handlers) {
    for (IMCMessage msg : event.getMessages()) {
      if (msg.key.equals(handler.getKey())) {
        handler.act(msg);
      }
    }
  }
}
项目:Et-Futurum    文件:EtFuturum.java   
@EventHandler
public void processIMCRequests(IMCEvent event) {
    for (IMCMessage message : event.getMessages())
        if (message.key.equals("register-brewing-fuel")) {
            NBTTagCompound nbt = message.getNBTValue();
            ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("Fuel"));
            int brews = nbt.getInteger("Brews");
            BrewingFuelRegistry.registerFuel(stack, brews);
        }
}
项目:NausicaaMod    文件:MMod.java   
@EventHandler
public void messageRecieve(IMCEvent event) {

       Iterator<IMCMessage> itr = event.getMessages().iterator();
      while(itr.hasNext()) {
         IMCMessage element = itr.next();
         logger.info("Sender: " + element.getSender() + "   Value: " + element.getStringValue() + " ");
      } 

}
项目:NausicaaMod    文件:LapMain.java   
/** this is more just for future reference than anything else
 * you dont need to understand it
 */
@Override
@EventHandler
public void messageRecieve(IMCEvent event) {

    Iterator<IMCMessage> itr = event.getMessages().iterator();
    while(itr.hasNext()) {
        IMCMessage element = itr.next();
        logger.info("Sender: " + element.getSender() + "Value: " + element.getStringValue() + " ");
    }
    System.out.println();
}
项目:NausicaaMod    文件:Main.java   
/** this is more just for future reference than anything else */
@Override
@EventHandler
public void messageRecieve(IMCEvent event) {

    Iterator<IMCMessage> itr = event.getMessages().iterator();
    while(itr.hasNext()) {
        IMCMessage element = itr.next();
        logger.info("Sender: " + element.getSender() + "Value: " + element.getStringValue() + " ");
    }
    System.out.println();
}
项目:The-Derpy-Shiz-Mod    文件:Main.java   
@EventHandler
public void IMCCallback(IMCEvent event) {
    for (IMCMessage msg : event.getMessages()) {
        switch (msg.key) {
        case "registerLeafType":
            DerpyRegistry.leafTypes.add(new BasicBlockEntry(GameRegistry.findBlock(msg.getNBTValue().getString("sourceMod"), msg.getNBTValue().getString("blockID")), msg.getNBTValue().getInteger("meta")));
            break;
        }
    }
}
项目:Open-Exchange    文件:IMCHandler.java   
public static void processIMCMessages(IMCEvent event) {
  for (IMCMessage imcMessage : event.getMessages()) {
    if (imcMessage.getMessageType() == NBTTagCompound.class) {
      if (imcMessage.key.equalsIgnoreCase(addQMCItemStack)) {
        addQMCItemStack(imcMessage);
      } else if (imcMessage.key.equalsIgnoreCase(toolBlackList)) {
        toolBlackList(imcMessage);
      }
    }
  }
}
项目:LookingGlass    文件:LookingGlass.java   
@EventHandler
public void handleIMC(IMCEvent event) {
    // Catch IMC messages and send them off to our IMC handler
    ImmutableList<IMCMessage> messages = event.getMessages();
    IMCHandler.process(messages);
}
项目:MagicBees    文件:MagicBees.java   
@Mod.EventHandler
public void handleIMCMessage(IMCEvent event)
{
    IMCManager.handle(event);
}
项目:Structures    文件:EnderStructures.java   
@EventHandler
public void onImc(IMCEvent evt) {
  processImc(evt.getMessages());
}
项目:EnderCore    文件:EnderCore.java   
@EventHandler
public void onIMCEvent(IMCEvent event) {
  IMCRegistry.INSTANCE.handleEvent(event);
}
项目:Chisel-2    文件:Chisel.java   
@EventHandler
public void onIMC(IMCEvent event) {
    for (IMCMessage msg : event.getMessages()) {
        IMCHandler.INSTANCE.handleMessage(msg);
    }
}
项目:Quantum-Energistics-2    文件:QuantumEnergistics.java   
@EventHandler
public void handleIMCMessages(IMCEvent event) {
}
项目:ForestryLegacy    文件:Forestry.java   
@IMCCallback
public void processIMCMessages(IMCEvent event) {
    core.processIMCMessages(event.getMessages());
}
项目:Open-Exchange    文件:OpenExchange.java   
@EventHandler
public void handleIMCMessages(IMCEvent event) {
  IMCHandler.processIMCMessages(event);
}
项目:AbacusCommonsLib    文件:ATemplateMod.java   
/**
 * A public method to handle what happens in an "inter-mod communication" phase.<p/>
 * From the {@link EventHandler} javadoc for methods using the {@link IMCEvent} parameter:
 * <pre>
 * IMCEvent:
 * Sent just after FMLInitializationEvent if you have IMC messages waiting from other mods
 * </pre>
 * and in IMCEvent itself:
 * <pre>
 * Subscribe to this event to receive your messages (they are sent between Init and PostInit)
 * </pre>
 * So I assume this means that any other mods that post IMC messages will be delivered, via Forge handling, to the
 * appropriate mods; if this mod is the recipient of such a message, this method should be used to process it.
 * @param event A Forge event handler for inter-mod communications
 */
@EventHandler
abstract public void intermodcommunication(IMCEvent event);