public static boolean playerHasIngredients(EntityPlayerMP player, List<ItemStack> ingredients)
    {
        NonNullList<ItemStack> main = player.inventory.mainInventory;
        NonNullList<ItemStack> arm = player.inventory.armorInventory;

        for (ItemStack isIngredient : ingredients)
        {
            int target = isIngredient.getCount();
            for (int i = 0; i < main.size() + arm.size() && target > 0; i++)
            {
                ItemStack isPlayer = (i >= main.size()) ? arm.get(i - main.size()) : main.get(i);
                if (isPlayer != null && isIngredient != null && itemStackIngredientsMatch(isPlayer, isIngredient))
                    target -= isPlayer.getCount();
            }
            if (target > 0)
                return false;   // Don't have enough of this.
        }
        return true;
    }
public static boolean playerHasIngredients ( EntityPlayerMP player , List < ItemStack > ingredients ) { NonNullList < ItemStack > main = player . inventory . mainInventory ; NonNullList < ItemStack > arm = player . inventory . armorInventory ; for ( ItemStack isIngredient : ingredients ) { int target = isIngredient . getCount ( ) ; for ( int i = 0 ; i < main . size ( ) + arm . size ( ) && target > 0 ; i ++ ) { ItemStack isPlayer = ( i >= main . size ( ) ) ? arm . get ( i - main . size ( ) ) : main . get ( i ) ; if ( isPlayer != null && isIngredient != null && itemStackIngredientsMatch ( isPlayer , isIngredient ) ) target -= isPlayer . getCount ( ) ; } if ( target > 0 ) return false ; } return true ; }
Inspect a player's inventory to see whether they have enough items to form the supplied list of ItemStacks.<br>
The ingredients list MUST be amalgamated such that no two ItemStacks contain the same type of item.
@param player
@param ingredients an amalgamated list of ingredients
@return true if the player's inventory contains sufficient quantities of all the required items.