Buggy code:
public class TileGrid extends TileMachine implements IGrid { public static final String NBT_SORTING_DIRECTION = "SortingDirection" ; public static final String NBT_SORTING_TYPE = "SortingType" ; public static final String NBT_SEARCH_BOX_MODE = "SearchBoxMode" ; public static final int SORTING_DIRECTION_ASCENDING = 0 ; public static final int SORTING_DIRECTION_DESCENDING = 1 ; public static final int SORTING_TYPE_QUANTITY = 0 ; public static final int SORTING_TYPE_NAME = 1 ; public static final int SEARCH_BOX_MODE_NORMAL = 0 ; public static final int SEARCH_BOX_MODE_NORMAL_AUTOSELECTED = 1 ; public static final int SEARCH_BOX_MODE_JEI_SYNCHRONIZED = 2 ; public static final int SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED = 3 ; private Container craftingContainer = new Container ( ) { @ Override public boolean canInteractWith ( EntityPlayer player ) { } @ Override public void onCraftMatrixChanged ( IInventory inventory ) { } } ; private InventoryCrafting craftingInventory = new InventoryCrafting ( craftingContainer , 3 , 3 ) ; private InventoryCraftResult craftingResultInventory = new InventoryCraftResult ( ) ; private InventorySimple patternsInventory = new InventorySimple ( "patterns" , 2 , this ) ; private int sortingDirection = TileGrid . SORTING_DIRECTION_DESCENDING ; private int sortingType = TileGrid . SORTING_TYPE_NAME ; private int searchBoxMode = TileGrid . SEARCH_BOX_MODE_NORMAL ; private List < ItemGroup > itemGroups = new ArrayList < ItemGroup > ( ) ; @ Override public int getEnergyUsage ( ) { } @ Override public void updateMachine ( ) { } public EnumGridType getType ( ) { } @ Override public List < ItemGroup > getItemGroups ( ) { } @ Override public void onItemPush ( int playerSlot , boolean one ) { } @ Override public void onItemPull ( int id , int flags ) { } public InventoryCrafting getCraftingInventory ( ) { } public InventoryCraftResult getCraftingResultInventory ( ) { } public InventorySimple getPatternsInventory ( ) { } public void onCraftingMatrixChanged ( ) { } public void onCrafted ( ContainerGrid container ) { } public void onCraftedShift ( ContainerGrid container , EntityPlayer player ) { List < ItemStack > craftedItemsList = new ArrayList < ItemStack > ( ) ; int craftedItems = 0 ; ItemStack crafted = craftingResultInventory . getStackInSlot ( 0 ) ; while ( true ) { onCrafted ( container ) ; craftedItemsList . add ( crafted . copy ( ) ) ; craftedItems += crafted . stackSize ; <START_BUG> if ( ( ! ( RefinedStorageUtils . compareStack ( crafted , craftingResultInventory . getStackInSlot ( 0 ) ) ) ) || ( ( craftedItems + ( crafted . stackSize ) ) > 64 ) ) { <END_BUG> break ; } } for ( ItemStack craftedItem : craftedItemsList ) { if ( ! ( player . inventory . addItemStackToInventory ( craftedItem . copy ( ) ) ) ) { if ( ( ( controller ) != null ) && ( controller . push ( craftedItem . copy ( ) ) ) ) { } else { RefinedStorageUtils . dropStack ( player . worldObj , craftedItem , player . getPosition ( ) . getX ( ) , player . getPosition ( ) . getY ( ) , player . getPosition ( ) . getZ ( ) ) ; } } } } public void onCreatePattern ( ) { } public boolean canCreatePattern ( ) { } public void onRecipeTransfer ( ItemStack [ ] [ ] recipe ) { } public int getSortingDirection ( ) { } public void setSortingDirection ( int sortingDirection ) { } public int getSortingType ( ) { } public void setSortingType ( int sortingType ) { } public int getSearchBoxMode ( ) { } public void setSearchBoxMode ( int searchBoxMode ) { } @ Override public void onSortingTypeChanged ( int type ) { } @ Override public void onSortingDirectionChanged ( int direction ) { } @ Override public void onSearchBoxModeChanged ( int searchBoxMode ) { } @ Override public void onCraftingRequested ( int id , int quantity ) { } @ Override public IRedstoneModeConfig getRedstoneModeSetting ( ) { } @ Override public void readFromNBT ( NBTTagCompound nbt ) { } @ Override public void writeToNBT ( NBTTagCompound nbt ) { } @ Override public void sendContainerData ( ByteBuf buf ) { } @ Override public void receiveContainerData ( ByteBuf buf ) { } @ Override public Class < ? extends Container > getContainer ( ) { } @ Override public IInventory getDroppedInventory ( ) { } }

Fix:
if ( ( ! ( RefinedStorageUtils . compareStack ( crafted , craftingResultInventory . getStackInSlot ( 0 ) ) ) ) || ( ( craftedItems + ( crafted . stackSize ) ) > ( crafted . getMaxStackSize ( ) ) ) ) {