skylinerw / guides

Creative Commons Attribution 4.0 International
166 stars 29 forks source link

Programmatically modify recipes? #9

Open Chekote opened 6 years ago

Chekote commented 6 years ago

Thanks so much for the guide, it's really well documented! I do have a quick question I hope you can assist with:

I want to have config options in my mod that affect recipes. For example, change a particular recipe ingredient from Emerald to Diamond. I'm currently trying to implement this by modifying the recipe programmatically when the mod loads. This is easy to do in earlier versions that don't use the JSON files, but I can't work out how to do it when using JSON files.

Is there a way to programmatically modify these recipes?

Thanks in advance for your help!

skylinerw commented 6 years ago

Unfortunately I'm not a modder so I don't have any experience in that area. One issue is that fully data-driven recipes are only available in 1.13+, but 1.13 is still in snapshot stages so there's no deobfuscated MCP variant for it.

Looking at the CraftingManager for 1.12 MCP, it looks as though you cannot just overwrite one of the recipes in its entirety. You might be able to get a recipe from its resource location from the crafting manager, and then get the ingredients from the resulting IRecipe. I'm also not too familiar with Java, so when I say that you might be able to edit the ItemStack you get from that and it'll work, it might not work. Plus I'm not sure how/if a 1.12 server will notify the client of changes that deviate from vanilla.