Recipe.shapeless constructor

Recipe.shapeless(
  1. List<Item> ingreds,
  2. Item result, {
  3. String name = 'recipe',
  4. int? id,
  5. bool exactlyPlaced = false,
  6. int? exactResult,
})

The API also supports shapeless crafting. That means you can set the ingredients in any shape and it would be the same result.

Recipe.shapeless
List<Item> The ingredients in any shape(without slots)
... stays the same

Example:

Recipe.shapeless(
    [
       Item(Blocks.oak_planks),
       Item(Items.diamond)
    ],
    Item(Items.diamond_sword)
)

Implementation

factory Recipe.shapeless(
  List<Item> ingreds,
  Item result, {
  String name = 'recipe',
  int? id,
  bool exactlyPlaced = false,
  int? exactResult,
}) {
  var ingredients = <int, Item>{};
  for (var i = 0; i < ingreds.length; i++) {
    ingredients[i + 1] = ingreds[i];
  }

  return Recipe(
    ingredients,
    result,
    id: id,
    name: name,
    type: RecipeType.shapeless,
    exactlyPlaced: exactlyPlaced,
    exactResult: exactResult,
  );
}