Context
It’s possible for multiple recipes to have the same inputs and different outputs. We can call these “conflicting recipes.” In this case, which result is produced when placing items manually into the crafting grid is undefined (one output is chosen arbitrarily). You can still select a particular output from the recipe book to craft a particular conflicting recipe.
The bug
The bug occurs when there are conflicting recipes, the limited_crafting gamerule is turned on, one of the conflicting recipes is unlocked and the others aren’t, and the player places items manually into the crafting grid, invoking the arbitrary selection.
The expected behavior is that the unlocked recipe produces its result, since it’s the only available choice. The observed behavior is that, despite the conflicting recipes being locked, they can still be arbitrarily selected for the output. Since the player cannot use locked recipes, the grid simply shows no output, even though an unlocked output is available.
How to reproduce
Install the attached data pack. It contains this very simple recipe:
{ "type": "crafting_shapeless", "ingredients": ["#logs"], "result": "apple" }This recipe conflicts with all of the log → planks recipes that exist in the vanilla game.
Open a crafting window and manually place a log inside. It will choose one of the possible outputs (planks or apple) arbitrarily. Choose logs until you find one that outputs planks.
Now select the apple in the recipe book. It will allow you to use that same log to craft an apple instead.
Now run the following commands:
/advancement grant @p from recipes/root /recipe take @p * /recipe give @p test:test /gamerule limited_crafing trueThe apple recipe is now your only available recipe.
Manually place the log in the crafting grid again.
→ ❌ There is no output. The log still selected the planks recipe, even though it’s locked and unavailable. Since the apple recipe is the only available unlocked recipe, it’s expected for it to take priority. Note that you can still craft the log into the apple by deliberately selecting it in the recipe book, as before.
Code Analysis (19w36a)
slotChangedCraftingGrid in CraftingMenu uses getRecipeFor to find the "first" recipe that matches the provided ingredients. Then, setRecipeUsed in the RecipeHolder interface can reject this recipe because the gamerule being enabled requires it to be present in the player's recipe book. As a result, nothing appears in the results slot. The filtering out of locked recipes when the gamerule is enabled should happen sooner.
Can confirm: