public static byte moveStackFromSlotAToSlotB(IInventory aTileEntity1,IInventory aTileEntity2,int aGrabFrom,int aPutTo,byte aMaxTargetStackSize,byte aMinTargetStackSize,byte aMaxMoveAtOnce,byte aMinMoveAtOnce){
  if (aTileEntity1 == null || aTileEntity2 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMaxMoveAtOnce <= 0 || aMinMoveAtOnce > aMaxMoveAtOnce)   return 0;
  ItemStack tStack1=aTileEntity1.getStackInSlot(aGrabFrom), tStack2=aTileEntity2.getStackInSlot(aPutTo), tStack3=null;
  if (tStack1 != null) {
    if (tStack2 != null && !areStacksEqual(tStack1,tStack2))     return 0;
    tStack3=copy(tStack1);
    aMaxTargetStackSize=(byte)Math.min(aMaxTargetStackSize,Math.min(tStack3.getMaxStackSize(),Math.min(tStack2 == null ? Integer.MAX_VALUE : tStack2.getMaxStackSize(),aTileEntity2.getInventoryStackLimit())));
    tStack3.stackSize=Math.min(tStack3.stackSize,aMaxTargetStackSize - (tStack2 == null ? 0 : tStack2.stackSize));
    if (tStack3.stackSize > aMaxMoveAtOnce)     tStack3.stackSize=aMaxMoveAtOnce;
    if (tStack3.stackSize + (tStack2 == null ? 0 : tStack2.stackSize) >= Math.min(tStack3.getMaxStackSize(),aMinTargetStackSize) && tStack3.stackSize >= aMinMoveAtOnce) {
      tStack3=aTileEntity1.decrStackSize(aGrabFrom,tStack3.stackSize);
      aTileEntity1.markDirty();
      if (tStack3 != null) {
        if (tStack2 == null) {
          aTileEntity2.setInventorySlotContents(aPutTo,copy(tStack3));
          aTileEntity2.markDirty();
        }
 else {
          tStack2.stackSize+=tStack3.stackSize;
          aTileEntity2.markDirty();
        }
        return (byte)tStack3.stackSize;
      }
    }
  }
  return 0;
}

public static byte moveStackFromSlotAToSlotB ( IInventory aTileEntity1 , IInventory aTileEntity2 , int aGrabFrom , int aPutTo , byte aMaxTargetStackSize , byte aMinTargetStackSize , byte aMaxMoveAtOnce , byte aMinMoveAtOnce ) { if ( aTileEntity1 == null || aTileEntity2 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMaxMoveAtOnce <= 0 || aMinMoveAtOnce > aMaxMoveAtOnce ) return 0 ; ItemStack tStack1 = aTileEntity1 . getStackInSlot ( aGrabFrom ) , tStack2 = aTileEntity2 . getStackInSlot ( aPutTo ) , tStack3 = null ; if ( tStack1 != null ) { if ( tStack2 != null && ! areStacksEqual ( tStack1 , tStack2 ) ) return 0 ; tStack3 = copy ( tStack1 ) ; aMaxTargetStackSize = ( byte ) Math . min ( aMaxTargetStackSize , Math . min ( tStack3 . getMaxStackSize ( ) , Math . min ( tStack2 == null ? Integer . MAX_VALUE : tStack2 . getMaxStackSize ( ) , aTileEntity2 . getInventoryStackLimit ( ) ) ) ) ; tStack3 . stackSize = Math . min ( tStack3 . stackSize , aMaxTargetStackSize - ( tStack2 == null ? 0 : tStack2 . stackSize ) ) ; if ( tStack3 . stackSize > aMaxMoveAtOnce ) tStack3 . stackSize = aMaxMoveAtOnce ; if ( tStack3 . stackSize + ( tStack2 == null ? 0 : tStack2 . stackSize ) >= Math . min ( tStack3 . getMaxStackSize ( ) , aMinTargetStackSize ) && tStack3 . stackSize >= aMinMoveAtOnce ) { tStack3 = aTileEntity1 . decrStackSize ( aGrabFrom , tStack3 . stackSize ) ; aTileEntity1 . markDirty ( ) ; if ( tStack3 != null ) { if ( tStack2 == null ) { aTileEntity2 . setInventorySlotContents ( aPutTo , copy ( tStack3 ) ) ; aTileEntity2 . markDirty ( ) ; } else { tStack2 . stackSize += tStack3 . stackSize ; aTileEntity2 . markDirty ( ) ; } return ( byte ) tStack3 . stackSize ; } } } return 0 ; }
moves stack from inv - slot to inv - slot , without checking if its even allowed . ( useful for internal inventory operations )
