pub struct ShapedRecipe {
pub id: Identifier,
pub category: CraftingCategory,
pub width: usize,
pub height: usize,
pub pattern: &'static [Ingredient],
pub result: RecipeResult,
pub show_notification: bool,
pub symmetrical: bool,
}Expand description
A shaped crafting recipe with a specific pattern.
Fields§
§id: Identifier§category: CraftingCategory§width: usize§height: usize§pattern: &'static [Ingredient]Pattern ingredients in row-major order (width * height).
result: RecipeResult§show_notification: bool§symmetrical: boolPre-computed: whether the pattern is horizontally symmetric.
Implementations§
Source§impl ShapedRecipe
impl ShapedRecipe
Sourcepub fn new(
id: Identifier,
category: CraftingCategory,
width: usize,
height: usize,
pattern: &'static [Ingredient],
result: RecipeResult,
show_notification: bool,
) -> Self
pub fn new( id: Identifier, category: CraftingCategory, width: usize, height: usize, pattern: &'static [Ingredient], result: RecipeResult, show_notification: bool, ) -> Self
Creates a new shaped recipe, pre-computing symmetry.
Sourcefn compute_symmetrical(width: usize, pattern: &[Ingredient]) -> bool
fn compute_symmetrical(width: usize, pattern: &[Ingredient]) -> bool
Computes whether the pattern is horizontally symmetric.
Sourcepub fn fits_in_2x2(&self) -> bool
pub fn fits_in_2x2(&self) -> bool
Returns true if this recipe fits in a 2x2 grid.
Sourcepub fn matches(&self, input: &CraftingInput) -> bool
pub fn matches(&self, input: &CraftingInput) -> bool
Tests if the crafting input matches this recipe.
Sourcefn matches_at(&self, input: &CraftingInput, mirrored: bool) -> bool
fn matches_at(&self, input: &CraftingInput, mirrored: bool) -> bool
Tests if the crafting input matches this recipe with optional mirroring.
Sourcepub fn get_remaining_items(&self, input: &CraftingInput) -> Vec<ItemStack>
pub fn get_remaining_items(&self, input: &CraftingInput) -> Vec<ItemStack>
Gets the remaining items after crafting (e.g., empty buckets).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ShapedRecipe
impl RefUnwindSafe for ShapedRecipe
impl Send for ShapedRecipe
impl Sync for ShapedRecipe
impl Unpin for ShapedRecipe
impl UnsafeUnpin for ShapedRecipe
impl UnwindSafe for ShapedRecipe
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more