Class CTShapelessRecipeHandler
- All Implemented Interfaces:
IRecipeHandler<CTShapelessRecipe>
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.blamejared.crafttweaker.api.recipe.handler.IRecipeHandler
IRecipeHandler.For -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecompose(IRecipeManager<? super CTShapelessRecipe> manager, net.minecraft.core.RegistryAccess registryAccess, CTShapelessRecipe recipe) Decomposes a recipe from its complete form into anIDecomposedRecipe.<U extends net.minecraft.world.item.crafting.Recipe<?>>
booleandoesConflict(IRecipeManager<? super CTShapelessRecipe> manager, CTShapelessRecipe firstRecipe, U secondRecipe) Checks if the two recipes conflict with each other.dumpToCommandString(IRecipeManager<? super CTShapelessRecipe> manager, net.minecraft.core.RegistryAccess registryAccess, net.minecraft.world.item.crafting.RecipeHolder<CTShapelessRecipe> holder) Creates a String representation of a validaddRecipe(or alternative) call for the given subclass ofRecipe.recompose(IRecipeManager<? super CTShapelessRecipe> manager, net.minecraft.core.RegistryAccess registryAccess, IDecomposedRecipe recipe) Reconstructs a complete recipe from its decomposed form.
-
Constructor Details
-
CTShapelessRecipeHandler
public CTShapelessRecipeHandler()
-
-
Method Details
-
dumpToCommandString
public String dumpToCommandString(IRecipeManager<? super CTShapelessRecipe> manager, net.minecraft.core.RegistryAccess registryAccess, net.minecraft.world.item.crafting.RecipeHolder<CTShapelessRecipe> holder) 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<CTShapelessRecipe>- Parameters:
manager- The recipe manager responsible for this kind of recipes.registryAccess- Access to registries to get the output of recipes.holder- The recipe that is currently being dumped.- Returns:
- A String representing a
addRecipe(or similar) call.
-
doesConflict
public <U extends net.minecraft.world.item.crafting.Recipe<?>> boolean doesConflict(IRecipeManager<? super CTShapelessRecipe> manager, CTShapelessRecipe 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<CTShapelessRecipe>- 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.
-
decompose
public Optional<IDecomposedRecipe> decompose(IRecipeManager<? super CTShapelessRecipe> manager, net.minecraft.core.RegistryAccess registryAccess, CTShapelessRecipe recipe) Description copied from interface:IRecipeHandlerDecomposes a recipe from its complete form into anIDecomposedRecipe.The decomposition needs to be complete, meaning that any meaningful part of the recipe should be present in the returned decomposed recipe. The only exception is the name, as decomposed recipes only track
IRecipeComponents, and names aren't one.It is allowed for an implementation to specify that the given recipe cannot be properly decomposed. Examples of this occurrence might be recipes whose behavior is completely determined by code, such as map cloning in vanilla. In this context, it is allowed to return
Optional.empty().It is mandatory for a recipe handler to produce a decomposed recipe that can then be converted back into its complete form in
IRecipeHandler.recompose(IRecipeManager, RegistryAccess, IDecomposedRecipe). In other words, if the return value of this method isn't empty, thenrecompose(manager, name, decompose(manager, recipe).get())must not return an empty optional.- Specified by:
decomposein interfaceIRecipeHandler<CTShapelessRecipe>- Parameters:
manager- The recipe manager responsible for this kind of recipes.registryAccess- Access to registries to get the output of recipes.recipe- The recipe that should be decomposed.- Returns:
- An
Optionalwrapping decomposed recipe, or an empty one if need be as specified above.
-
recompose
public Optional<CTShapelessRecipe> recompose(IRecipeManager<? super CTShapelessRecipe> manager, net.minecraft.core.RegistryAccess registryAccess, IDecomposedRecipe recipe) Description copied from interface:IRecipeHandlerReconstructs a complete recipe from its decomposed form.The recomposition should be as complete as possible, making sure that all
IRecipeComponents that are necessary to properly rebuild the recipe are present in the givenIDecomposedRecipe. If the recipe presents unknown components, i.e. components that this handler doesn't know how to convert, the handler is allowed to throw an exception as detailed in the following paragraphs.It is allowed for an implementation to return
Optional.empty()in case the recomposition fails for any reason, or if no decomposed recipe can be used to rebuild a recipe in its complete form, e.g. for map cloning in vanilla.It is mandatory for a recipe handler that knows how to decompose a recipe to also know how to recompose it. In other words, if
IRecipeHandler.decompose(IRecipeManager, RegistryAccess, Recipe)returns a non-emptyOptional, thenrecompose(manager, name, decompose(manager, recipe).get())must not return an empty optional nor throw an exception.- Specified by:
recomposein interfaceIRecipeHandler<CTShapelessRecipe>- Parameters:
manager- The recipe manager responsible for this kind of recipes.registryAccess- Access to registries.recipe- TheIDecomposedRecipethat should be recomposed back into a complete form.- Returns:
- An
Optionalwrapping the complete form of the recipe, or an empty one if need be as specified above.
-