2013-12-27 23:59:59 +01:00
|
|
|
package appeng.core.features.registries;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-05-25 01:23:23 +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.IExternalStorageRegistry;
|
|
|
|
import appeng.api.storage.StorageChannel;
|
2014-02-16 19:41:45 +01:00
|
|
|
import appeng.core.features.registries.entries.ExternalIInv;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public class ExternalStorageRegistry implements IExternalStorageRegistry
|
|
|
|
{
|
|
|
|
|
|
|
|
List<IExternalStorageHandler> Handlers;
|
2014-02-16 19:41:45 +01:00
|
|
|
final ExternalIInv lastHandler = new ExternalIInv();
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public ExternalStorageRegistry() {
|
|
|
|
Handlers = new ArrayList();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-05-25 01:23:23 +02:00
|
|
|
public IExternalStorageHandler getHandler(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
for (IExternalStorageHandler x : Handlers)
|
|
|
|
{
|
2014-05-25 01:23:23 +02:00
|
|
|
if ( x.canHandle( te, d, chan, mySrc ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
return x;
|
|
|
|
}
|
2014-02-16 19:41:45 +01:00
|
|
|
|
2014-05-25 01:23:23 +02:00
|
|
|
if ( lastHandler.canHandle( te, d, chan, mySrc ) )
|
2014-02-16 19:41:45 +01:00
|
|
|
return lastHandler;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addExternalStorageInterface(IExternalStorageHandler ei)
|
|
|
|
{
|
|
|
|
Handlers.add( ei );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|