Skip to main content

Recipe

Trait Recipe 

Source
pub trait Recipe {
    // Provided methods
    fn shaped(&self) -> Vec<ShapedRecipe> { ... }
    fn shapeless(&self) -> Vec<ShapelessRecipe> { ... }
    fn cooking(&self) -> Vec<CookingRecipe> { ... }
    fn has_recipes(&self) -> bool { ... }
    fn register(&self) { ... }
}
Expand description

A trait representing a collection of custom recipes that can be registered.

Types implementing this trait provide one or more recipes to be added to the server when Recipe::register is called. All recipes are returned in bulk to allow for efficient registration.

§Example

pub struct MyRecipes;

impl Recipe for MyRecipes {
    fn recipes(&self) -> Vec<RecipeKind> {
        vec![
            RecipeKind::Shaped {
                // ...
            },
        ]
    }
}

Provided Methods§

Source

fn shaped(&self) -> Vec<ShapedRecipe>

Returns the shaped crafting recipes to be registered.

Each entry describes a recipe with a fixed grid pattern. Override this to provide shaped recipes. Defaults to an empty vector.

Source

fn shapeless(&self) -> Vec<ShapelessRecipe>

Returns the shapeless crafting recipes to be registered.

Each entry describes a recipe where ingredients can be placed in any slot of the crafting grid. Override this to provide shapeless recipes. Defaults to an empty vector.

Source

fn cooking(&self) -> Vec<CookingRecipe>

Returns the cooking recipes to be registered.

Covers furnace, smoker, blast furnace, and campfire recipes. Override this to provide cooking recipes. Defaults to an empty vector.

Source

fn has_recipes(&self) -> bool

Returns true if there is at least one recipe to register.

Source

fn register(&self)

Registers all recipes returned by the trait methods.

Logs the count and time taken. If no recipes are present this is a no-op.

Implementors§