Interface ICustomIngredient

All Known Implementing Classes:
BlockTagIngredient, CompoundIngredient, CustomDisplayIngredient, DataComponentIngredient, DifferenceIngredient, IntersectionIngredient

public interface ICustomIngredient
Interface that modders can implement to create new behaviors for Ingredients.

This is not directly implemented on vanilla Ingredients, but conversions are possible:

Implementations of this interface must implement Object.equals(java.lang.Object) and Object.hashCode() to ensure that the ingredient also supports them.

  • Method Details

    • test

      boolean test(ItemStack stack)
      Checks if a stack matches this ingredient. The stack must not be modified in any way.
      Parameters:
      stack - the stack to test
      Returns:
      true if the stack matches this ingredient, false otherwise
    • items

      Stream<Holder<Item>> items()
      Returns the list of items that this ingredient accepts.

      The following guidelines should be followed for good compatibility:

      • At least one item must be returned for the ingredient not to be considered empty. Empty ingredients invalidate the entire recipe.
      • The ingredient should return all Items it might possible accept. This allows mods that inspect the ingredient to figure out which stacks it might accept.
      • Returned items might not always be accepted by the ingredient, as an ingredient might still perform additional NBT-dependent tests.
      • An exception is ingredients that are simple, for which testing a stack is equivalent to testing if the item is in the returned list.

      Note: no caching needs to be done by the implementation, this is already handled by the ingredient itself.

      Returns:
      the list of items that this ingredient accepts
    • isSimple

      boolean isSimple()
      Returns whether this ingredient always requires direct stack testing.
      Returns:
      true if this ingredient ignores NBT data when matching stacks, false otherwise
      See Also:
    • getType

      IngredientType<?> getType()
      Returns the type of this ingredient.

      The type must be registered to NeoForgeRegistries.INGREDIENT_TYPES.

      Returns:
      the type of this ingredient
    • display

      default SlotDisplay display()
      Returns the display for this ingredient.

      The display is synced to the client, and is also used to retrieve the ItemStacks that are shown to the client.

    • toVanilla

      @NonExtendable default Ingredient toVanilla()
      Returns a new Ingredient behaving as defined by this custom ingredient.
      Returns:
      a new Ingredient behaving as defined by this custom ingredient