Relocate Source to proper directory.
This commit is contained in:
@@ -0,0 +1,356 @@
|
||||
package appeng.core.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
import org.objectweb.asm.commons.RemappingClassAdapter;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import appeng.api.parts.CableRenderMode;
|
||||
import appeng.api.parts.IPartHelper;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.LayerBase;
|
||||
import appeng.client.render.BusRenderer;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.abstraction.IFMP;
|
||||
import appeng.parts.PartPlacement;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
public class ApiPart implements IPartHelper
|
||||
{
|
||||
|
||||
int classNum = 1;
|
||||
|
||||
HashMap<String, Class> TileImplementations = new HashMap();
|
||||
HashMap<String, ClassNode> readerCache = new HashMap();
|
||||
HashMap<Class, String> interfaces2Layer = new HashMap();
|
||||
HashMap<String, Class> roots = new HashMap();
|
||||
|
||||
List<String> desc = new LinkedList();
|
||||
|
||||
public void initFMPSupport()
|
||||
{
|
||||
for (Class layerInterface : interfaces2Layer.keySet())
|
||||
{
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
||||
((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).registerPassThrough( layerInterface );
|
||||
}
|
||||
}
|
||||
|
||||
private Class loadClass(String Name, byte[] b)
|
||||
{
|
||||
// override classDefine (as it is protected) and define the class.
|
||||
Class clazz = null;
|
||||
try
|
||||
{
|
||||
ClassLoader loader = getClass().getClassLoader();// ClassLoader.getSystemClassLoader();
|
||||
Class root = ClassLoader.class;
|
||||
Class cls = loader.getClass();
|
||||
java.lang.reflect.Method defineClassMethod = root.getDeclaredMethod( "defineClass",
|
||||
new Class[] { String.class, byte[].class, int.class, int.class } );
|
||||
java.lang.reflect.Method runTransformersMethod = cls
|
||||
.getDeclaredMethod( "runTransformers", new Class[] { String.class, String.class, byte[].class } );
|
||||
|
||||
runTransformersMethod.setAccessible( true );
|
||||
defineClassMethod.setAccessible( true );
|
||||
try
|
||||
{
|
||||
Object[] argsA = new Object[] { Name, Name, b };
|
||||
b = (byte[]) runTransformersMethod.invoke( loader, argsA );
|
||||
|
||||
Object[] args = new Object[] { Name, b, new Integer( 0 ), new Integer( b.length ) };
|
||||
clazz = (Class) defineClassMethod.invoke( loader, args );
|
||||
}
|
||||
finally
|
||||
{
|
||||
runTransformersMethod.setAccessible( false );
|
||||
defineClassMethod.setAccessible( false );
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AELog.error( e );
|
||||
throw new RuntimeException( "Unable to manage part API.", e );
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public ClassNode getReader(String name) throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
ClassReader cr;
|
||||
String path = "/" + name.replace( ".", "/" ) + ".class";
|
||||
InputStream is = getClass().getResourceAsStream( path );
|
||||
cr = new ClassReader( is );
|
||||
ClassNode cn = new ClassNode();
|
||||
cr.accept( cn, ClassReader.EXPAND_FRAMES );
|
||||
return cn;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( "Error loading " + name, t );
|
||||
}
|
||||
}
|
||||
|
||||
public Class getCombinedInstance(String base)
|
||||
{
|
||||
if ( desc.size() == 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Class.forName( base );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
String description = base + ":" + Joiner.on( ";" ).skipNulls().join( desc.iterator() );
|
||||
|
||||
if ( TileImplementations.get( description ) != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
return TileImplementations.get( description );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
String f = base;// TileCableBus.class.getName();
|
||||
String Addendum = "";
|
||||
try
|
||||
{
|
||||
Addendum = Class.forName( base ).getSimpleName();
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
Class myCLass;
|
||||
|
||||
try
|
||||
{
|
||||
myCLass = Class.forName( f );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
|
||||
String path = f;
|
||||
|
||||
for (String name : desc)
|
||||
{
|
||||
try
|
||||
{
|
||||
String newPath = path + ";" + name;
|
||||
myCLass = getClassByDesc( Addendum, newPath, f, interfaces2Layer.get( Class.forName( name ) ) );
|
||||
path = newPath;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.warning( "Error loading " + name );
|
||||
AELog.error( t );
|
||||
// throw new RuntimeException( t );
|
||||
}
|
||||
f = myCLass.getName();
|
||||
}
|
||||
|
||||
TileImplementations.put( description, myCLass );
|
||||
|
||||
try
|
||||
{
|
||||
return myCLass;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
class DefaultPackageClassNameRemapper extends Remapper
|
||||
{
|
||||
|
||||
public HashMap<String, String> inputOutput = new HashMap<String, String>();
|
||||
|
||||
@Override
|
||||
public String map(String typeName)
|
||||
{
|
||||
String o = inputOutput.get( typeName );
|
||||
if ( o == null )
|
||||
return typeName;
|
||||
return o;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Class getClassByDesc(String Addendum, String fullPath, String root, String next) throws IOException
|
||||
{
|
||||
if ( roots.get( fullPath ) != null )
|
||||
return roots.get( fullPath );
|
||||
|
||||
ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS );
|
||||
ClassNode n = getReader( next );
|
||||
String originalName = n.name;
|
||||
|
||||
try
|
||||
{
|
||||
n.name = n.name + "_" + Addendum;
|
||||
n.superName = Class.forName( root ).getName().replace( ".", "/" );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
|
||||
for (MethodNode mn : n.methods)
|
||||
{
|
||||
Iterator<AbstractInsnNode> i = mn.instructions.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
processNode( i.next(), n.superName );
|
||||
}
|
||||
}
|
||||
|
||||
DefaultPackageClassNameRemapper remapper = new DefaultPackageClassNameRemapper();
|
||||
remapper.inputOutput.put( "appeng/api/parts/LayerBase", n.superName );
|
||||
remapper.inputOutput.put( originalName, n.name );
|
||||
n.accept( new RemappingClassAdapter( cw, remapper ) );
|
||||
// n.accept( cw );
|
||||
|
||||
// n.accept( new TraceClassVisitor( new PrintWriter( System.out ) ) );
|
||||
byte[] barray = cw.toByteArray();
|
||||
int size = barray.length;
|
||||
Class nclass = loadClass( n.name.replace( "/", "." ), barray );
|
||||
|
||||
try
|
||||
{
|
||||
Object fish = nclass.newInstance();
|
||||
Class rootC = Class.forName( root );
|
||||
|
||||
boolean bads = false;
|
||||
|
||||
if ( !rootC.isInstance( fish ) )
|
||||
{
|
||||
bads = true;
|
||||
AELog.severe( "Error, Expected layer to implement " + root + " did not." );
|
||||
}
|
||||
|
||||
if ( fish instanceof LayerBase )
|
||||
{
|
||||
bads = true;
|
||||
AELog.severe( "Error, Expected layer to NOT implement LayerBase but it DID." );
|
||||
}
|
||||
|
||||
if ( !fullPath.contains( ".fmp." ) )
|
||||
{
|
||||
if ( !(fish instanceof TileCableBus) )
|
||||
{
|
||||
bads = true;
|
||||
AELog.severe( "Error, Expected layer to implement TileCableBus did not." );
|
||||
}
|
||||
|
||||
if ( !(fish instanceof TileEntity) )
|
||||
{
|
||||
bads = true;
|
||||
AELog.severe( "Error, Expected layer to implement TileEntity did not." );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !bads )
|
||||
{
|
||||
AELog.info( "Layer: " + n.name + " loaded successfully - " + size + " bytes" );
|
||||
}
|
||||
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.severe( "Layer: " + n.name + " Failed." );
|
||||
AELog.error( t );
|
||||
}
|
||||
|
||||
roots.put( fullPath, nclass );
|
||||
return nclass;
|
||||
}
|
||||
|
||||
private void processNode(AbstractInsnNode next, String nePar)
|
||||
{
|
||||
if ( next instanceof MethodInsnNode )
|
||||
{
|
||||
MethodInsnNode min = (MethodInsnNode) next;
|
||||
if ( min.owner.equals( "appeng/api/parts/LayerBase" ) )
|
||||
{
|
||||
min.owner = nePar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemBusRenderer(IPartItem i)
|
||||
{
|
||||
if ( Platform.isClient() && i instanceof Item )
|
||||
MinecraftForgeClient.registerItemRenderer( (Item) i, BusRenderer.instance );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBus(ItemStack is, int x, int y, int z, int side, EntityPlayer player, World w)
|
||||
{
|
||||
return PartPlacement.place( is, x, y, z, side, player, w, PartPlacement.PlaceType.PLACE_ITEM, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerNewLayer(String layer, String layerInterface)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( interfaces2Layer.get( layerInterface ) == null )
|
||||
{
|
||||
interfaces2Layer.put( Class.forName( layerInterface ), layer );
|
||||
desc.add( layerInterface );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
AELog.info( "Layer " + layer + " not registered, " + layerInterface + " already has a layer." );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableRenderMode getCableRenderMode()
|
||||
{
|
||||
return CommonHelper.proxy.getRenderMode();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package appeng.core.api;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
import appeng.api.networking.crafting.ICraftingRequester;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IStorageHelper;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.crafting.CraftingLink;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.item.ItemList;
|
||||
|
||||
public class ApiStorage implements IStorageHelper
|
||||
{
|
||||
|
||||
@Override
|
||||
public IAEItemStack createItemStack(ItemStack is)
|
||||
{
|
||||
return AEItemStack.create( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack createFluidStack(FluidStack is)
|
||||
{
|
||||
return AEFluidStack.create( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> createItemList()
|
||||
{
|
||||
return new ItemList( IAEItemStack.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEFluidStack> createFluidList()
|
||||
{
|
||||
return new ItemList( IAEFluidStack.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack poweredExtraction(IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack request, BaseActionSource src)
|
||||
{
|
||||
return Platform.poweredExtraction( energy, cell, request, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack poweredInsert(IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack input, BaseActionSource src)
|
||||
{
|
||||
return Platform.poweredInsert( energy, cell, input, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack readItemFromPacket(ByteBuf input) throws IOException
|
||||
{
|
||||
return AEItemStack.loadItemStackFromPacket( input );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack readFluidFromPacket(ByteBuf input) throws IOException
|
||||
{
|
||||
return AEFluidStack.loadFluidStackFromPacket( input );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingLink loadCraftingLink(NBTTagCompound data, ICraftingRequester req)
|
||||
{
|
||||
return new CraftingLink( data, req );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package appeng.core.api;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
public interface IIMCHandler
|
||||
{
|
||||
|
||||
void post(IMCMessage m);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package appeng.core.api.imc;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.api.IIMCHandler;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
public class IMCBlackListSpatial implements IIMCHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void post(IMCMessage m)
|
||||
{
|
||||
|
||||
ItemStack is = m.getItemStackValue();
|
||||
if ( is != null )
|
||||
{
|
||||
Block blk = Block.getBlockFromItem( is.getItem() );
|
||||
if ( blk != null )
|
||||
{
|
||||
AEApi.instance().registries().movable().blacklistBlock( blk );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AELog.info( "Bad Block blacklisted by " + m.getSender() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
@@ -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" );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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().movable().whiteListTileEntity( classInstance );
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
AELog.info( "Bad Class Registered: " + m.getStringValue() + " by " + m.getSender() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user