本文整理匯總了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");
}
}
}
}
示例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();
}
}
}
}
}
示例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();
}
}
示例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!");
}
}
}
}
示例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);
}
示例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();
}
}
}
示例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());
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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());
}
}
示例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");
}
}
}
}
示例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());
}
}
}
示例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());
}
}
}
}
示例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());
}
}
}