NameFilteringRule

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.api.recipe.replacement.type.NameFilteringRule;

Description

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 Recipe#getId(), at the cost of some efficiency.

Implements

NameFilteringRule implements the following interfaces:

IFilteringRule,ITargetingFilter

Members

static anyOf(exactNames as string[]) as NameFilteringRule
Creates a rule that filters only recipes with the specific given names.

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

Returns: A rule carrying out what has been specified.

script.zs
// NameFilteringRule.anyOf(exactNames as string[]) as NameFilteringRule;
NameFilteringRule.anyOf(myString[]);

Parameters:

exactNames Type: string[] - The exact names to look for.

Return Type: NameFilteringRule

static containing(contents as string) as NameFilteringRule
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.

Returns: A rule carrying out exactly what has been specified.

script.zs
// NameFilteringRule.containing(contents as string) as NameFilteringRule;
NameFilteringRule.containing(myString);

Parameters:

contents Type: string - The contents to look for in the recipe's name.

Return Type: NameFilteringRule

static regex(regex as string) as NameFilteringRule
Creates a rule filtering recipes based on the given regular expression.

Returns: A rule carrying out what has been specified.

script.zs
// NameFilteringRule.regex(regex as string) as NameFilteringRule;
NameFilteringRule.regex(myString);

Parameters:

regex Type: string - The regular expression to use.

Return Type: NameFilteringRule