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

项目: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);
        }
}
项目:ExoMagica    文件:ExoMagicaAPI.java   
protected static void processIMC(IMCMessage message) {
    if(message.key.equalsIgnoreCase("API") || message.key.equalsIgnoreCase("getAPI")) {
        createAPIHandler(message);
    } else {
        ExoMagica.LOG.debug("{} sent an unknown key: {}", message.getSender(), message.key);
    }
}
项目: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());
        }
    }
}
项目:Factorization    文件:RecipeViewer.java   
public static void handleImc(IMCMessage message) throws Throwable {
    if (message.key.equals("AddRecipeCategory")) {
        addRecipeCategory(message.getStringValue());
    } else if (message.key.equals("AddRecipeCategoryGuided")) {
        NBTTagCompound tag = message.getNBTValue();
        addRecipeCategory(tag.getString("category"));
        GuidedReflectionWriter.register(tag);
    }
}
项目:arcadian-octo-duck    文件:IMCHandler.java   
public static void processIMCMessages(List<IMCMessage> imcMessages) {
    if (imcMessages != null && imcMessages.size() > 0) {
        for (IMCMessage message : imcMessages) {
            if (message != null && message.isStringMessage()) {
                if (blackListKey.equalsIgnoreCase(message.key)) {
                    ModEventHandler.mobBlackList.add(message.getStringValue());
                    LogUtil.logInfo("%s has blacklisted %s", message.getSender(), message.getStringValue());
                } else if (whiteListKey.equalsIgnoreCase(message.key)) {
                    ModEventHandler.mobWhiteList.add(message.getStringValue());
                    LogUtil.logInfo("%s has whitelisted %s", message.getSender(), message.getStringValue());
                }
            }
        }
    }
}
项目:ExoMagica    文件:ExoMagica.java   
@EventHandler
public void receiveIMC(IMCEvent event) {
    for(IMCMessage message : event.getMessages()) {
        ExoMagicaAPI.processIMC(message);
    }
}
项目:Toms-Mod    文件:IMCHandler.java   
public static void receive(IMCMessage msg) throws Exception {
    if (msg.key.equalsIgnoreCase("addRecipe")) {
        if (msg.isNBTMessage()) {
            NBTTagCompound nbt = msg.getNBTValue();
            if (nbt != null) {
                int id = nbt.getInteger("id");
                NBTTagCompound tag = nbt.getCompoundTag("msg");
                if (id == 0) {
                    /*ElectrolyzerRecipesHandler.add(FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("input")), tag.getInteger("energy"),
                            FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("output1")),
                            tag.getBoolean("out2") ? FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("output2")) : null,
                                    tag.getBoolean("out3") ? FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("output3")) : null,
                                            tag.getBoolean("out4") ? FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("output4")) : null);
                    log().debug("Electrolyzer Recipe Added");*/
                } else if (id == 1) {
                    /*NBTTagCompound b1 = tag.getCompoundTag("block1");
                    NBTTagCompound b2 = tag.getCompoundTag("block2");
                    NBTTagCompound bO = tag.getCompoundTag("blockOut");
                    Block block1 = findBlock(b1.getString("modid"), b1.getString("blockName"));
                    Block block2 = findBlock(b2.getString("modid"), b2.getString("blockName"));
                    Block blockOut = findBlock(bO.getString("modid"), bO.getString("blockName"));
                    MultiblockCrafterRecipeHandler.add(block1, block2, blockOut);
                    log().debug("Multiblock Crafter Recipe Added");*/
                } else {
                    log().error(String.format("Mod %s sent an unregistered recipe mode message. Report this to the mod author.", msg.getSender()));
                }
            } else {
                log().error(String.format("Mod %s sent a null NBT message! Report this to the mod author.", msg.getSender()));
            }
        } else {
            log().error(String.format("Mod %s sent a non-NBT message, where an NBT message was expected. Report this to the mod author.", msg.getSender()));
        }
        /*}else if(msg.key.equalsIgnoreCase("glass")){
        if(msg.isNBTMessage()) {
            NBTTagCompound nbt = msg.getNBTValue();
            if(nbt != null){
                Block block1 = findBlock(nbt.getString("modid"), nbt.getString("blockName"));
                GlobalFields.glassBlocks.put(block1, nbt.getFloat("t"));
            }else{
                log().error(String.format("Mod %s sent a null NBT message! Report this to the mod author.", msg.getSender()));
            }
        }else{
            log().error(String.format("Mod %s sent a non-NBT message, where an NBT message was expected. Report this to the mod author.", msg.getSender()));
        }*/
    } else {
        log().error(String.format("Mod %s sent an unregistered message. Report this to the mod author.", msg.getSender()));
    }
}