Replacer
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.
Description
Handles the replacement ofIRecipeComponent
s for net.minecraft.world.item.crafting.Recipe
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 #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 #create()
and various filters specified through #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.
Members
After this method is called, the replacer will be exhausted, meaning that a new replacer will be needed to carry out additional replacements.
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.
Parameters:
Return Type:
Replacer
In particular, the given IRecipeComponent
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 com.blamejared.crafttweaker.api.ingredient.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.
Parameters:
component: IRecipeComponent<T>
Type: IRecipeComponent<T>
- The IRecipeComponent
indicating what should be targeted. toReplace: T
Type: T
- The oracle representing the element that needs to be replaced. with: T
Type: T
- The element which will replace the oracle as needed.
Return Type:
Replacer
In particular, the given IRecipeComponent
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 com.blamejared.crafttweaker.api.ingredient.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.
Parameters:
component: IRecipeComponent<T>
Type: IRecipeComponent<T>
- The IRecipeComponent
indicating what should be targeted. strategy: ITargetingStrategy
Type: ITargetingStrategy
- The ITargetingStrategy
that will be used to target components. toReplace: T
Type: T
- The oracle representing the element that needs to be replaced. with: T
Type: T
- The element which will replace the oracle as needed.
Return Type:
Replacer
In particular, the given IRecipeComponent
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 com.blamejared.crafttweaker.api.ingredient.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.
Parameters:
component: IRecipeComponent<T>
Type: IRecipeComponent<T>
- The IRecipeComponent
indicating what should be targeted. strategy: ITargetingStrategy
Type: ITargetingStrategy
- The ITargetingStrategy
that will be used to target components. toReplace: T
Type: T
- The oracle representing the element that needs to be replaced. with: function(r as T) as T
Type: function(r as T) as T
- A Function that determines the replacement for toReplace
. The argument given tothe function is the target that needs to be replaced. The function can then determine freely how
the replacement should be carried out.
Return Type:
Replacer
In particular, the given IRecipeComponent
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 com.blamejared.crafttweaker.api.ingredient.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.
Parameters:
component: IRecipeComponent<T>
Type: IRecipeComponent<T>
- The IRecipeComponent
indicating what should be targeted. strategy: ITargetingStrategy
Type: ITargetingStrategy
- The ITargetingStrategy
that will be used to target components. toReplace: function(t as T) as bool
Type: function(t as T) as bool
- A Predicate determining whether a specific element should be replaced or not. Theargument given to it is the target that might have to be replaced.
with: function(r as T) as T
Type: function(r as T) as T
- A Function that determines the replacement for elements that toReplace
deemsnecessary 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.
Return Type:
Replacer