question: public ItemStack addItem ( ItemStack drive , ItemStack item ) { if ( getMaxKilobits ( drive ) == - 1 ) { if ( getPartitioningMode ( drive ) == PartitioningMode . NONE || findDataIndexForPrototype ( drive , createPrototype ( item ) ) != - 1 ) { item . stackSize = 0 ; return null ; } else { return item ; } } int bitsFree = getKilobitsFreeFor ( drive , item ) ; int amountTaken = Math . min ( item . stackSize , bitsFree ) ; int current = getAmountStored ( drive , item ) ; if ( amountTaken > 0 ) { setAmountStored ( drive , item , current + amountTaken ) ; item . stackSize -= amountTaken ; markDirty ( drive ) ; } if ( item . stackSize <= 0 ) { return null ; } else { return item ; } }
target:  Insert as many items as possible from the given stack into a drive. <p> The stackSize of the passed stack will be affected. Return value is for convenience, and will be null if all items are taken.