Applied-Energistics-2-tiler.../me/storage/AEExternalHandler.java

61 lines
1.8 KiB
Java
Raw Normal View History

package appeng.me.storage;
import net.minecraft.tileentity.TileEntity;
2014-02-09 02:34:52 +01:00
import net.minecraftforge.common.util.ForgeDirection;
2014-01-23 20:02:48 +01:00
import appeng.api.implementations.tiles.ITileStorageMonitorable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
2014-01-03 19:28:52 +01:00
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.tile.misc.TileCondenser;
public class AEExternalHandler implements IExternalStorageHandler
{
@Override
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel)
{
2014-01-03 19:28:52 +01:00
if ( channel == StorageChannel.ITEMS && te instanceof ITileStorageMonitorable )
return true;
return te instanceof TileCondenser;
}
@Override
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src)
{
if ( te instanceof TileCondenser )
{
if ( channel == StorageChannel.ITEMS )
return new VoidItemInventory( (TileCondenser) te );
else
return new VoidFluidInventory( (TileCondenser) te );
}
2014-01-03 19:28:52 +01:00
if ( te instanceof ITileStorageMonitorable )
{
2014-01-03 19:28:52 +01:00
ITileStorageMonitorable iface = (ITileStorageMonitorable) te;
IStorageMonitorable sm = iface.getMonitorable( d, src );
2014-01-03 19:28:52 +01:00
if ( channel == StorageChannel.ITEMS && sm != null )
{
2014-01-03 19:28:52 +01:00
IMEInventory<IAEItemStack> ii = sm.getItemInventory();
if ( ii != null )
return ii;
}
2014-01-03 19:28:52 +01:00
if ( channel == StorageChannel.FLUIDS && sm != null )
{
2014-01-03 19:28:52 +01:00
IMEInventory<IAEFluidStack> fi = sm.getFluidInventory();
if ( fi != null )
return fi;
}
}
return null;
}
}