@EventHandler public void handleIMC(IMCEvent evt) { NBTTagCompound extensions = new NBTTagCompound(); NBTTagList data = new NBTTagList(); for (Map.Entry<String, String> e : KNOWN_MIME_TYPES.entrySet()) { NBTTagCompound entry = new NBTTagCompound(); entry.setString("mime", e.getKey()); entry.setString("ext", e.getValue()); data.appendTag(entry); } extensions.setTag("data", data); for (IMCMessage msg : evt.getMessages()) if ("listCodecs".equalsIgnoreCase(msg.key)) { String sender = msg.getSender(); Log.info("Received codec list request from %s, responding", sender); FMLInterModComms.sendMessage(sender, "knownCodecs", extensions); } }
@EventHandler public static void onIMCMessages(IMCEvent event) { log.info("Receiving IMC"); for (IMCMessage message : event.getMessages()) { try { IMCHandler.receive(message); } catch (Exception e) { log.error("CRITICAL EXCEPTION occurred while handling IMC. Ignoring the current IMC message!"); log.error(e.toString()); e.printStackTrace(); log.error("Message sent by: " + message.getSender()); } } }
@EventHandler public void handleIMC(IMCEvent event) { for(net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage message : event.getMessages()) { if(message.isStringMessage() && message.getStringValue().contains(":")) { String[] data = message.getStringValue().split(":"); entityBanMap.put(data[0], Integer.valueOf(data[1])); } logger.log(Level.INFO, "Mod: " + message.getSender() + " has sent a ban request!"); } }
@Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { logger = event.getModLog(); knightArmourMaterial = EnumHelper.addArmorMaterial("knights.armour", "battlegear2:knight", 25, new int[]{3, 5, 7, 3}, 15, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 1.5F); ResourceLocation sound = new ResourceLocation(MODID, "shield"); shieldSound = GameRegistry.register(new SoundEvent(sound).setRegistryName(sound)); BattlegearConfig.getConfig(new Configuration(event.getSuggestedConfigurationFile())); if((event.getSourceFile().getName().endsWith(".jar") || debug) && event.getSide().isClient()){ try { Class.forName("mods.mud.ModUpdateDetector").getDeclaredMethod("registerMod", ModContainer.class, String.class, String.class).invoke(null, FMLCommonHandler.instance().findContainerFor(this), "https://raw.github.com/Mine-and-blade-admin/Battlegear2/master/battlegear_update.xml", "https://raw.github.com/Mine-and-blade-admin/Battlegear2/master/changelog.md" ); } catch (Throwable e) { e.printStackTrace(); } } proxy.registerHandlers(); QuiverArrowRegistry.addArrowToRegistry(Items.ARROW, EntityTippedArrow.class); QuiverArrowRegistry.addArrowToRegistry(Items.TIPPED_ARROW, EntityTippedArrow.class); QuiverArrowRegistry.addArrowToRegistry(Items.SPECTRAL_ARROW, EntitySpectralArrow.class); //Fetch early messages IMCEvent imc = new IMCEvent(); imc.applyModContainer(FMLCommonHandler.instance().findContainerFor(MODID)); onMessage(imc); }
@EventHandler public void receiveIMC(IMCEvent event) { for(IMCMessage message : event.getMessages()) { ExoMagicaAPI.processIMC(message); } }
@EventHandler public void processModMessages(IMCEvent event) { ModMessages.handleMessage(event); }
@Override public void processIMC(IMCEvent event){}
@EventHandler public void onImc(@Nonnull IMCEvent evt) { processImc(evt.getMessages()); }