Interface RecipeChoice

All Superinterfaces:
Cloneable, Predicate<ItemStack>
All Known Subinterfaces:
RecipeChoice.ItemTypeChoice, RecipeChoice.PredicateChoice
All Known Implementing Classes:
RecipeChoice.ExactChoice, RecipeChoice.MaterialChoice

@NullMarked @NonExtendable public interface RecipeChoice extends Predicate<ItemStack>, Cloneable
Represents a potential item match within a recipe. All choices within a recipe must be satisfied for it to be craftable. Choices must never be null or air. This class is not legal for implementation by plugins!
  • Method Details

    • empty

      static RecipeChoice empty()
      An "empty" recipe choice. Only valid as a recipe choice in specific places. Check the javadocs of a method before using it to be sure it's valid for that recipe and ingredient type.
      Returns:
      the empty recipe choice
    • itemType

      @Contract(pure=true, value="_, _ -> new") static RecipeChoice.ItemTypeChoice itemType(ItemType itemType, ItemType... itemTypes)
      Creates a new recipe choice based on a collection of ItemTypes.
      Parameters:
      itemType - the first item type to match
      itemTypes - other item types to match.
      Returns:
      a new recipe choice
    • itemType

      @Contract(pure=true, value="_ -> new") static RecipeChoice.ItemTypeChoice itemType(RegistryKeySet<ItemType> itemTypes)
      Creates a new recipe choice based on a RegistryKeySet of item types. Can either be created via RegistrySet.keySet(RegistryKey, TypedKey[]) or obtained from Registry.getTag(TagKey).
      Parameters:
      itemTypes - the item types to match
      Returns:
      a new recipe choice
    • exactChoice

      @Contract(value="_, _ -> new", pure=true) static RecipeChoice.ExactChoice exactChoice(ItemStack first, ItemStack... others)
      Creates a choice that will be valid only if one of the stacks is exactly matched (aside from stack size).
      Parameters:
      first - an ItemStack to match against. Cannot be null or empty/air.
      others - additional ItemStacks to match against.
      Returns:
      a new ExactChoice
    • exactChoice

      @Contract(value="_ -> new", pure=true) static RecipeChoice.ExactChoice exactChoice(List<ItemStack> stacks)
      Creates a choice that will be valid only if one of the stacks is exactly matched (aside from stack size).
      Parameters:
      stacks - the ItemStacks to match against. Cannot be empty or contain empty/air stacks.
      Returns:
      a new ExactChoice
    • predicateChoice

      @Contract(value="_, _ -> new", pure=true) static RecipeChoice.PredicateChoice predicateChoice(Predicate<? super ItemStack> stackPredicate, ItemStack exampleStack)
      Creates a recipe choice that will be valid only if an item matches the given predicate.

      Note: Mutating the ItemStack within the predicate is not supported.

      Parameters:
      stackPredicate - the predicate to match against.
      exampleStack - an example ItemStack to be shown in the recipe book. Cannot be empty or air.
      Returns:
      a new PredicateChoice
    • getItemStack

      @Deprecated(since="1.13.1") ItemStack getItemStack()
      Deprecated.
      for compatibility only
      Gets a single item stack representative of this stack choice.
      Returns:
      a single representative item
    • clone

      RecipeChoice clone()
    • test

      boolean test(ItemStack itemStack)
      Specified by:
      test in interface Predicate<ItemStack>
    • validate

      @Internal default RecipeChoice validate(boolean allowEmptyRecipes)