Class DefaultCustomIngredients
java.lang.Object
net.fabricmc.fabric.api.recipe.v1.ingredient.DefaultCustomIngredients
Factory methods for the custom ingredients directly provided by Fabric API.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Ingredient
all
(Ingredient... ingredients) Creates an ingredient that matches when its sub-ingredients all match.static Ingredient
any
(Ingredient... ingredients) Creates an ingredient that matches when any of its sub-ingredients matches.static Ingredient
components
(ItemStack stack) Creates an ingredient that matches the passed template stack, includingItemStack.getComponentChanges()
.static Ingredient
components
(Ingredient base, UnaryOperator<ComponentChanges.Builder> operator) static Ingredient
components
(Ingredient base, ComponentChanges components) Creates an ingredient that wraps another ingredient to also check for matching components.static Ingredient
difference
(Ingredient base, Ingredient subtracted) Creates an ingredient that matches if its base ingredient matches, and its subtracted ingredient does not match.
-
Method Details
-
all
Creates an ingredient that matches when its sub-ingredients all match.The JSON format is as follows:
{ "fabric:type": "fabric:all", "ingredients": [ // sub-ingredient 1, // sub-ingredient 2, // etc... ] }
- Throws:
IllegalArgumentException
- if the array is empty
-
any
Creates an ingredient that matches when any of its sub-ingredients matches.The JSON format is as follows:
{ "fabric:type": "fabric:any", "ingredients": [ // sub-ingredient 1, // sub-ingredient 2, // etc... ] }
- Throws:
IllegalArgumentException
- if the array is empty
-
difference
Creates an ingredient that matches if its base ingredient matches, and its subtracted ingredient does not match.The JSON format is as follows:
{ "fabric:type": "fabric:difference", "base": // base ingredient, "subtracted": // subtracted ingredient }
-
components
Creates an ingredient that wraps another ingredient to also check for matching components.Use
ComponentChanges.builder()
to add or remove components. Added components are checked to match on the target stack. Removed components are checked to not exist in the target stack- Throws:
IllegalArgumentException
- ifComponentChanges.isEmpty()
is true
-
components
public static Ingredient components(Ingredient base, UnaryOperator<ComponentChanges.Builder> operator) - See Also:
-
components
Creates an ingredient that matches the passed template stack, includingItemStack.getComponentChanges()
. Note that the count of the stack is ignored.- See Also:
-