pub struct RecipeRegistry {
recipes_by_id: Vec<&'static CraftingRecipe>,
recipes_by_key: FxHashMap<Identifier, usize>,
shaped_recipes: Vec<&'static ShapedRecipe>,
shapeless_recipes: Vec<&'static ShapelessRecipe>,
allows_registering: bool,
}Expand description
Registry for all recipes.
Fields§
§recipes_by_id: Vec<&'static CraftingRecipe>All recipes in registration order (unified storage for RegistryExt).
recipes_by_key: FxHashMap<Identifier, usize>Map from recipe key to index in recipes_by_id.
shaped_recipes: Vec<&'static ShapedRecipe>All shaped crafting recipes (for type-specific iteration).
shapeless_recipes: Vec<&'static ShapelessRecipe>All shapeless crafting recipes (for type-specific iteration).
allows_registering: boolWhether registration is still allowed.
Implementations§
Source§impl RecipeRegistry
impl RecipeRegistry
Sourcepub fn register_shaped(&mut self, recipe: &'static ShapedRecipe)
pub fn register_shaped(&mut self, recipe: &'static ShapedRecipe)
Registers a shaped recipe.
Sourcepub fn register_shapeless(&mut self, recipe: &'static ShapelessRecipe)
pub fn register_shapeless(&mut self, recipe: &'static ShapelessRecipe)
Registers a shapeless recipe.
Sourcepub fn find_crafting_recipe(
&self,
input: &CraftingInput,
) -> Option<CraftingRecipe>
pub fn find_crafting_recipe( &self, input: &CraftingInput, ) -> Option<CraftingRecipe>
Finds a matching crafting recipe for the given positioned input. Returns the first matching recipe, or None if no recipe matches.
Sourcepub fn find_crafting_recipe_2x2(
&self,
input: &CraftingInput,
) -> Option<CraftingRecipe>
pub fn find_crafting_recipe_2x2( &self, input: &CraftingInput, ) -> Option<CraftingRecipe>
Finds a matching crafting recipe for a 2x2 grid. Only checks recipes that can fit in a 2x2 grid.
Sourcepub fn get_shaped(&self, id: &Identifier) -> Option<&'static ShapedRecipe>
pub fn get_shaped(&self, id: &Identifier) -> Option<&'static ShapedRecipe>
Gets a shaped recipe by its identifier.
Sourcepub fn get_shapeless(&self, id: &Identifier) -> Option<&'static ShapelessRecipe>
pub fn get_shapeless(&self, id: &Identifier) -> Option<&'static ShapelessRecipe>
Gets a shapeless recipe by its identifier.
Sourcepub fn shaped_count(&self) -> usize
pub fn shaped_count(&self) -> usize
Returns the number of shaped recipes.
Sourcepub fn shapeless_count(&self) -> usize
pub fn shapeless_count(&self) -> usize
Returns the number of shapeless recipes.
Sourcepub fn iter_shaped(&self) -> impl Iterator<Item = &'static ShapedRecipe> + '_
pub fn iter_shaped(&self) -> impl Iterator<Item = &'static ShapedRecipe> + '_
Iterates over all shaped recipes.
Sourcepub fn iter_shapeless(
&self,
) -> impl Iterator<Item = &'static ShapelessRecipe> + '_
pub fn iter_shapeless( &self, ) -> impl Iterator<Item = &'static ShapelessRecipe> + '_
Iterates over all shapeless recipes.