Ingredients
Ingredient
s are predicate handlers for item-based inputs which check whether a certain ItemStack
meets the condition to be a valid input in a recipe. All vanilla recipes that take inputs use an Ingredient
or a list of Ingredient
s, which is then merged into a single Ingredient
.
Custom Ingredients
Custom ingredients can be specified by setting type
to the name of the ingredient's serializer, with the exception of compound ingredients. When no type is specified, type
defaults to the vanilla ingredient minecraft:item
. Custom ingredients can also easily be used in data generation.
NeoForge Types
NeoForge provides a few additional Ingredient
types for programmers to implement.
CompoundIngredient
Though they are functionally identical, Compound ingredients replaces the way one would implement a list of ingredients would in a recipe. They work as a set OR where the passed in stack must be within at least one of the supplied ingredients. This change was made to allow custom ingredients to work correctly within lists. As such, no type needs to be specified.
// For some input
[
// At least one of these ingredients must match to succeed
{
// Ingredient
},
{
// Custom ingredient
"type": "examplemod:example_ingredient"
}
]
StrictNBTIngredient
StrictNBTIngredient
s compare the item, damage, and the share tags (as defined by IForgeItem#getShareTag
) on an ItemStack
for exact equivalency. This can be used by specifying the type
as forge:nbt
.
// For some input
{
"type": "forge:nbt",
"item": "examplemod:example_item",
"nbt": {
// Add nbt data (must match exactly what is on the stack)
}
}