java.lang.Object
com.blamejared.crafttweaker.api.recipe.replacement.type.NameFilteringRule
All Implemented Interfaces:
IFilteringRule, ITargetingFilter

@ZenRegister public final class NameFilteringRule extends Object implements IFilteringRule
Filters recipes that match a specific pattern on their name.

This acts as a less specialized version of ModsFilteringRule as it allows custom matching on the entirety of a recipe's name as determined by RecipeHolder.id(), at the cost of some efficiency.

Since:
10.0.0
  • Method Details

    • anyOf

      public static NameFilteringRule anyOf(String... exactNames)
      Creates a rule that filters only recipes with the specific given names.

      The names are matched exactly, in both namespace and path.

      Parameters:
      exactNames - The exact names to look for.
      Returns:
      A rule carrying out what has been specified.
      Since:
      10.0.0
    • containing

      public static NameFilteringRule containing(String contents)
      Creates a rule filtering recipes that have the given word in their name.

      The word is not matched exactly and word boundaries aren't considered. This means that if a recipe is called "minecraft:pumpkin_pie" and the rule is set up to check "pump", that recipe will pass the check instead of failing it.

      Parameters:
      contents - The contents to look for in the recipe's name.
      Returns:
      A rule carrying out exactly what has been specified.
      Since:
      10.0.0
    • regex

      public static NameFilteringRule regex(String regex)
      Creates a rule filtering recipes based on the given regular expression.
      Parameters:
      regex - The regular expression to use.
      Returns:
      A rule carrying out what has been specified.
      Since:
      10.0.0
    • castFilter

      public Stream<net.minecraft.world.item.crafting.RecipeHolder<?>> castFilter(Stream<net.minecraft.world.item.crafting.RecipeHolder<?>> 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.