Recipe registry

Hey everyone

With the recipe registry now implemented in API 7, I was wondering how to view the ingredients of a specific recipe?
I can get all recipes by using Sponge.getRegistry().getCraftingRecipeRegistry().getRecipes() (or the equivalent for smelting recipes) and then iterating over that collection, but a single recipe object of type CraftingRecipe only tells me if an inventory isValid, and what the output of the recipe is.
The ingredients have to be specified when building the recipe with the builder, so I was expecting them to be available after the recipe is registered, but that doesn’t seem to be the case - or am I missing something obvious here?

Cheers & Thanks for the help
Val

I wish I could help, but I can’t even find the documentation for ShapedCraftingRecipe.Builder.

what even is SalamiOS

1 Like

@Faithcaio since worked mostly for a while on this, would you like to elaborate?

My guess is that when you get the collection of recipes, you’d have to check whether the CraftingRecipe is an instance of ShapedCraftingRecipe or ShapelessCraftingRecipe and then cast it to one of those. You can then do ShapedCraftingRecipe#getIngredient(int x, int y) or ShapelessCraftingRecipe#getIngredientPredicates().
Note: this is not tested and just a guess from looking through the crafting api.

Thats correct.
Is it possible to implement CraftingRecipe yourself without using Ingredients at all and register that.
Also a few vanilla Recipes like e.g. Fireworks do not use Ingredients.

Ohhh I didn’t realise the Shaped and Shapeless one’s had the ingredients on them, thank you very much!
And I guess there is not much I can do in case someone implements their own recipe, but at least I got the normal cases covered like this, thank you very much :slight_smile: