There compatibility tags such as forge:crops and it would be very useful to be able to set a default SpoilRecipe for a category like that, while also being able to override the category with a higher-priority recipe (for example make potatoes spoil slower than other crops).
Creating two recipes like this is already possible, however I have noticed that the order that runtime stores and returns the recipes is arbitrary and not affected by ordering in scripts, so it is likely that the category recipe will always be returned even when there is a lower-level recipe that you would prefer to be used.
This PR adds an optional priority attribute to the SpoilRecipe, and changes the lookup to retrieve all relevant recipes and and select the highest-priority recipe.
Test plan
After creating a new world, under the datapacks folder create test/pack.meta
Summary
There compatibility tags such as
forge:crops
and it would be very useful to be able to set a default SpoilRecipe for a category like that, while also being able to override the category with a higher-priority recipe (for example make potatoes spoil slower than other crops).Creating two recipes like this is already possible, however I have noticed that the order that runtime stores and returns the recipes is arbitrary and not affected by ordering in scripts, so it is likely that the category recipe will always be returned even when there is a lower-level recipe that you would prefer to be used.
This PR adds an optional
priority
attribute to the SpoilRecipe, and changes the lookup to retrieve all relevant recipes and and select the highest-priority recipe.Test plan
After creating a new world, under the
datapacks
folder createtest/pack.meta
then create
test/data/testpack/recipes/test_recipe.json
then in the
scripts
folder createtest_script.zs
Then, play with the priority values and verify that the highest-priority recipe is always used.