Class CTShapelessRecipeHandler
- All Implemented Interfaces:
IRecipeHandler<CTShapelessRecipeBase>
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.blamejared.crafttweaker.api.recipe.handler.IRecipeHandler
IRecipeHandler.For, IRecipeHandler.ReplacementNotSupportedException -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<U extends net.minecraft.world.item.crafting.Recipe<?>>
booleandoesConflict(IRecipeManager manager, CTShapelessRecipeBase firstRecipe, U secondRecipe) Checks if the two recipes conflict with each other.dumpToCommandString(IRecipeManager manager, CTShapelessRecipeBase recipe) Creates a String representation of a validaddRecipe(or alternative) call for the given subclass ofRecipe.Optional<Function<net.minecraft.resources.ResourceLocation,CTShapelessRecipeBase>> replaceIngredients(IRecipeManager manager, CTShapelessRecipeBase recipe, List<IReplacementRule> rules) Handles the replacement of ingredients according to the given set ofIReplacementRules for the given subclass ofRecipe.
-
Constructor Details
-
CTShapelessRecipeHandler
public CTShapelessRecipeHandler()
-
-
Method Details
-
dumpToCommandString
Description copied from interface:IRecipeHandlerCreates a String representation of a validaddRecipe(or alternative) call for the given subclass ofRecipe.Recipe dumps are triggered by the
/ct recipesor/ct recipes handcommands.All newlines added to either the start or the end of the string will be automatically trimmed.
- Specified by:
dumpToCommandStringin interfaceIRecipeHandler<CTShapelessRecipeBase>- Parameters:
manager- The recipe manager responsible for this kind of recipes.recipe- The recipe that is currently being dumped.- Returns:
- A String representing a
addRecipe(or similar) call.
-
replaceIngredients
public Optional<Function<net.minecraft.resources.ResourceLocation,CTShapelessRecipeBase>> replaceIngredients(IRecipeManager manager, CTShapelessRecipeBase recipe, List<IReplacementRule> rules) Description copied from interface:IRecipeHandlerHandles the replacement of ingredients according to the given set ofIReplacementRules for the given subclass ofRecipe.This method should try to apply all of the applicable rules to the recipe. If one of the rules fails to apply, an error message should be generated via
CraftTweakerAPI.LOGGER. Incomplete application of the replacement rules may or may not apply depending on the specific implementation: no specific contracts are enforced by this method.If a particular recipe handler does not support replacement, a
IRecipeHandler.ReplacementNotSupportedExceptionshould be raised, along with a helpful error message. A recipe handler must be consistent, meaning that given the same recipe class, the behavior should be consistent: either an exception gets thrown or the replacement gets carried out.- Specified by:
replaceIngredientsin interfaceIRecipeHandler<CTShapelessRecipeBase>- Parameters:
manager- The recipe manager responsible for this kind of recipes.recipe- The recipe whose ingredients should be replaced.rules- A series ofIReplacementRules in the order they should be applied. Implementations are nevertheless allowed to reorder these rules as they see fit. Refer to the implementation specifications for more details.- Returns:
- An
Optionalcontaining a function that creates the replaced recipe, if any replacements have been carried out. If no replacement rule affected the current recipe, the return value should beOptional.empty(). The parameter of the function will be the new ID of the recipe that should be used, as determined by the method caller: the name may correspond to the old one or be a completely new one, implementations are not allowed to make any assumptions on the value of this parameter. It is customary, though not required, that the value returned by the wrapped function is a completely different object fromrecipe(i.e.recipe != result.get().apply(recipe.getId())).
-
doesConflict
public <U extends net.minecraft.world.item.crafting.Recipe<?>> boolean doesConflict(IRecipeManager manager, CTShapelessRecipeBase firstRecipe, U secondRecipe) Description copied from interface:IRecipeHandlerChecks if the two recipes conflict with each other.In this case, a conflict is defined as the two recipes being made in the exact same way (e.g. with the same shape and the same ingredients if the two recipes are shaped crafting table ones).
Conflicts are also considered symmetrical in this implementation, which means that if
firstRecipeconflicts withsecondRecipe, the opposite is also true.- Specified by:
doesConflictin interfaceIRecipeHandler<CTShapelessRecipeBase>- Type Parameters:
U- The type ofsecondRecipe.- Parameters:
manager- The recipe manager responsible for this kind of recipes.firstRecipe- The recipe which should be checked for conflict.secondRecipe- The other recipe whichfirstRecipeshould be checked against. The recipe may or may not be of the same type offirstRecipe. See the API note section for more details.- Returns:
- Whether the
firstRecipeconflicts withsecondRecipeor not.
-