Invalid leaf directive! `since`

Handles the replacement of IRecipeComponent<T>s for Recipe<C>s.

Due to the expensive nature of the replacing process, once the replacer is created, it is not immediately executed like with other calls, but rather the user needs to determine when the execution should occur with the this#execute() method. It is suggested to chain as many replacements as possible in a single invocation to avoid too big performance hits.

A replacer instance can be created through this#create() and various filters specified through this#filter(IFilteringRule). Note that all filters are positive, meaning that they specify the set of recipes the replacer should target. Replacements can then be specified with the various replace methods. Refer to their documentation for more information.

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

ZenScript
Copy
import crafttweaker.api.recipe.replacement.Replacer;

Name: create

Creates a new replacer instance.

Returns: A new replacer instance.
Return Type: Replacer

ZenScript
Copy
// Replacer.create() as Replacer

Replacer.create();

Name: execute

Executes the replacer, carrying out all replacements determined up until now.

After this method is called, the replacer will be exhausted, meaning that a new replacer will be needed to carry out additional replacements.

ZenScript
Copy
// Replacer.execute()

Replacer.create().execute();

Name: filter

Specifies an IFilteringRule that the replacer must follow.

Note that the rules are positive, meaning that they specify the recipes that the replacer should act upon.

You can specify as many filters as you want. Note that they will all be applied at the same time. For example, filtering for mod "crafttweaker" and with recipe type <recipetype:minecraft:crafting> will indicate that only recipes added by you to the crafting table will be targeted.

A replacer cannot be modified after execution.

Returns: This for chaining.
Return Type: Replacer

ZenScript
Copy
Replacer.filter(rule as IFilteringRule) as Replacer
参数类型描述
参数
rule
类型
IFilteringRule
描述
The rule that should be applied.

Name: replace

Specifies a replacement that should be carried out by this replacer.

In particular, the given IRecipeComponent<T> will be used to query the recipe and alter exactly what has been specified. The first element is then used to determine what needs to be replaced and the second element indicates what the element should be replaced by. In other words, any instance of toReplace will be replaced by with.

The replacement strategy used will be default one, so the components will be checked directly, without examining the various elements in detail. For example, a IIngredient like <item:minecraft:dirt> | <item:minecraft:diamond> will be considered like a single entity. Attempting to replace only dirt, for example, won't work.

A replacer cannot be modified after execution.

Returns: This replacer for chaining.
Return Type: Replacer

ZenScript
Copy
Replacer.replace<T : Object>(component as IRecipeComponent<T>, toReplace as T, with as T) as Replacer
参数类型描述
参数
component
类型
IRecipeComponent<T>
描述
The IRecipeComponent<T> indicating what should be targeted.
参数
toReplace
类型
T
描述
The oracle representing the element that needs to be replaced.
参数
with
类型
T
描述
The element which will replace the oracle as needed.
参数
T
类型
Object
描述
The type of elements targeted by the component.

Name: replace

Specifies a replacement that should be carried out by this replacer.

In particular, the given IRecipeComponent<T> will be used to query the recipe and alter exactly what has been specified. The predicate will be used to determine whether a specific target needs to be replaced, whereas the function will determine what the element should be replaced by. In other words, any instance that makes toReplace return true will be replaced by the result of the execution of with.

The strategy used can be determined by you, allowing for example to consider each element in detail instead of directly. For example, a IIngredient like <item:minecraft:dirt> | <item:minecraft:diamond> can also be considered as two separate ingredients and thus replacing only dirt can happen.

A replacer cannot be modified after execution.

Returns: This replacer for chaining.
Return Type: Replacer

ZenScript
Copy
Replacer.replace<T : Object>(component as IRecipeComponent<T>, strategy as ITargetingStrategy, toReplace as Predicate<T>, with as Function<T,T>) as Replacer
参数类型描述
参数
component
类型
IRecipeComponent<T>
描述
The IRecipeComponent<T> indicating what should be targeted.
参数
strategy
类型
ITargetingStrategy
描述
The ITargetingStrategy that will be used to target components.
参数
toReplace
类型
Predicate<T>
描述
A Predicate<T> determining whether a specific element should be replaced or not. The
argument given to it is the target that might have to be replaced.
参数
with
类型
Function<T,T>
描述
A Function<T,R> that determines the replacement for elements that toReplace deems
necessary of replacement. The argument given to the function is the target that needs to be
replaced. The function can then determine freely how the replacement should be carried out.
参数
T
类型
Object
描述
The type of elements targeted by the component.

Name: replace

Specifies a replacement that should be carried out by this replacer.

In particular, the given IRecipeComponent<T> will be used to query the recipe and alter exactly what has been specified. The first element is then used to determine what needs to be replaced and the second element will determine what the element should be replaced by. In other words, any instance of toReplace will be replaced by the result of the execution of with.

The strategy used can be determined by you, allowing for example to consider each element in detail instead of directly. For example, a IIngredient like <item:minecraft:dirt> | <item:minecraft:diamond> can also be considered as two separate ingredients and thus replacing only dirt can happen.

A replacer cannot be modified after execution.

Returns: This replacer for chaining.
Return Type: Replacer

ZenScript
Copy
Replacer.replace<T : Object>(component as IRecipeComponent<T>, strategy as ITargetingStrategy, toReplace as T, with as Function<T,T>) as Replacer
参数类型描述
参数
component
类型
IRecipeComponent<T>
描述
The IRecipeComponent<T> indicating what should be targeted.
参数
strategy
类型
ITargetingStrategy
描述
The ITargetingStrategy that will be used to target components.
参数
toReplace
类型
T
描述
The oracle representing the element that needs to be replaced.
参数
with
类型
Function<T,T>
描述
A Function<T,R> that determines the replacement for toReplace. The argument given to
the function is the target that needs to be replaced. The function can then determine freely how
the replacement should be carried out.
参数
T
类型
Object
描述
The type of elements targeted by the component.

Name: replace

Specifies a replacement that should be carried out by this replacer.

In particular, the given IRecipeComponent<T> will be used to query the recipe and alter exactly what has been specified. The first element is then used to determine what needs to be replaced and the second element indicates what the element should be replaced by. In other words, any instance of toReplace will be replaced by with.

The strategy used can be determined by you, allowing for example to consider each element in detail instead of directly. For example, a IIngredient like <item:minecraft:dirt> | <item:minecraft:diamond> can also be considered as two separate ingredients and thus replacing only dirt can happen.

A replacer cannot be modified after execution.

Returns: This replacer for chaining.
Return Type: Replacer

ZenScript
Copy
Replacer.replace<T : Object>(component as IRecipeComponent<T>, strategy as ITargetingStrategy, toReplace as T, with as T) as Replacer
参数类型描述
参数
component
类型
IRecipeComponent<T>
描述
The IRecipeComponent<T> indicating what should be targeted.
参数
strategy
类型
ITargetingStrategy
描述
The ITargetingStrategy that will be used to target components.
参数
toReplace
类型
T
描述
The oracle representing the element that needs to be replaced.
参数
with
类型
T
描述
The element which will replace the oracle as needed.
参数
T
类型
Object
描述
The type of elements targeted by the component.