public static List getIngredients()

in Minecraft/src/main/java/com/microsoft/Malmo/Utils/CraftingHelper.java [82:132]


    public static List<ItemStack> getIngredients(IRecipe recipe) {
        // IRecipe helpfully has no method for inspecting the raw ingredients, so we need to do different things depending on the subclass.
        List<ItemStack> ingredients = new ArrayList<ItemStack>();
        if (recipe instanceof ShapelessRecipes) {
            List<?> items = (List<?>) ((ShapelessRecipes) recipe).recipeItems;
            for (Object obj : items) {
                if (obj instanceof ItemStack)
                    ingredients.add((ItemStack) obj);
            }
        } else if (recipe instanceof ShapelessOreRecipe) {
            NonNullList<Object> objs = ((ShapelessOreRecipe) recipe).getInput();
            for (Object o : objs) {
                if (o != null) {
                    if (o instanceof ItemStack)
                        ingredients.add((ItemStack) o);
                    else if (o instanceof List) {
                        List<?> stacks = (List<?>) o;
                        for (Object stack : stacks) {
                            if (stack instanceof ItemStack)
                                ingredients.add((ItemStack) stack);
                        }
                    }
                }
            }
        } else if (recipe instanceof ShapedRecipes) {
            ItemStack[] stack = ((ShapedRecipes) recipe).recipeItems;
            for (int i = 0; i < stack.length; i++) {
                if (stack[i] != null)
                    ingredients.add(stack[i]);
            }
        } else if (recipe instanceof ShapedOreRecipe) {
            Object[] items = ((ShapedOreRecipe) recipe).getInput();
            for (int i = 0; i < items.length; i++) {
                Object obj = items[i];
                if (obj != null) {
                    if (obj instanceof ItemStack)
                        ingredients.add((ItemStack) obj);
                    else if (obj instanceof List) {
                        List<?> stacks = (List<?>) items[i];
                        for (Object stack : stacks) {
                            if (stack instanceof ItemStack)
                                ingredients.add((ItemStack) stack);
                        }
                    }
                }
            }
        } else {
            return null;
        }
        return consolidateItemStacks(ingredients);
    }