Struct Recipe
#[non_exhaustive]pub struct Recipe {
pub id: String,
pub kind: String,
pub group: String,
pub ingredients: Vec<Ingredient>,
pub results: Vec<ItemStack>,
pub cooking_time: Option<u32>,
pub experience: Option<f32>,
pub rule: Option<RecipeRule>,
pub json: Arc<Value>,
}Expand description
A recipe in force (RecipeManager.getAllRecipesFor), whatever its type
(vanilla’s or a mod’s own): its typed parts, and its file for whatever a
mod’s own type keeps there. json is the data-pack file’s JSON, read by a
mod at reload; host parsing helpers accept JSON text. Plain data.
A recipe the game could not parse (an ingredient it cannot read, no result) is not in force and is not listed.
ingredients and results are filled from the game’s own parse of the
shaped, shapeless and cooking types: a shaped recipe’s pattern cells row
by row (empty cells left out), a shapeless recipe’s list, a cooking
recipe’s ingredient, and the result as results[0]. Stonecutting,
smithing and special crafting recipes instead expose their typed RecipeRule
in rule, keeping these two lists empty. Dynamic outputs are rules/templates,
not fixed stacks; use LevelRef::recipe_for to match and assemble a crafting grid.
A mod’s own type leaves these fields empty and keeps its json.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: String<namespace>:<path>, its place under data/<namespace>/recipe/.
kind: StringThe recipe type, minecraft:smelting or mymod:crusher.
group: StringThe recipe book group, empty for none.
ingredients: Vec<Ingredient>What it takes, as above.
results: Vec<ItemStack>What it makes, as above.
cooking_time: Option<u32>Ticks a cooking recipe (smelting, blasting, smoking,
campfire_cooking) takes, its file’s cookingtime; None for any
other type.
experience: Option<f32>Experience a cooking recipe gives, None for any other type.
rule: Option<RecipeRule>Parsed stonecutting, smithing or special crafting rule. None for
shaped, shapeless, cooking and mod-defined types. The ingredient roles,
bounds and templates come from the game’s canonical parse.
json: Arc<Value>The recipe’s file, as the data pack wrote it.