Applied-Energistics-2-tiler.../core/features/registries/CellRegistry.java
2013-12-27 16:59:59 -06:00

68 lines
1.3 KiB
Java

package appeng.core.features.registries;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import appeng.api.storage.ICellHandler;
import appeng.api.storage.ICellRegistry;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
public class CellRegistry implements ICellRegistry
{
List<ICellHandler> handlers;
public CellRegistry() {
handlers = new ArrayList();
}
@Override
public void addCellHandler(ICellHandler h)
{
if ( h != null )
handlers.add( h );
}
@Override
public boolean isCellHandled(ItemStack is)
{
if ( is == null )
return false;
for (ICellHandler ch : handlers)
if ( ch.isCell( is ) )
return true;
return false;
}
@Override
public ICellHandler getHander(ItemStack is)
{
if ( is == null )
return null;
for (ICellHandler ch : handlers)
{
if ( ch.isCell( is ) )
{
return ch;
}
}
return null;
}
@Override
public IMEInventoryHandler getCellInventory(ItemStack is, StorageChannel chan)
{
if ( is == null )
return null;
for (ICellHandler ch : handlers)
{
if ( ch.isCell( is ) )
{
return ch.getCellInventory( is, chan );
}
}
return null;
}
}