2013-12-27 23:59:59 +01:00
|
|
|
package appeng.me.storage;
|
|
|
|
|
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraftforge.common.ForgeDirection;
|
2014-01-23 20:02:48 +01:00
|
|
|
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
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
|
|
|
|
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel)
|
|
|
|
{
|
2014-01-03 19:28:52 +01:00
|
|
|
if ( channel == StorageChannel.ITEMS && te instanceof ITileStorageMonitorable )
|
2013-12-27 23:59:59 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
if ( channel == StorageChannel.ITEMS && te instanceof IInventory )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return te instanceof TileCondenser;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
IStorageMonitorable sm = iface.getMonitorable( d );
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( channel == StorageChannel.ITEMS && te instanceof IInventory )
|
|
|
|
{
|
|
|
|
return new MEMonitorIInventory( (IInventory) te, d );
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|