steel_registry/recipe/
single_item.rs1use steel_utils::{DowncastType, DowncastTypeKey};
4
5use crate::item_stack::ItemStack;
6use crate::item_stack_template::ItemStackTemplate;
7
8use super::{Ingredient, RecipeData, RecipeInput, RecipeMatches, RecipeProperties};
9
10#[derive(Debug, Clone)]
12pub struct SingleItemRecipeInput {
13 pub item: ItemStack,
14}
15
16impl SingleItemRecipeInput {
17 #[must_use]
18 pub const fn new(item: ItemStack) -> Self {
19 Self { item }
20 }
21}
22
23unsafe impl DowncastType for SingleItemRecipeInput {
25 const TYPE_KEY: DowncastTypeKey = DowncastTypeKey::new("steel:recipe_input/single_item");
26}
27
28impl RecipeInput for SingleItemRecipeInput {
29 fn is_empty(&self) -> bool {
30 self.item.is_empty()
31 }
32}
33
34#[derive(Debug)]
36pub struct CookingRecipe {
37 pub properties: RecipeProperties,
38 pub ingredient: Ingredient,
39 pub result: ItemStackTemplate,
40 pub experience: f32,
41 pub cooking_time: i32,
42}
43
44unsafe impl DowncastType for CookingRecipe {
46 const TYPE_KEY: DowncastTypeKey = DowncastTypeKey::new("steel:recipe_data/cooking");
47}
48
49impl RecipeData for CookingRecipe {
50 fn properties(&self) -> Option<&RecipeProperties> {
51 Some(&self.properties)
52 }
53}
54
55#[derive(Debug)]
57pub struct StonecuttingRecipe {
58 pub properties: RecipeProperties,
59 pub ingredient: Ingredient,
60 pub result: ItemStackTemplate,
61}
62
63unsafe impl DowncastType for StonecuttingRecipe {
65 const TYPE_KEY: DowncastTypeKey = DowncastTypeKey::new("steel:recipe_data/stonecutting");
66}
67
68impl RecipeData for StonecuttingRecipe {
69 fn properties(&self) -> Option<&RecipeProperties> {
70 Some(&self.properties)
71 }
72}
73
74impl RecipeMatches<SingleItemRecipeInput> for CookingRecipe {
75 fn matches(&self, input: &SingleItemRecipeInput) -> bool {
76 self.ingredient.test(&input.item)
77 }
78}
79
80impl RecipeMatches<SingleItemRecipeInput> for StonecuttingRecipe {
81 fn matches(&self, input: &SingleItemRecipeInput) -> bool {
82 self.ingredient.test(&input.item)
83 }
84}