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
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 Summary
Modifier and TypeMethodDescriptionStream<? extends net.minecraft.world.item.crafting.Recipe<?>>castFilter(Stream<? extends net.minecraft.world.item.crafting.Recipe<?>> allRecipes) Casts the filter onto the givenStreamofRecipes.describe()Describes the actions of this filtering rule in a human-readable form, for log output.static <T> ComponentFilteringRule<T>of(IRecipeComponent<T> component) Creates a new rule that filters recipes that have the givenIRecipeComponent.static <T> ComponentFilteringRule<T>of(IRecipeComponent<T> component, Predicate<T> content, ITargetingStrategy checkStrategy) Creates a new rule that filters recipes that have the givenIRecipeComponentand whose value matches the givenPredicateaccording to the givenITargetingStrategy.static <T> ComponentFilteringRule<T>of(IRecipeComponent<T> component, T content) Creates a new rule that filters recipes that have the givenIRecipeComponentand whose value matches the givencontent.static <T> ComponentFilteringRule<T>of(IRecipeComponent<T> component, T content, ITargetingStrategy checkStrategy) Creates a new rule that filters recipes that have the givenIRecipeComponentand whose value matches the givencontentaccording to the givenITargetingStrategy.
-
Method Details
-
of
Creates a new rule that filters recipes that have the givenIRecipeComponent.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
Creates a new rule that filters recipes that have the givenIRecipeComponentand whose value matches the givencontent.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 givenIRecipeComponentand whose value matches the givencontentaccording to the givenITargetingStrategy.- 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 givenIRecipeComponentand whose value matches the givenPredicateaccording to the givenITargetingStrategy.- Type Parameters:
T- The type of object pointed to by the component.- Parameters:
component- The component to check for.content- APredicatethat 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:ITargetingFilterCasts the filter onto the givenStreamofRecipes.The filter can perform any operation required, which range from filtering, to simple mapping, to peeking as needed.
- Specified by:
castFilterin interfaceITargetingFilter- Parameters:
allRecipes- TheStreamthat needs to be filtered.- Returns:
- The mutated stream.
-
describe
Description copied from interface:IFilteringRuleDescribes the actions of this filtering rule in a human-readable form, for log output.- Specified by:
describein interfaceIFilteringRule- Returns:
- A human-readable description of this rule.
-