Class ReplacementHandlerHelper
java.lang.Object
com.blamejared.crafttweaker.api.recipe.handler.helper.ReplacementHandlerHelper
Set of helper functions that can replace ingredients according to the given
IReplacementRules.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends net.minecraft.world.item.crafting.Recipe<?>,U>
Optional<Function<net.minecraft.resources.ResourceLocation,T>> replaceIngredientArray(U[] originalIngredients, Class<U> ingredientClass, T recipe, List<IReplacementRule> rules, Function<U[], Function<net.minecraft.resources.ResourceLocation, T>> factory) Replaces the given array of ingredients of typeingredientClassaccording to the given set of rules.static <T extends net.minecraft.world.item.crafting.Recipe<?>,U>
Optional<Function<net.minecraft.resources.ResourceLocation,T>> replaceIngredientList(List<U> originalIngredients, Class<U> ingredientClass, T recipe, List<IReplacementRule> rules, Function<List<U>, Function<net.minecraft.resources.ResourceLocation, T>> factory) Replaces the givenListof ingredients of typeingredientClassaccording to the given set of rules.static <T extends net.minecraft.world.item.crafting.Recipe<?>,U>
Optional<Function<net.minecraft.resources.ResourceLocation,T>> replaceNonNullIngredientList(net.minecraft.core.NonNullList<U> originalIngredients, Class<U> ingredientClass, T recipe, List<IReplacementRule> rules, Function<net.minecraft.core.NonNullList<U>, Function<net.minecraft.resources.ResourceLocation, T>> factory) Replaces the givenNonNullListof ingredients of typeingredientClassaccording to the given set of rules.
-
Method Details
-
replaceNonNullIngredientList
public static <T extends net.minecraft.world.item.crafting.Recipe<?>,U> Optional<Function<net.minecraft.resources.ResourceLocation,T>> replaceNonNullIngredientList(net.minecraft.core.NonNullList<U> originalIngredients, Class<U> ingredientClass, T recipe, List<IReplacementRule> rules, Function<net.minecraft.core.NonNullList<U>, Function<net.minecraft.resources.ResourceLocation, T>> factory) Replaces the givenNonNullListof ingredients of typeingredientClassaccording to the given set of rules.This acts as the
NonNullListequivalent ofreplaceIngredientList(List, Class, Recipe, List, Function), in case the recipe constructor explicitly requires aNonNullListto be passed as a parameter.- Type Parameters:
T- The type of the recipe whose ingredients are currently undergoing replacement.U- The type of the ingredient that is currently being replaced. No restrictions are placed on the type of the ingredient.- Parameters:
originalIngredients- The originalNonNullListof ingredients that will be replaced; this should match the list of ingredients in the recipe.ingredientClass- The type of the ingredient that should be replaced. Its value may or may not correspond to the actual ingredient's class, although it must be one of its superclass (in other words, it is not necessary foringredientClass == originalIngredients[i].getClass()for anyibetween0andoriginalIngredients.size(); on the other hand,ingredientClass.isAssignableFrom(originalIngredients[i].getClass())must hold true for everyiin the same range).recipe- The recipe whose ingredients are currently undergoing replacement.rules- The list ofIReplacementRules that need to be applied to the recipe.factory- AFunctionthat accepts aNonNullListof ingredients of typeUas a first parameter and returns aFunctionthat can create the recipe given an ID in the form of aResourceLocation(it effectively is a factory for a recipe factory).- Returns:
- An
Optionalholding aFunctionthat is able to create a new recipe with the replaced ingredient list when given an ID in the form of aResourceLocation, if any replacements have been carried out on one or more of its ingredients;Optional.empty()otherwise.
-
replaceIngredientList
public static <T extends net.minecraft.world.item.crafting.Recipe<?>,U> Optional<Function<net.minecraft.resources.ResourceLocation,T>> replaceIngredientList(List<U> originalIngredients, Class<U> ingredientClass, T recipe, List<IReplacementRule> rules, Function<List<U>, Function<net.minecraft.resources.ResourceLocation, T>> factory) Replaces the givenListof ingredients of typeingredientClassaccording to the given set of rules.If the recipe requires a
NonNullListas a parameter, it is possible to use the more specialized versionreplaceNonNullIngredientList(NonNullList, Class, Recipe, List, Function).- Type Parameters:
T- The type of the recipe whose ingredients are currently undergoing replacement.U- The type of the ingredient that is currently being replaced. No restrictions are placed on the type of the ingredient.- Parameters:
originalIngredients- The originalListof ingredients that will be replaced; this should match the list of ingredients in the recipe.ingredientClass- The type of the ingredient that should be replaced. Its value may or may not correspond to the actual ingredient's class, although it must be one of its superclass (in other words, it is not necessary foringredientClass == originalIngredients[i].getClass()for anyibetween0andoriginalIngredients.size(); on the other hand,ingredientClass.isAssignableFrom(originalIngredients[i].getClass())must hold true for everyiin the same range).recipe- The recipe whose ingredients are currently undergoing replacement.rules- The list ofIReplacementRules that need to be applied to the recipe.factory- AFunctionthat accepts aListof ingredients of typeUas a first parameter and returns aFunctionthat can create the recipe given an ID in the form of aResourceLocation(it effectively is a factory for a recipe factory).- Returns:
- An
Optionalholding aFunctionthat is able to create a new recipe with the replaced ingredient list when given an ID in the form of aResourceLocation, if any replacements have been carried out on one or more of its ingredients;Optional.empty()otherwise.
-
replaceIngredientArray
public static <T extends net.minecraft.world.item.crafting.Recipe<?>,U> Optional<Function<net.minecraft.resources.ResourceLocation,T>> replaceIngredientArray(U[] originalIngredients, Class<U> ingredientClass, T recipe, List<IReplacementRule> rules, Function<U[], Function<net.minecraft.resources.ResourceLocation, T>> factory) Replaces the given array of ingredients of typeingredientClassaccording to the given set of rules.- Type Parameters:
T- The type of the recipe whose ingredients are currently undergoing replacement.U- The type of the ingredient that is currently being replaced. No restrictions are placed on the type of the ingredient.- Parameters:
originalIngredients- The original array of ingredients that will be replaced; this should match the array of ingredients in the recipe.ingredientClass- The type of the ingredient that should be replaced. Its value may or may not correspond to the actual ingredient's class, although it must be one of its superclass (in other words, it is not necessary foringredientClass == originalIngredients[i].getClass()for anyibetween0andoriginalIngredients.size(); on the other hand,ingredientClass.isAssignableFrom(originalIngredients[i].getClass())must hold true for everyiin the same range).recipe- The recipe whose ingredients are currently undergoing replacement.rules- The list ofIReplacementRules that need to be applied to the recipe.factory- AFunctionthat accepts an array of ingredients of typeUas a first parameter and returns aFunctionthat can create the recipe given an ID in the form of aResourceLocation(it effectively is a factory for a recipe factory).- Returns:
- An
Optionalholding aFunctionthat is able to create a new recipe with the replaced ingredient list when given an ID in the form of aResourceLocation, if any replacements have been carried out on one or more of its ingredients;Optional.empty()otherwise.
-