Edit on GitHub

hexdoc.minecraft.recipe

 1__all__ = [
 2    "BlastingRecipe",
 3    "CampfireCookingRecipe",
 4    "CookingRecipe",
 5    "CraftingRecipe",
 6    "CraftingShapedRecipe",
 7    "CraftingShapelessRecipe",
 8    "ItemIngredient",
 9    "ItemIngredientList",
10    "ItemResult",
11    "MinecraftItemIdIngredient",
12    "MinecraftItemTagIngredient",
13    "Recipe",
14    "SmeltingRecipe",
15    "SmithingRecipe",
16    "SmithingTransformRecipe",
17    "SmithingTrimRecipe",
18    "SmokingRecipe",
19    "StonecuttingRecipe",
20]
21
22from .ingredients import (
23    ItemIngredient,
24    ItemIngredientList,
25    ItemResult,
26    MinecraftItemIdIngredient,
27    MinecraftItemTagIngredient,
28)
29from .recipes import (
30    BlastingRecipe,
31    CampfireCookingRecipe,
32    CookingRecipe,
33    CraftingRecipe,
34    CraftingShapedRecipe,
35    CraftingShapelessRecipe,
36    Recipe,
37    SmeltingRecipe,
38    SmithingRecipe,
39    SmithingTransformRecipe,
40    SmithingTrimRecipe,
41    SmokingRecipe,
42    StonecuttingRecipe,
43)
class BlastingRecipe(hexdoc.minecraft.recipe.CookingRecipe):
143class BlastingRecipe(
144    CookingRecipe,
145    type="minecraft:blasting",
146    workstation="minecraft:blast_furnace",
147):
148    cookingtime: int = 100

Base model for Minecraft recipes.

https://minecraft.wiki/w/Recipe

cookingtime: int
def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Args: self: The BaseModel instance. context: The context.

class CampfireCookingRecipe(hexdoc.minecraft.recipe.CookingRecipe):
151class CampfireCookingRecipe(
152    CookingRecipe,
153    type="minecraft:campfire_cooking",
154    workstation="minecraft:campfire",
155):
156    cookingtime: int = 100

Base model for Minecraft recipes.

https://minecraft.wiki/w/Recipe

cookingtime: int
def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Args: self: The BaseModel instance. context: The context.

class CookingRecipe(hexdoc.minecraft.recipe.Recipe):
136class CookingRecipe(Recipe):
137    ingredient: ItemIngredientList
138    result: ItemWithTexture
139    experience: float
140    cookingtime: int

Base model for Minecraft recipes.

https://minecraft.wiki/w/Recipe

ingredient: typing.Annotated[list[ItemIngredient], BeforeValidator(func=<function _validate_single_item_to_list at 0x7f29ae1e8d60>, json_schema_input_type=PydanticUndefined), AfterValidator(func=<function _validate_flatten_nested_tags at 0x7f29ae1e9300>)]
experience: float
cookingtime: int
def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Args: self: The BaseModel instance. context: The context.

class CraftingRecipe(hexdoc.minecraft.recipe.Recipe):
111class CraftingRecipe(Recipe, workstation="minecraft:crafting_table"):
112    result: ItemResult

Base model for Minecraft recipes.

https://minecraft.wiki/w/Recipe

result: ItemResult
def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Args: self: The BaseModel instance. context: The context.

class CraftingShapedRecipe(hexdoc.minecraft.recipe.CraftingRecipe):
119class CraftingShapedRecipe(CraftingRecipe, type="minecraft:crafting_shaped"):
120    key: dict[str, ItemIngredientList]
121    pattern: list[str]
122
123    @property
124    def ingredients(self) -> Iterator[ItemIngredientList | None]:
125        for row in self.pattern:
126            if len(row) > 3:
127                raise ValueError(f"Expected len(row) <= 3, got {len(row)}: `{row}`")
128            for item_key in row.ljust(3):
129                match item_key:
130                    case " ":
131                        yield None
132                    case _:
133                        yield self.key[item_key]

Base model for Minecraft recipes.

https://minecraft.wiki/w/Recipe

key: dict[str, typing.Annotated[list[ItemIngredient], BeforeValidator(func=<function _validate_single_item_to_list at 0x7f29ae1e8d60>, json_schema_input_type=PydanticUndefined), AfterValidator(func=<function _validate_flatten_nested_tags at 0x7f29ae1e9300>)]]
pattern: list[str]
ingredients: Iterator[Optional[Annotated[list[ItemIngredient], BeforeValidator(func=<function _validate_single_item_to_list at 0x7f29ae1e8d60>, json_schema_input_type=PydanticUndefined), AfterValidator(func=<function _validate_flatten_nested_tags at 0x7f29ae1e9300>)]]]
123    @property
124    def ingredients(self) -> Iterator[ItemIngredientList | None]:
125        for row in self.pattern:
126            if len(row) > 3:
127                raise ValueError(f"Expected len(row) <= 3, got {len(row)}: `{row}`")
128            for item_key in row.ljust(3):
129                match item_key:
130                    case " ":
131                        yield None
132                    case _:
133                        yield self.key[item_key]
def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Args: self: The BaseModel instance. context: The context.

class CraftingShapelessRecipe(hexdoc.minecraft.recipe.CraftingRecipe):
115class CraftingShapelessRecipe(CraftingRecipe, type="minecraft:crafting_shapeless"):
116    ingredients: list[ItemIngredientList]

Base model for Minecraft recipes.

https://minecraft.wiki/w/Recipe

ingredients: list[typing.Annotated[list[ItemIngredient], BeforeValidator(func=<function _validate_single_item_to_list at 0x7f29ae1e8d60>, json_schema_input_type=PydanticUndefined), AfterValidator(func=<function _validate_flatten_nested_tags at 0x7f29ae1e9300>)]]
def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Args: self: The BaseModel instance. context: The context.

class ItemIngredient(hexdoc.model.tagged_union.TypeTaggedUnion, abc.ABC):
23class ItemIngredient(TypeTaggedUnion, ABC):
24    @property
25    def item(self) -> ItemWithTexture | TagWithTexture: ...

Implements internally tagged unions using the Registry pattern.

To ensure your subtypes are loaded even if they're not imported by any file, add a Pluggy hook implementation for hexdoc_load_tagged_unions() -> list[Package].

Subclasses MUST NOT be generic unless they provide a default value for all __init_subclass__ arguments. See pydantic/7171 for more info.

Args: key: The dict key for the internal tag. If None, the parent's value is used. value: The expected tag value for this class. Should be None for types which shouldn't be instantiated (eg. abstract classes).

24    @property
25    def item(self) -> ItemWithTexture | TagWithTexture: ...
ItemIngredientList = typing.Annotated[list[ItemIngredient], BeforeValidator(func=<function _validate_single_item_to_list>, json_schema_input_type=PydanticUndefined), AfterValidator(func=<function _validate_flatten_nested_tags>)]
class ItemResult(hexdoc.model.base.HexdocModel):
44class ItemResult(HexdocModel):
45    item: ItemWithTexture
46    count: int = 1

Base class for all Pydantic models in hexdoc.

Sets the default model config, and overrides __init__ to allow using the init_context context manager to set validation context for constructors.

count: int
class MinecraftItemIdIngredient(hexdoc.minecraft.recipe.ItemIngredient):
28class MinecraftItemIdIngredient(ItemIngredient, type=NoValue):
29    item_: ItemWithTexture = Field(alias="item")
30
31    @property
32    def item(self):
33        return self.item_

Implements internally tagged unions using the Registry pattern.

To ensure your subtypes are loaded even if they're not imported by any file, add a Pluggy hook implementation for hexdoc_load_tagged_unions() -> list[Package].

Subclasses MUST NOT be generic unless they provide a default value for all __init_subclass__ arguments. See pydantic/7171 for more info.

Args: key: The dict key for the internal tag. If None, the parent's value is used. value: The expected tag value for this class. Should be None for types which shouldn't be instantiated (eg. abstract classes).

item
31    @property
32    def item(self):
33        return self.item_
class MinecraftItemTagIngredient(hexdoc.minecraft.recipe.ItemIngredient):
36class MinecraftItemTagIngredient(ItemIngredient, type=NoValue):
37    tag: AssumeTag[TagWithTexture]
38
39    @property
40    def item(self):
41        return self.tag

Implements internally tagged unions using the Registry pattern.

To ensure your subtypes are loaded even if they're not imported by any file, add a Pluggy hook implementation for hexdoc_load_tagged_unions() -> list[Package].

Subclasses MUST NOT be generic unless they provide a default value for all __init_subclass__ arguments. See pydantic/7171 for more info.

Args: key: The dict key for the internal tag. If None, the parent's value is used. value: The expected tag value for this class. Should be None for types which shouldn't be instantiated (eg. abstract classes).

tag: typing.Annotated[hexdoc.minecraft.assets.TagWithTexture, BeforeValidator(func=<function _add_hashtag_to_tag at 0x7f29b00e49a0>, json_schema_input_type=PydanticUndefined)]
item
39    @property
40    def item(self):
41        return self.tag
class Recipe(hexdoc.model.tagged_union.TypeTaggedTemplate, hexdoc.model.id.ResourceModel):
 21class Recipe(TypeTaggedTemplate, ResourceModel):
 22    """Base model for Minecraft recipes.
 23
 24    https://minecraft.wiki/w/Recipe
 25    """
 26
 27    category: str | None = None
 28    group: str | None = None
 29    show_notification: AtLeast_1_20[bool] | Before_1_20[None] = Field(
 30        default_factory=ValueIfVersion(">=1.20", True, None)
 31    )
 32
 33    # not in the actual model
 34
 35    _workstation: ClassVar[ResourceLocation | None] = None
 36
 37    _gui_name: LocalizedStr | None = PrivateAttr(None)
 38    _gui_texture: ImageTexture | None = PrivateAttr(None)
 39
 40    def __init_subclass__(
 41        cls,
 42        *,
 43        type: str | InheritType | None = Inherit,
 44        workstation: str | InheritType | None = Inherit,
 45        **kwargs: Unpack[ConfigDict],
 46    ):
 47        super().__init_subclass__(type=type, **kwargs)
 48
 49        match workstation:
 50            case str():
 51                cls._workstation = ResourceLocation.from_str(workstation)
 52            case None:
 53                cls._workstation = None
 54            case _:
 55                pass
 56
 57    @classmethod
 58    def load_resource(cls, id: ResourceLocation, loader: ModResourceLoader):
 59        return loader.load_resource("data", "recipes", id)
 60
 61    @classproperty
 62    @classmethod
 63    @override
 64    def template(cls):
 65        return cls.template_id.template_path("recipes")
 66
 67    @classproperty
 68    @classmethod
 69    @override
 70    def template_id(cls):
 71        assert cls._workstation is not None
 72        return cls._workstation
 73
 74    @property
 75    def gui_name(self):
 76        return self._gui_name
 77
 78    @property
 79    def gui_texture(self):
 80        return self._gui_texture
 81
 82    @classproperty
 83    @classmethod
 84    def _gui_texture_id(cls) -> ResourceLocation | None:
 85        """ResourceLocation of the background image for this recipe type."""
 86        if cls._workstation is None:
 87            return None
 88        return ResourceLocation(
 89            cls._workstation.namespace,
 90            f"textures/gui/hexdoc/{cls._workstation.path}.png",
 91        )
 92
 93    def _localize_workstation(self, i18n: I18n):
 94        if self._workstation is not None:
 95            return i18n.localize_item(self._workstation)
 96
 97    @model_validator(mode="after")
 98    def _load_gui_texture(self, info: ValidationInfo):
 99        self._gui_name = self._localize_workstation(I18n.of(info))
100
101        if self._gui_texture_id is not None:
102            self._gui_texture = validate_texture(
103                self._gui_texture_id,
104                context=info,
105                model_type=ImageTexture,
106            )
107
108        return self

Base model for Minecraft recipes.

https://minecraft.wiki/w/Recipe

category: str | None
group: str | None
show_notification: Union[Annotated[bool, IsVersion(version_spec='>=1.20', version_source=<class 'hexdoc.core.MinecraftVersion'>)], Annotated[NoneType, IsVersion(version_spec='<1.20', version_source=<class 'hexdoc.core.MinecraftVersion'>)]]
@classmethod
def load_resource( cls, id: hexdoc.core.ResourceLocation, loader: hexdoc.core.ModResourceLoader):
57    @classmethod
58    def load_resource(cls, id: ResourceLocation, loader: ModResourceLoader):
59        return loader.load_resource("data", "recipes", id)
def template(unknown):

Equivalent of classmethod(property(...)).

Use @classproperty. Do not instantiate this class directly.

def template_id(unknown):

Equivalent of classmethod(property(...)).

Use @classproperty. Do not instantiate this class directly.

gui_name
74    @property
75    def gui_name(self):
76        return self._gui_name
gui_texture
78    @property
79    def gui_texture(self):
80        return self._gui_texture
def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Args: self: The BaseModel instance. context: The context.

class SmeltingRecipe(hexdoc.minecraft.recipe.CookingRecipe):
159class SmeltingRecipe(
160    CookingRecipe,
161    type="minecraft:smelting",
162    workstation="minecraft:furnace",
163):
164    cookingtime: int = 200

Base model for Minecraft recipes.

https://minecraft.wiki/w/Recipe

cookingtime: int
def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Args: self: The BaseModel instance. context: The context.

class SmithingRecipe(hexdoc.minecraft.recipe.Recipe):
175class SmithingRecipe(Recipe, workstation="minecraft:smithing_table"):
176    base: ItemIngredient
177    addition: ItemIngredient
178    template_ingredient: ItemIngredient = Field(alias="template")
179
180    @property
181    def result_item(self):
182        return self.base.item

Base model for Minecraft recipes.

https://minecraft.wiki/w/Recipe

addition: ItemIngredient
template_ingredient: ItemIngredient
result_item
180    @property
181    def result_item(self):
182        return self.base.item
def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Args: self: The BaseModel instance. context: The context.

class SmithingTransformRecipe(hexdoc.minecraft.recipe.SmithingRecipe):
185class SmithingTransformRecipe(SmithingRecipe, type="minecraft:smithing_transform"):
186    result: ItemWithTexture
187
188    @property
189    def result_item(self):
190        return self.result

Base model for Minecraft recipes.

https://minecraft.wiki/w/Recipe

result_item
188    @property
189    def result_item(self):
190        return self.result
def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Args: self: The BaseModel instance. context: The context.

class SmithingTrimRecipe(hexdoc.minecraft.recipe.SmithingRecipe):
193class SmithingTrimRecipe(SmithingRecipe, type="minecraft:smithing_trim"):
194    pass

Base model for Minecraft recipes.

https://minecraft.wiki/w/Recipe

def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Args: self: The BaseModel instance. context: The context.

class SmokingRecipe(hexdoc.minecraft.recipe.CookingRecipe):
167class SmokingRecipe(
168    CookingRecipe,
169    type="minecraft:smoking",
170    workstation="minecraft:smoker",
171):
172    cookingtime: int = 100

Base model for Minecraft recipes.

https://minecraft.wiki/w/Recipe

cookingtime: int
def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Args: self: The BaseModel instance. context: The context.

class StonecuttingRecipe(hexdoc.minecraft.recipe.Recipe):
197class StonecuttingRecipe(
198    Recipe,
199    type="minecraft:stonecutting",
200    workstation="minecraft:stonecutter",
201):
202    ingredient: ItemIngredientList
203    result: ItemWithTexture
204    count: int

Base model for Minecraft recipes.

https://minecraft.wiki/w/Recipe

ingredient: typing.Annotated[list[ItemIngredient], BeforeValidator(func=<function _validate_single_item_to_list at 0x7f29ae1e8d60>, json_schema_input_type=PydanticUndefined), AfterValidator(func=<function _validate_flatten_nested_tags at 0x7f29ae1e9300>)]
count: int
def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Args: self: The BaseModel instance. context: The context.