pub struct RecipeRegistrar<'a> { /* private fields */ }Expand description
Plugin-facing handle to the recipe registry with event dispatch.
Holds mutable references to a RecipeRegistryHandle trait object
and the game event bus, plus a shared reference to a dispatch
context. Every mutation method dispatches the appropriate lifecycle
event and respects Validate-stage cancellation.
Implementations§
Source§impl<'a> RecipeRegistrar<'a>
impl<'a> RecipeRegistrar<'a>
Sourcepub fn add_shaped(&mut self, recipe: OwnedShapedRecipe) -> bool
pub fn add_shaped(&mut self, recipe: OwnedShapedRecipe) -> bool
Registers a shaped recipe.
Dispatches RecipeRegisterEvent at Validate. If a handler
cancels the event, the registry is left untouched and this
method returns false. Otherwise the recipe is inserted and
RecipeRegisteredEvent is dispatched at Post; returns true.
Sourcepub fn add_shapeless(&mut self, recipe: OwnedShapelessRecipe) -> bool
pub fn add_shapeless(&mut self, recipe: OwnedShapelessRecipe) -> bool
Registers a shapeless recipe.
Same dispatch semantics as add_shaped.
The caller is responsible for sorting recipe.ingredients
ascending — required for correct matching.
Sourcepub fn remove_by_id(&mut self, id: &RecipeId) -> bool
pub fn remove_by_id(&mut self, id: &RecipeId) -> bool
Removes the recipe with the given id, dispatching
RecipeUnregisteredEvent at Post on success.
Returns true if a recipe was removed, false if the id was
not registered.
Sourcepub fn remove_by_result(&mut self, result_id: i32) -> usize
pub fn remove_by_result(&mut self, result_id: i32) -> usize
Removes every recipe (shaped and shapeless) producing the given
result_id. Dispatches one RecipeUnregisteredEvent per
removed entry. Returns the number of recipes removed.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Removes every recipe and dispatches one
RecipeUnregisteredEvent per removed entry.
Sourcepub fn contains(&self, id: &RecipeId) -> bool
pub fn contains(&self, id: &RecipeId) -> bool
Returns true if the registry contains a recipe with the given id.
Sourcepub fn get(&self, id: &RecipeId) -> Option<Recipe>
pub fn get(&self, id: &RecipeId) -> Option<Recipe>
Returns a clone of the recipe with the given id, or None.
Sourcepub fn shaped_count(&self) -> usize
pub fn shaped_count(&self) -> usize
Returns the number of registered shaped recipes.
Sourcepub fn shapeless_count(&self) -> usize
pub fn shapeless_count(&self) -> usize
Returns the number of registered shapeless recipes.