IAEItemStack ais = slotItem.copy();
ItemStack myItem = ais.getItemStack();
ais.setStackSize( myItem.getMaxStackSize() );
InventoryAdaptor adp = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
myItem.stackSize = (int) ais.getStackSize();
myItem = adp.simulateAdd( myItem );
if ( myItem != null )
ais.setStackSize( ais.getStackSize() - myItem.stackSize );
ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
if ( ais != null )
adp.addItems( ais.getItemStack() );
}
break;
case ROLL_DOWN:
if ( powerSrc == null || cellInv == null )
return;
int releaseQty = 1;
ItemStack isg = player.inventory.getItemStack();
if ( isg != null && releaseQty > 0 )
{
IAEItemStack ais = AEApi.instance().storage().createItemStack( isg );
ais.setStackSize( 1 );
IAEItemStack extracted = ais.copy();
ais = Platform.poweredInsert( powerSrc, cellInv, ais, mySrc );
if ( ais == null )
{
InventoryAdaptor ia = new AdaptorPlayerHand( player );
ItemStack fail = ia.removeItems( 1, extracted.getItemStack(), null );
if ( fail == null )
cellInv.extractItems( extracted, Actionable.MODULATE, mySrc );
updateHeld( player );
}
}
break;
case ROLL_UP:
case PICKUP_SINGLE:
if ( powerSrc == null || cellInv == null )
return;
if ( slotItem != null )
{
int liftQty = 1;
ItemStack item = player.inventory.getItemStack();
if ( item != null )
{
if ( item.stackSize >= item.getMaxStackSize() )
liftQty = 0;
if ( !Platform.isSameItemPrecise( slotItem.getItemStack(), item ) )
liftQty = 0;
}
if ( liftQty > 0 )
{
IAEItemStack ais = slotItem.copy();
ais.setStackSize( 1 );
ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
if ( ais != null )
{
InventoryAdaptor ia = new AdaptorPlayerHand( player );
ItemStack fail = ia.addItems( ais.getItemStack() );
if ( fail != null )
cellInv.injectItems( ais, Actionable.MODULATE, mySrc );
updateHeld( player );
}
}
}
break;
case PICKUP_OR_SET_DOWN:
if ( powerSrc == null || cellInv == null )
return;
if ( player.inventory.getItemStack() == null )
{
if ( slotItem != null )
{
IAEItemStack ais = slotItem.copy();
ais.setStackSize( ais.getItemStack().getMaxStackSize() );
ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
if ( ais != null )
player.inventory.setItemStack( ais.getItemStack() );
else
player.inventory.setItemStack( null );
updateHeld( player );
}
}
else
{
IAEItemStack ais = AEApi.instance().storage().createItemStack( player.inventory.getItemStack() );
ais = Platform.poweredInsert( powerSrc, cellInv, ais, mySrc );
if ( ais != null )
player.inventory.setItemStack( ais.getItemStack() );
else
player.inventory.setItemStack( null );
updateHeld( player );
}
break;
case SPLIT_OR_PLACE_SINGLE:
if ( powerSrc == null || cellInv == null )
return;
if ( player.inventory.getItemStack() == null )
{
if ( slotItem != null )
{
IAEItemStack ais = slotItem.copy();
long maxSize = ais.getItemStack().getMaxStackSize();
ais.setStackSize( maxSize );
ais = cellInv.extractItems( ais, Actionable.SIMULATE, mySrc );
if ( ais != null )
{
long stackSize = Math.min( maxSize, ais.getStackSize() );
ais.setStackSize( (stackSize + 1) >> 1 );
ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
}
if ( ais != null )
player.inventory.setItemStack( ais.getItemStack() );
else
player.inventory.setItemStack( null );
updateHeld( player );
}
}
else
{
IAEItemStack ais = AEApi.instance().storage().createItemStack( player.inventory.getItemStack() );
ais.setStackSize( 1 );
ais = Platform.poweredInsert( powerSrc, cellInv, ais, mySrc );
if ( ais == null )
{
ItemStack is = player.inventory.getItemStack();
is.stackSize--;
if ( is.stackSize <= 0 )
player.inventory.setItemStack( null );
updateHeld( player );
}
}
break;
case CREATIVE_DUPLICATE:
if ( player.capabilities.isCreativeMode && slotItem != null )
{
ItemStack is = slotItem.getItemStack();
is.stackSize = is.getMaxStackSize();
player.inventory.setItemStack( is );
updateHeld( player );
}
break;
case MOVE_REGION:
if ( powerSrc == null || cellInv == null )
return;
if ( slotItem != null )
{
int playerInv = 9 * 4;
for (int slotNum = 0; slotNum < playerInv; slotNum++)
{
IAEItemStack ais = slotItem.copy();
ItemStack myItem = ais.getItemStack();
ais.setStackSize( myItem.getMaxStackSize() );
InventoryAdaptor adp = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
myItem.stackSize = (int) ais.getStackSize();
myItem = adp.simulateAdd( myItem );
if ( myItem != null )
ais.setStackSize( ais.getStackSize() - myItem.stackSize );
ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
if ( ais != null )
adp.addItems( ais.getItemStack() );
else
return;
}
}