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()); } } }
@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)); } } }
@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)); } } }
@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(); } } } } }
@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() + "!"); } } } }
@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); } }
public void handleEvent(IMCEvent event) { for (IIMC handler : handlers) { for (IMCMessage msg : event.getMessages()) { if (msg.key.equals(handler.getKey())) { handler.act(msg); } } } }
@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() + " "); } }
/** 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(); }
/** 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(); }
@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; } } }
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); } } } }
@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); }
@Mod.EventHandler public void handleIMCMessage(IMCEvent event) { IMCManager.handle(event); }
@EventHandler public void onImc(IMCEvent evt) { processImc(evt.getMessages()); }
@EventHandler public void onIMCEvent(IMCEvent event) { IMCRegistry.INSTANCE.handleEvent(event); }
@EventHandler public void onIMC(IMCEvent event) { for (IMCMessage msg : event.getMessages()) { IMCHandler.INSTANCE.handleMessage(msg); } }
@EventHandler public void handleIMCMessages(IMCEvent event) { }
@IMCCallback public void processIMCMessages(IMCEvent event) { core.processIMCMessages(event.getMessages()); }
@EventHandler public void handleIMCMessages(IMCEvent event) { IMCHandler.processIMCMessages(event); }
/** * 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);