當前位置: 首頁>>代碼示例>>Java>>正文


Java FMLInterModComms.IMCMessage方法代碼示例

本文整理匯總了Java中net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java FMLInterModComms.IMCMessage方法的具體用法?Java FMLInterModComms.IMCMessage怎麽用?Java FMLInterModComms.IMCMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.fml.common.event.FMLInterModComms的用法示例。


在下文中一共展示了FMLInterModComms.IMCMessage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onIMCMessage

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
@EventHandler
public void onIMCMessage(FMLInterModComms.IMCEvent event)
{
    for(FMLInterModComms.IMCMessage message : event.getMessages())
    {
        if(message.key.equalsIgnoreCase("blacklist") && message.isItemStackMessage())
        {
            if(!blacklist.contains(message.getItemStackValue().getItem()))
            {
                blacklist.add(message.getItemStackValue().getItem());
                logger.info("Registered " + message.getItemStackValue().getItem().toString() + " to Item blacklist");
            }
        }
        else if(message.key.equalsIgnoreCase("backtool") && message.isItemStackMessage())
        {
            if(!orientationMap.containsKey(message.getItemStackValue().getItem().getClass()))
            {
                orientationMap.put(message.getItemStackValue().getItem().getClass(), message.getItemStackValue().getCount());
                logger.warn("Registered " + message.getItemStackValue().getItem().getClass().getName() + " to backtools");
            }
        }
    }
}
 
開發者ID:iChun,項目名稱:BackTools,代碼行數:24,代碼來源:BackTools.java

示例2: onReceiveIMC

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
@Mod.EventHandler
public void onReceiveIMC(FMLInterModComms.IMCEvent event) {
    for (FMLInterModComms.IMCMessage message : event.getMessages()) {
        if (message.key.equalsIgnoreCase("possess_handler")) {
            if (message.isStringMessage()) {
                try {
                    Class<? extends EntityPossessHandler> clazz = (Class<? extends EntityPossessHandler>) Class.forName(message.getStringValue());
                    EntityPossessHandler handler = clazz.getDeclaredConstructor().newInstance();
                    PossessHandler.registerHandler(handler);
                } catch (Exception e) {
                    System.err.println("Received invalid IMC EntityPossessHandler class from mod " + message.getSender() + " (" + message.getStringValue() + ")");
                    e.printStackTrace();
                }
            }
        }
    }
}
 
開發者ID:Fararise,項目名稱:Possessed,代碼行數:18,代碼來源:Possessed.java

示例3: onIMCMessage

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
public void onIMCMessage(FMLInterModComms.IMCMessage message, boolean server, boolean runtime)
{
    try
    {
        boolean didHandle = handleMessage(message, server, runtime);

        if (!didHandle)
        {
            logger.warn("Could not handle message with key '" + message.key + "' of type '" + message.getMessageType().getName() + "'");
        }
    }
    catch (Exception ex)
    {
        logger.error("Exception on message with key '" + message.key + "' of type '" + message.getMessageType().getName() + "'");
        ex.printStackTrace();
    }
}
 
開發者ID:Ivorforce,項目名稱:IvToolkit,代碼行數:18,代碼來源:IvFMLIntercommHandler.java

示例4: imcCallback

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
@Mod.EventHandler
public void imcCallback(FMLInterModComms.IMCEvent event) {
    for (FMLInterModComms.IMCMessage message : event.getMessages()) {
        if (message.key.equalsIgnoreCase("getTheWheel")) {
            Optional<Function<IInteractionWheel, Void>> value = message.getFunctionValue(IInteractionWheel.class, Void.class);
            if (value.isPresent()) {
                value.get().apply(interactionWheelImp);
            } else {
                logger.warn("Some mod didn't return a valid result with getTheWheel!");
            }
        }
    }
}
 
開發者ID:McJty,項目名稱:interactionwheel,代碼行數:14,代碼來源:InteractionWheel.java

示例5: fromIMC

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
public static void fromIMC(FMLInterModComms.IMCMessage message) {
    if (!message.isNBTMessage()) {
    	ExampleMod.logger.warn("Invalid IMC sent by {} - biomeModule expects NBT", message.getSender());
        return;
    }

    NBTTagCompound tag = message.getNBTValue();

    if (!tag.hasKey("name") || tag.getString("name").isEmpty()) {
    	ExampleMod.logger.warn("Invalid IMC sent by {} - biomeModule requires a name in the 'name' tag", message.getSender());
        return;
    }
    if (!tag.hasKey("json") || tag.getString("json").isEmpty()) {
    	ExampleMod.logger.warn("Invalid IMC sent by {} - biomeModule requires biome settings data in the 'json' tag", message.getSender());
        return;
    }

    BiomeSettings settings = new BiomeSettings();

    try {
        settings.readFromJson(tag.getString("json"));
    } catch (Exception e) {
    	ExampleMod.logger.warn("Invalid IMC sent by {} - biomeModule received invalid biome json data", message.getSender());
        return;
    }

    BiomeModule module = new BiomeModule(tag.getString("name"), message.getSender(), settings, tag.getBoolean("enabled"));

    ExampleMod.globalRegistry.biomeModules.add(module);
}
 
開發者ID:stuebz88,項目名稱:modName,代碼行數:31,代碼來源:BiomeModule.java

示例6: handleImc

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
@Mod.EventHandler
public void handleImc(FMLInterModComms.IMCEvent event) {
    for (FMLInterModComms.IMCMessage message : event.getMessages()) {
        try {
            RecipeViewer.handleImc(message);
            handleImc(message);
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:12,代碼來源:DocumentationModule.java

示例7: onIMC

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
public static void onIMC(FMLInterModComms.IMCEvent event) {
    for (final FMLInterModComms.IMCMessage imcMessage : event.getMessages()) {
        if (imcMessage.key.toLowerCase().equals("lootblacklist") && imcMessage.isItemStackMessage()) {
            lootBlacklist.add(imcMessage.getItemStackValue());
        }
    }
}
 
開發者ID:AdlyTempleton,項目名稱:Aura-Cascade,代碼行數:8,代碼來源:IMCManager.java

示例8: handleMessages

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
public void handleMessages(boolean server, boolean runtime)
{
    for (FMLInterModComms.IMCMessage message : FMLInterModComms.fetchRuntimeMessages(modInstance))
    {
        onIMCMessage(message, server, true);
    }
}
 
開發者ID:Ivorforce,項目名稱:IvToolkit,代碼行數:8,代碼來源:IvFMLIntercommHandler.java

示例9: isMessage

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
protected boolean isMessage(String key, FMLInterModComms.IMCMessage message, Class expectedType)
{
    if (key.equals(message.key))
    {
        if (message.getMessageType().isAssignableFrom(expectedType))
        {
            return true;
        }

        faultyMessage(message, expectedType);
    }

    return false;
}
 
開發者ID:Ivorforce,項目名稱:IvToolkit,代碼行數:15,代碼來源:IvFMLIntercommHandler.java

示例10: sendReply

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
protected boolean sendReply(FMLInterModComms.IMCMessage message, String value)
{
    if (message.getSender() == null)
    {
        return false;
    }

    NBTTagCompound cmp = message.getNBTValue();
    FMLInterModComms.sendRuntimeMessage(modOwnerID, message.getSender(), cmp.getString("replyKey"), value);
    return true;
}
 
開發者ID:Ivorforce,項目名稱:IvToolkit,代碼行數:12,代碼來源:IvFMLIntercommHandler.java

示例11: processMessage

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
/**
 * If the message key is either {@link #IMC_SWORD_KEY} or {@link #IMC_WEAPON_KEY}
 * and the message contains an ItemStack, the stack will be registered appropriately.
 */
public void processMessage(FMLInterModComms.IMCMessage msg) {
	if (!msg.isItemStackMessage()) {
		return;
	} else if (msg.key.equalsIgnoreCase(IMC_SWORD_KEY)) {
		registerSword("IMC", msg.getSender(), msg.getItemStackValue().getItem());
	} else if (msg.key.equalsIgnoreCase(IMC_WEAPON_KEY)) {
		registerWeapon("IMC", msg.getSender(), msg.getItemStackValue().getItem());
	}
}
 
開發者ID:coolAlias,項目名稱:ZeldaSwordSkills,代碼行數:14,代碼來源:WeaponRegistry.java

示例12: onIMCMessage

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
@Mod.EventHandler
public void onIMCMessage(FMLInterModComms.IMCEvent event)
{
    for(FMLInterModComms.IMCMessage message : event.getMessages())
    {
        if(message.key.equalsIgnoreCase("blacklist"))
        {
            try
            {
                Class clz = Class.forName(message.getStringValue());
                if(ModelBase.class.isAssignableFrom(clz))
                {
                    if(ModelList.modelBlacklist.contains(clz))
                    {
                        Tabula.LOGGER.warn(message.getStringValue() + " is already blacklisted");
                    }
                    else
                    {
                        ModelList.modelBlacklist.add(clz);
                        Tabula.LOGGER.warn(message.getStringValue() + " blacklisted from Tabula's import list");
                    }
                }
                else
                {
                    Tabula.LOGGER.warn(message.getStringValue() + " is not a model class!");
                }
            }
            catch(Exception e)
            {
                Tabula.LOGGER.warn("Could not find class " + message.getStringValue() + " for blacklist");
            }
        }
    }
}
 
開發者ID:iChun,項目名稱:Tabula,代碼行數:35,代碼來源:Tabula.java

示例13: processIMC

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
public void processIMC(final FMLInterModComms.IMCEvent event) {
    for (final FMLInterModComms.IMCMessage message : event.getMessages()) {
        if ("checkUpdate".equals(message.key) && message.isStringMessage()) {
            processMessage(message.getSender(), message.getStringValue());
        }
    }
}
 
開發者ID:Lunatrius,項目名稱:LunatriusCore,代碼行數:8,代碼來源:CommonProxy.java

示例14: processMessages

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
public static void processMessages(List<FMLInterModComms.IMCMessage> messageList)
{
    for (FMLInterModComms.IMCMessage message : messageList)
    {
        if (message.key.equalsIgnoreCase(IMCOperations.ADD_UPDATE))
        {
            LogHandler.info("Received update from mod " + message.getSender());
            if (message.isNBTMessage())
            {
                processAddUpdateMessage(message.getNBTValue(), message.getSender());
            }
            else if (message.isStringMessage())
            {
                processAddUpdateMessage(message.getStringValue(), message.getSender());
            }
        }
        else if (message.key.equalsIgnoreCase(IMCOperations.ADD_VERSION_CHECK))
        {
            LogHandler.info("Received version check from mod " + message.getSender());
            if (message.isStringMessage())
            {
                processVersionCheckMessage(message.getSender(), message.getStringValue());
            }
        }
        else if (message.key.equalsIgnoreCase(IMCOperations.ADD_CURSE_CHECK))
        {
            LogHandler.info("Received curse check from mod " + message.getSender());
            if (message.isNBTMessage())
            {
                processCurseCheckMessage(message.getSender(), message.getNBTValue());
            }
        }
    }
}
 
開發者ID:Dynious,項目名稱:VersionChecker,代碼行數:35,代碼來源:IMCHandler.java

示例15: processMessage

import net.minecraftforge.fml.common.event.FMLInterModComms; //導入方法依賴的package包/類
@EventHandler
public void processMessage(FMLInterModComms.IMCEvent event) {
	for (FMLInterModComms.IMCMessage m : event.getMessages()) {
		if (m.isStringMessage() && "donateUrl".equalsIgnoreCase(m.key)) {
			DonationUrlManager.instance().addUrl(m.getSender(), m.getStringValue());
		}

		if (m.isItemStackMessage() && "bucket".equalsIgnoreCase(m.key)) {
			filledBuckets.add(m.getItemStackValue());
		}
	}
}
 
開發者ID:OpenMods,項目名稱:OpenBlocks,代碼行數:13,代碼來源:OpenBlocks.java


注:本文中的net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。