Applied-Energistics-2-tiler.../core/features/registries/ExternalStorageRegistry.java

46 lines
1.2 KiB
Java
Raw Normal View History

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;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IExternalStorageRegistry;
import appeng.api.storage.StorageChannel;
import appeng.core.features.registries.entries.ExternalIInv;
public class ExternalStorageRegistry implements IExternalStorageRegistry
{
List<IExternalStorageHandler> Handlers;
final ExternalIInv lastHandler = new ExternalIInv();
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)
{
for (IExternalStorageHandler x : Handlers)
{
2014-05-25 01:23:23 +02:00
if ( x.canHandle( te, d, chan, mySrc ) )
return x;
}
2014-05-25 01:23:23 +02:00
if ( lastHandler.canHandle( te, d, chan, mySrc ) )
return lastHandler;
return null;
}
@Override
public void addExternalStorageInterface(IExternalStorageHandler ei)
{
Handlers.add( ei );
}
}