Class DefaultCustomIngredients

java.lang.Object
net.fabricmc.fabric.api.recipe.v1.ingredient.DefaultCustomIngredients

public final class DefaultCustomIngredients extends Object
Factory methods for the custom ingredients directly provided by Fabric API.
  • Method Details

    • all

      public static Ingredient all(Ingredient... ingredients)
      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

      public static Ingredient any(Ingredient... ingredients)
      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

      public static Ingredient difference(Ingredient base, Ingredient subtracted)
      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

      public static Ingredient nbt(Ingredient base, @Nullable @Nullable NbtCompound nbt, boolean strict)
      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 null nbt is allowed, and will only match stacks with null NBT. In partial mode, passing a null nbt is 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 - if strict is false and the NBT is null
    • nbt

      public static Ingredient nbt(ItemStack stack, boolean strict)
      Creates an ingredient that matches the passed template stack, including NBT. Note that the count of the stack is ignored.
      See Also: