Knowledge book gives recipe before removing itself from inventory causing unexpected advancement behavior
The bug
Using a knowledge book gives the player the recipes first and then removes itself from the inventory of the player. This creates some problems if an advancement has a trigger for the gives recipes. For example trying to change the item in the slot the knowledge book was in fails because the knowledge book clears this slot afterwards.
How to reproduce
- Download the attached advancement recipe_test.json
and place it in the following directory of your world folder
data\advancements\custom
- Open the world
- Take the anvil recipe
/recipe take @s anvil
- Give yourself a knowledge book containing the anvil recipe
/give @s knowledge_book 1 0 {Recipes:[anvil]} - Switch to Survival or Adventure mode
- Right click the knowledge book
→ It prints in the chat that you have a knowledge book meaning that when the test happens the knowledge book has not been removed yet
Created Issue:
Replaceitem/give don't work with advancement recipe_unlock
(I'm french, sorry for my translation)
I would like to create remote command with knowledge book. I create a progress JSON file that a reusable function and uses a replaceitem who do not work if the knowledge book is on the same slot as the one appeal advancement.
My JSON file:{ "criteria": { "start": { "trigger": "minecraft:recipe_unlocked", "conditions": { "recipe": "anvil" } } }, "requirements": [ [ "start" ] ], "rewards": { "commands": [ "advancement revoke @s only hogwarts:animations/statuts", "recipe take @s minecraft:anvil", "replaceitem entity @s slot.hotbar.8 minecraft:knowledge_book 1 0 {Recipes:[\"minecraft:anvil\"]}", "say @s" ] } }Use:
- I have knowledge book in slot.hotbar.8
- It's used with a right click and launch the advancement and this commands
- All commands are executed except replaceitem which wants to replace the knowledge book on slot.hotbar.8
Environment
Windows 10 - Java 8u131
(I'm french, sorry for my translation)
I would like to create remote command with knowledge book. I create a progress JSON file that a reusable function and uses a replaceitem who do not work if the knowledge book is on the same slot as the one appeal advancement.
My JSON file:{ "criteria": { "start": { "trigger": "minecraft:recipe_unlocked", "conditions": { "recipe": "anvil" } } }, "requirements": [ [ "start" ] ], "rewards": { "commands": [ "advancement revoke @s only hogwarts:animations/statuts", "recipe take @s minecraft:anvil", "replaceitem entity @s slot.hotbar.8 minecraft:knowledge_book 1 0 {Recipes:[\"minecraft:anvil\"]}", "say @s" ] } }Use:
- I have knowledge book in slot.hotbar.8
- It's used with a right click and launch the advancement and this commands
- All commands are executed except replaceitem which wants to replace the knowledge book on slot.hotbar.8
Windows 10 - Java 8u131
Replaceitem/give don't work with advancement recipe_unlockKnowledge book gives recipe before removing itself from inventory causing unexpected advancement behavior
(I'm french, sorry for my translation)
I would like to create remote command with knowledge book. I create a progress JSON file that a reusable function and uses a replaceitem who do not work if the knowledge book is on the same slot as the one appeal advancement.
My JSON file:{ "criteria": { "start": { "trigger": "minecraft:recipe_unlocked", "conditions": { "recipe": "anvil" } } }, "requirements": [ [ "start" ] ], "rewards": { "commands": [ "advancement revoke @s only hogwarts:animations/statuts", "recipe take @s minecraft:anvil", "replaceitem entity @s slot.hotbar.8 minecraft:knowledge_book 1 0 {Recipes:[\"minecraft:anvil\"]}", "say @s" ] } }Use:
- I have knowledge book in slot.hotbar.8
- It's used with a right click and launch the advancement and this commands
- All commands are executed except replaceitem which wants to replace the knowledge book on slot.hotbar.8
The bug
Using a knowledge book gives the player the recipes first and then removes itself from the inventory of the player. This creates some problems if an advancement has a trigger for the gives recipes. For example trying to change the item in the slot the knowledge book was in fails because the knowledge book clears this slot afterwards.
How to reproduce
- Download the attached advancement recipe_test.json
and place it in the following directory of your world folder
data\advancements\custom- Open the world
- Take the anvil recipe
/recipe take @s anvil- Give yourself a knowledge book containing the anvil recipe
/give @s knowledge_book 1 0 {Recipes:[anvil]}- Switch to Survival or Adventure mode
- Right click the knowledge book
→ It prints in the chat that you have a knowledge book meaning that when the test happens the knowledge book has not been removed yet
Could be intended since advancement commands are executed instantaneously. This means it could be the case that right clicking the knowledge book first gives the recipes which then trigger the advancement and after that the usage method continues and removes the (new) knowledge book.
But that is only an assumption and it does not mean the knowledge book could not first remove itself from the inventory and after that give the recipes, which would probably better.
I am going to make the report more generic now, I hope you are fine with that.
Please do not mark unreleased versions as affected.
You don't have access to them yet.