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;
  }
}

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 ; } }
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 .
