cpw.mods.fml.common.event.FMLInterModComms.IMCMessage Java Examples
The following examples show how to use
cpw.mods.fml.common.event.FMLInterModComms.IMCMessage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdvancedMod.java From AdvancedMod with GNU General Public License v3.0 | 6 votes |
@Mod.EventHandler public void onIMCMessages(IMCEvent event){ Log.info("Receiving IMC"); for(IMCMessage message : event.getMessages()) { if(message.key.equalsIgnoreCase("camoMineBlacklist")) { if(message.isItemStackMessage()) { ItemStack blacklistedStack = message.getItemStackValue(); if(blacklistedStack.getItem() != null) { TileEntityCamoMine.camouflageBlacklist.add(blacklistedStack); Log.info(String.format("Mod %s added %s to be blacklisted as camouflage for the Camo Mine", message.getSender(), blacklistedStack.toString())); } else { throw new IllegalStateException(String.format("ItemStack tried to be used in registry by the mod %s has a null item.", message.getSender())); } } else { Log.warn(String.format("Mod %s sent a non-ItemStack message, where an ItemStack message was expected.", message.getSender())); } } else { Log.warn(String.format("Mod %s used an invalid IMC key: %s", message.getSender(), message.key)); } } }
Example #2
Source File: FactoryRegistry.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public static void sendMessage(String message, Object value) { if (!Loader.isModLoaded("MineFactoryReloaded") || Loader.instance().activeModContainer() == null) return; try { Method m = FMLInterModComms.class.getDeclaredMethod("enqueueMessage", Object.class, String.class, IMCMessage.class); m.setAccessible(true); Constructor<IMCMessage> c = IMCMessage.class.getDeclaredConstructor(String.class, Object.class); c.setAccessible(true); m.invoke(null, Loader.instance().activeModContainer(), "MineFactoryReloaded", c.newInstance(message, value)); } catch(Exception e) { e.printStackTrace(); } }
Example #3
Source File: FactoryRegistry.java From BigReactors with MIT License | 6 votes |
public static void sendMessage(String message, Object value) { if (!Loader.isModLoaded("MineFactoryReloaded") || Loader.instance().activeModContainer() == null) return; try { Method m = FMLInterModComms.class.getDeclaredMethod("enqueueMessage", Object.class, String.class, IMCMessage.class); m.setAccessible(true); Constructor<IMCMessage> c = IMCMessage.class.getDeclaredConstructor(String.class, Object.class); c.setAccessible(true); m.invoke(null, Loader.instance().activeModContainer(), "MineFactoryReloaded", c.newInstance(message, value)); } catch(Exception e) { e.printStackTrace(); } }
Example #4
Source File: EtFuturum.java From Et-Futurum with The Unlicense | 5 votes |
@EventHandler public void processIMCRequests(IMCEvent event) { for (IMCMessage message : event.getMessages()) if (message.key.equals("register-brewing-fuel")) { NBTTagCompound nbt = message.getNBTValue(); ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("Fuel")); int brews = nbt.getInteger("Brews"); BrewingFuelRegistry.registerFuel(stack, brews); } }
Example #5
Source File: IMCHandler.java From Chisel-2 with GNU General Public License v2.0 | 5 votes |
public void handleMessage(IMCMessage message) { for (IMC imc : IMC.values()) { if (imc.key.equals(message.key)) { handle(message, imc, message.getStringValue()); } } }
Example #6
Source File: IMCHandler.java From Chisel-2 with GNU General Public License v2.0 | 5 votes |
private void handle(IMCMessage message, IMC type, String value) { ICarvingRegistry reg = Carving.chisel; String[] data = value.split("\\|"); try { switch (type) { case ADD_VARIATION: case REMOVE_VARIATION: Block block = (Block) Block.blockRegistry.getObject(data[1]); int meta = Short.parseShort(data[2]); if (type == IMC.ADD_VARIATION) { reg.addVariation(data[0], block, meta, order++); } else { reg.removeVariation(block, meta, data[0]); } break; case REGISTER_GROUP_ORE: reg.registerOre(data[0], data[1]); break; default: throw new IllegalArgumentException("Invalid IMC constant! How...what...?"); } } catch (Exception e) { Chisel.logger.error("Could not handle data {} for IMC type {}. This was sent from mod {}.\n" + "!! This is a bug in that mod !!\nSwallowing error and continuing...", value, type.name(), message.getSender()); e.printStackTrace(); } }
Example #7
Source File: LookingGlass.java From LookingGlass with GNU General Public License v3.0 | 4 votes |
@EventHandler public void handleIMC(IMCEvent event) { // Catch IMC messages and send them off to our IMC handler ImmutableList<IMCMessage> messages = event.getMessages(); IMCHandler.process(messages); }
Example #8
Source File: IMCAPIRegister.java From LookingGlass with GNU General Public License v3.0 | 4 votes |
@Override public void process(IMCMessage message) { if (!message.isStringMessage()) return; LoggerUtils.info(String.format("Receiving API registration request from [%s] for method %s", message.getSender(), message.getStringValue())); callbackRegistration(message.getStringValue(), message.getSender()); }
Example #9
Source File: Chisel.java From Chisel-2 with GNU General Public License v2.0 | 4 votes |
@EventHandler public void onIMC(IMCEvent event) { for (IMCMessage msg : event.getMessages()) { IMCHandler.INSTANCE.handleMessage(msg); } }
Example #10
Source File: IMCHandler.java From LookingGlass with GNU General Public License v3.0 | votes |
public void process(IMCMessage message);