2013-12-27 23:59:59 +01:00
|
|
|
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;
|
2014-04-18 05:33:48 +02:00
|
|
|
import appeng.api.networking.security.BaseActionSource;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.storage.IExternalStorageHandler;
|
|
|
|
import appeng.api.storage.IMEInventory;
|
2014-01-03 19:28:52 +01:00
|
|
|
import appeng.api.storage.IStorageMonitorable;
|
2013-12-27 23:59:59 +01:00
|
|
|
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
|
2014-05-25 01:23:23 +02:00
|
|
|
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-03 19:28:52 +01:00
|
|
|
if ( channel == StorageChannel.ITEMS && te instanceof ITileStorageMonitorable )
|
2014-05-25 01:23:23 +02:00
|
|
|
return ((ITileStorageMonitorable) te).getMonitorable( d, mySrc ) != null;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
return te instanceof TileCondenser;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-04-18 05:33:48 +02:00
|
|
|
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
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 )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-03 19:28:52 +01:00
|
|
|
ITileStorageMonitorable iface = (ITileStorageMonitorable) te;
|
2014-04-18 05:33:48 +02:00
|
|
|
IStorageMonitorable sm = iface.getMonitorable( d, src );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-01-03 19:28:52 +01:00
|
|
|
if ( channel == StorageChannel.ITEMS && sm != null )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-03 19:28:52 +01:00
|
|
|
IMEInventory<IAEItemStack> ii = sm.getItemInventory();
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( ii != null )
|
|
|
|
return ii;
|
|
|
|
}
|
|
|
|
|
2014-01-03 19:28:52 +01:00
|
|
|
if ( channel == StorageChannel.FLUIDS && sm != null )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-03 19:28:52 +01:00
|
|
|
IMEInventory<IAEFluidStack> fi = sm.getFluidInventory();
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( fi != null )
|
|
|
|
return fi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|