2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
package appeng.me.storage;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2014-12-29 21:59:05 +01:00
|
|
|
|
2014-02-21 21:36:40 +01:00
|
|
|
import appeng.api.AEApi;
|
2014-01-20 17:41:37 +01:00
|
|
|
import appeng.api.config.AccessRestriction;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.config.Actionable;
|
2014-01-20 17:41:37 +01:00
|
|
|
import appeng.api.networking.security.BaseActionSource;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.storage.IMEInventoryHandler;
|
2014-01-20 17:41:37 +01:00
|
|
|
import appeng.api.storage.StorageChannel;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.storage.data.IAEItemStack;
|
2014-01-20 17:41:37 +01:00
|
|
|
import appeng.api.storage.data.IItemList;
|
2014-01-26 07:48:09 +01:00
|
|
|
import appeng.items.contents.CellConfig;
|
2014-01-20 17:41:37 +01:00
|
|
|
import appeng.util.item.AEItemStack;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-01-20 17:41:37 +01:00
|
|
|
public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
2014-09-29 09:54:34 +02:00
|
|
|
final IItemList<IAEItemStack> itemListCache = AEApi.instance().storage().createItemList();
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
protected CreativeCellInventory( ItemStack o )
|
2014-10-04 08:08:28 +02:00
|
|
|
{
|
2014-01-20 17:41:37 +01:00
|
|
|
CellConfig cc = new CellConfig( o );
|
2015-04-03 08:54:31 +02:00
|
|
|
for( ItemStack is : cc )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( is != null )
|
2014-01-20 17:41:37 +01:00
|
|
|
{
|
|
|
|
IAEItemStack i = AEItemStack.create( is );
|
|
|
|
i.setStackSize( Integer.MAX_VALUE );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.itemListCache.add( i );
|
2014-01-20 17:41:37 +01:00
|
|
|
}
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
public static IMEInventoryHandler getCell( ItemStack o )
|
|
|
|
{
|
|
|
|
return new CellInventoryHandler( new CreativeCellInventory( o ) );
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
IAEItemStack local = this.itemListCache.findPrecise( input );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( local == null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-01-20 17:41:37 +01:00
|
|
|
return input;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-01-20 17:41:37 +01:00
|
|
|
|
|
|
|
return null;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
IAEItemStack local = this.itemListCache.findPrecise( request );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( local == null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-01-20 17:41:37 +01:00
|
|
|
return null;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-01-20 17:41:37 +01:00
|
|
|
|
|
|
|
return request.copy();
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public IItemList<IAEItemStack> getAvailableItems( IItemList out )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( IAEItemStack ais : this.itemListCache )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-01-20 17:41:37 +01:00
|
|
|
out.add( ais );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-01-20 17:41:37 +01:00
|
|
|
return out;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-20 17:41:37 +01:00
|
|
|
public StorageChannel getChannel()
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-20 17:41:37 +01:00
|
|
|
return StorageChannel.ITEMS;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-20 17:41:37 +01:00
|
|
|
public AccessRestriction getAccess()
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-20 17:41:37 +01:00
|
|
|
return AccessRestriction.READ_WRITE;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public boolean isPrioritized( IAEItemStack input )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.itemListCache.findPrecise( input ) != null;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public boolean canAccept( IAEItemStack input )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.itemListCache.findPrecise( input ) != null;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-20 17:41:37 +01:00
|
|
|
public int getPriority()
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-20 17:41:37 +01:00
|
|
|
return 0;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-20 17:41:37 +01:00
|
|
|
public int getSlot()
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-20 17:41:37 +01:00
|
|
|
return 0;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-06-20 09:10:02 +02:00
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public boolean validForPass( int i )
|
2014-06-20 09:10:02 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|