Java 类net.minecraftforge.fml.common.event.FMLInterModComms.IMCEvent 实例源码

项目:NotEnoughCodecs    文件:NotEnoughCodecs.java   
@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);
        }
}
项目:Toms-Mod    文件:CoreInit.java   
@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());
        }
    }
}
项目:Mini-Bosses    文件:MiniBosses.java   
@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!");
    }
}
项目:Battlegear2    文件:Battlegear.java   
@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);
}
项目:ExoMagica    文件:ExoMagica.java   
@EventHandler
public void receiveIMC(IMCEvent event) {
    for(IMCMessage message : event.getMessages()) {
        ExoMagicaAPI.processIMC(message);
    }
}
项目:EverythingBlocks    文件:EverythingBlocks.java   
@EventHandler
public void processModMessages(IMCEvent event) {
    ModMessages.handleMessage(event);
}
项目:IGW-mod    文件:ServerProxy.java   
@Override
public void processIMC(IMCEvent event){}
项目:EnderIO    文件:EnderIO.java   
@EventHandler
public void onImc(@Nonnull IMCEvent evt) {
  processImc(evt.getMessages());
}