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 Ingredientall(Ingredient... ingredients) Creates an ingredient that matches when its sub-ingredients all match.static Ingredientany(Ingredient... ingredients) Creates an ingredient that matches when any of its sub-ingredients matches.static Ingredientdifference(Ingredient base, Ingredient subtracted) Creates an ingredient that matches if its base ingredient matches, and its subtracted ingredient does not match.static IngredientCreates an ingredient that matches the passed template stack, including NBT.static Ingredientnbt(Ingredient base, @Nullable NbtCompound nbt, boolean strict) Creates an ingredient that wraps another ingredient to also check for stack NBT.
-
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 } -
nbt
Creates an ingredient that wraps another ingredient to also check for stack NBT. This check can either be strict (the exact NBT must match) or non-strict aka. partial (the ingredient NBT must be a subset of the stack NBT).In strict mode, passing a
nullnbtis allowed, and will only match stacks withnullNBT. In partial mode, passing anullnbtis not allowed, as it would always match.See
NbtHelper.matches(net.minecraft.nbt.NbtElement, net.minecraft.nbt.NbtElement, boolean)for the non-strict matching.The JSON format is as follows:
{ "fabric:type": "fabric:nbt", "base": // base ingredient, "nbt": // NBT tag to match, either in JSON directly or a string representation (default: null), "strict": // whether to use strict matching (default: false) }- Throws:
IllegalArgumentException- ifstrictisfalseand the NBT isnull
-
nbt
Creates an ingredient that matches the passed template stack, including NBT. Note that the count of the stack is ignored.- See Also:
-