question: public static void mergeStacks ( IStorage sourceStorage , IStorage destStorage , Item sourceItem , Item targetItem , long count ) { if ( sourceItem . getItemCount ( ) >= count ) { long freeCount = targetItem . getFreeCount ( ) ; count = count > freeCount ? freeCount : count ; long leftCount = destStorage . increaseItemCount ( targetItem , count , sourceStorage . getStorageType ( ) == destStorage . getStorageType ( ) ? ItemUpdateType . INC_ITEM_MERGE : ItemUpdateType . INC_ITEM_COLLECT ) ; sourceStorage . decreaseItemCount ( sourceItem , count - leftCount , sourceStorage . getStorageType ( ) == destStorage . getStorageType ( ) ? ItemUpdateType . DEC_ITEM_SPLIT : ItemUpdateType . DEC_ITEM_SPLIT_MOVE ) ; } }
target:  Merge 2 stacks with simple validation