Added IMC Support for P2P / Grinder / Spatial / MatterCannon

This commit is contained in:
AlgorithmX2
2014-04-17 21:52:39 -05:00
parent 572352c18e
commit cb81f34db3
6 changed files with 242 additions and 2 deletions
+10
View File
@@ -0,0 +1,10 @@
package appeng.core.api;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
public interface IIMCHandler
{
void post(IMCMessage m);
}
+79
View File
@@ -0,0 +1,79 @@
/* Example:
NBTTagCompound msg = new NBTTagCompound();
NBTTagCompound in = new NBTTagCompound();
NBTTagCompound out = new NBTTagCompound();
new ItemStack( Blocks.iron_ore ).writeToNBT( in );
new ItemStack( Items.iron_ingot ).writeToNBT( out );
msg.setTag( "in", in );
msg.setTag( "out", out );
msg.setInteger( "turns", 8 );
FMLInterModComms.sendMessage( "appliedenergistics2", "add-grindable", msg );
-- or --
NBTTagCompound msg = new NBTTagCompound();
NBTTagCompound in = new NBTTagCompound();
NBTTagCompound out = new NBTTagCompound();
NBTTagCompound optional = new NBTTagCompound();
new ItemStack( Blocks.iron_ore ).writeToNBT( in );
new ItemStack( Items.iron_ingot ).writeToNBT( out );
new ItemStack( Blocks.gravel ).writeToNBT( optional );
msg.setTag( "in", in );
msg.setTag( "out", out );
msg.setTag( "optional", optional );
msg.setFloat( "chance", 0.5 );
msg.setInteger( "turns", 8 );
FMLInterModComms.sendMessage( "appliedenergistics2", "add-grindable", msg );
*/
package appeng.core.api.imc;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.AEApi;
import appeng.core.api.IIMCHandler;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
public class IMCGrinder implements IIMCHandler
{
@Override
public void post(IMCMessage m)
{
NBTTagCompound msg = m.getNBTValue();
NBTTagCompound inTag = (NBTTagCompound) msg.getTag( "in" );
NBTTagCompound outTag = (NBTTagCompound) msg.getTag( "out" );
ItemStack in = ItemStack.loadItemStackFromNBT( inTag );
ItemStack out = ItemStack.loadItemStackFromNBT( outTag );
int turns = msg.getInteger( "turns" );
if ( in == null )
throw new RuntimeException( "invalid input" );
if ( out == null )
throw new RuntimeException( "invalid output" );
if ( msg.hasKey( "optional" ) )
{
NBTTagCompound optionalTag = (NBTTagCompound) msg.getTag( "optional" );
ItemStack optional = ItemStack.loadItemStackFromNBT( optionalTag );
if ( optional == null )
throw new RuntimeException( "invalid optional" );
float chance = msg.getFloat( "chance" );
AEApi.instance().registries().grinder().addRecipe( in, out, optional, chance, turns );
}
else
AEApi.instance().registries().grinder().addRecipe( in, out, turns );
}
}
+38
View File
@@ -0,0 +1,38 @@
/* Example:
NBTTagCompound msg = new NBTTagCompound();
NBTTagCompound item = new NBTTagCompound();
new ItemStack( Blocks.anvil ).writeToNBT( item );
msg.setTag( "item", item );
msg.setDouble( "weight", 32.0 );
FMLInterModComms.sendMessage( "appliedenergistics2", "add-mattercannon-ammo", msg );
*/
package appeng.core.api.imc;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.AEApi;
import appeng.core.api.IIMCHandler;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
public class IMCMatterCannon implements IIMCHandler
{
@Override
public void post(IMCMessage m)
{
NBTTagCompound msg = m.getNBTValue();
NBTTagCompound item = (NBTTagCompound) msg.getTag( "item" );
ItemStack ammo = ItemStack.loadItemStackFromNBT( item );
double weight = msg.getDouble( "weight" );
if ( ammo == null )
throw new RuntimeException( "invalid item" );
AEApi.instance().registries().matterCannon().registerAmmo( ammo, weight );
}
}
+41
View File
@@ -0,0 +1,41 @@
/* Example:
FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-me", new ItemStack( myBlockOrItem ) );
FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-bc-power", new ItemStack( myBlockOrItem ) );
FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-ic2-power", new ItemStack( myBlockOrItem ) );
FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-redstone", new ItemStack( myBlockOrItem ) );
FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-fluid", new ItemStack( myBlockOrItem ) );
FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-item", new ItemStack( myBlockOrItem ) );
*/
package appeng.core.api.imc;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.TunnelType;
import appeng.core.api.IIMCHandler;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
public class IMCP2PAttunement implements IIMCHandler
{
@Override
public void post(IMCMessage m)
{
String key = m.key.substring( "add-p2p-attunement-".length() ).replace( '-', '_' ).toUpperCase();
TunnelType type = TunnelType.valueOf( key );
if ( type != null )
{
ItemStack is = m.getItemStackValue();
if ( is != null )
AEApi.instance().registries().p2pTunnel().addNewAttunement( is, type );
else
throw new RuntimeException( "invalid item" );
}
else
throw new RuntimeException( "invalid type" );
}
}
+32
View File
@@ -0,0 +1,32 @@
/* Example:
FMLInterModComms.sendMessage( "appliedenergistics2", "whitelist-spatial", "mymod.tileentities.MyTileEntity" );
*/
package appeng.core.api.imc;
import appeng.api.AEApi;
import appeng.core.AELog;
import appeng.core.api.IIMCHandler;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
public class IMCSpatial implements IIMCHandler
{
@Override
public void post(IMCMessage m)
{
try
{
Class classInstance = Class.forName( m.getStringValue() );
AEApi.instance().registries().moveable().whiteListTileEntity( classInstance );
}
catch (ClassNotFoundException e)
{
AELog.info( "Bad Class Registered: " + m.getStringValue() + " by " + m.getSender() );
}
}
}