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

69 lines
1.3 KiB
Java
Raw Normal View History

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
2014-03-28 01:33:35 +01:00
public ICellHandler getHandler(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;
}
}