Class ComponentFilteringRule<T>

java.lang.Object
com.blamejared.crafttweaker.api.recipe.replacement.type.ComponentFilteringRule<T>
Type Parameters:
T - The type of the component that should be filtered.
All Implemented Interfaces:
IFilteringRule, ITargetingFilter

@ZenRegister public final class ComponentFilteringRule<T> extends Object implements IFilteringRule
Filters recipes that have the specified IRecipeComponent, optionally with a check on its value.

In other words, to be able to be processed by the replacer, the target recipe must have the specified IRecipeComponent. Optionally, the value of the component must match a specific value or a Predicate to match, for more custom filtering. The value of the recipe component can be checked with any ITargetingStrategy.

Since:
10.0.0
  • Method Details

    • of

      public static <T> ComponentFilteringRule<T> of(IRecipeComponent<T> component)
      Creates a new rule that filters recipes that have the given IRecipeComponent.

      The value of the component is not checked, merely its presence.

      Type Parameters:
      T - The type of the object pointed to by the component.
      Parameters:
      component - The component to check for.
      Returns:
      A rule carrying out what has been specified.
      Since:
      10.0.0
    • of

      public static <T> ComponentFilteringRule<T> of(IRecipeComponent<T> component, T content)
      Creates a new rule that filters recipes that have the given IRecipeComponent and whose value matches the given content.

      The strategy used is the default one, so components will be checked directly.

      Type Parameters:
      T - The type of the object pointed to by the component.
      Parameters:
      component - The component to check for.
      content - The oracle that represents the element to check for.
      Returns:
      A rule carrying out what has been specified.
      Since:
      10.0.0
    • of

      public static <T> ComponentFilteringRule<T> of(IRecipeComponent<T> component, T content, ITargetingStrategy checkStrategy)
      Creates a new rule that filters recipes that have the given IRecipeComponent and whose value matches the given content according to the given ITargetingStrategy.
      Type Parameters:
      T - The type of the object pointed to by the component.
      Parameters:
      component - The component to check for.
      content - The oracle that represents the element to check for.
      checkStrategy - The strategy that needs to be used to compare the component's value.
      Returns:
      A rule carrying out what has been specified.
      Since:
      10.0.0
    • of

      public static <T> ComponentFilteringRule<T> of(IRecipeComponent<T> component, Predicate<T> content, ITargetingStrategy checkStrategy)
      Creates a new rule that filters recipes that have the given IRecipeComponent and whose value matches the given Predicate according to the given ITargetingStrategy.
      Type Parameters:
      T - The type of object pointed to by the component.
      Parameters:
      component - The component to check for.
      content - A Predicate that determines whether an element is wanted or not. Its argument represents the object to check for.
      checkStrategy - The strategy that needs to be used to compare the component's value.
      Returns:
      A rule carrying out what has been specified
      Since:
      10.0.0
    • castFilter

      public Stream<? extends net.minecraft.world.item.crafting.Recipe<?>> castFilter(Stream<? extends net.minecraft.world.item.crafting.Recipe<?>> allRecipes)
      Description copied from interface: ITargetingFilter
      Casts the filter onto the given Stream of Recipes.

      The filter can perform any operation required, which range from filtering, to simple mapping, to peeking as needed.

      Specified by:
      castFilter in interface ITargetingFilter
      Parameters:
      allRecipes - The Stream that needs to be filtered.
      Returns:
      The mutated stream.
    • describe

      public String describe()
      Description copied from interface: IFilteringRule
      Describes the actions of this filtering rule in a human-readable form, for log output.
      Specified by:
      describe in interface IFilteringRule
      Returns:
      A human-readable description of this rule.