Function reward removing the item an advancement detected creates a ghost item
The bug
When a function reward of an advancement that triggers on inventory_changed removes the item, the advancement detected, the item is left behind has a ghost item on the client.
Presumably, that happens because of when in the tick the advancement triggers. It is likely, that the advancement triggers before the item is being send to the client, and then the inventory updates are send in the wrong order.
How to reproduce
- Download the example datapack: Advancement Ghost Item Bug.zip

- Put the datapack into your world's datapack directory
- Give yourself a vine
- Make sure you are in survival mode (in creative the ghost item will behave like a regular item)
→
You now have a ghost vine in your inventory
Linked Issues
is duplicated by6
Created Issue:
Function reward removing the item an advancement detected creates a ghost item
The Bug
When a function reward of an advancement that triggers on inventory_changed removes the item, the advancement detected, the item is left behind has a ghost item on the client.
How to reproduce
- Download the example datapack: Advancement Ghost Item Bug.zip
- Give yourself a vine
- Make sure you are in survival mode (in creative the ghost item will behave like a regular item)
→You now have a ghost vine in your inventory
The Bug
When a function reward of an advancement that triggers on inventory_changed removes the item, the advancement detected, the item is left behind has a ghost item on the client.
Presumably, that happens because of when in the tick the advancement triggers. It is likely, that the advancement triggers before the item is being send to the client, and then the inventory updates are send in the wrong order.How to reproduce
- Download the example datapack: Advancement Ghost Item Bug.zip
- Give yourself a vine
- Make sure you are in survival mode (in creative the ghost item will behave like a regular item)
→You now have a ghost vine in your inventory
The Bug
When a function reward of an advancement that triggers on inventory_changed removes the item, the advancement detected, the item is left behind has a ghost item on the client.
Presumably, that happens because of when in the tick the advancement triggers. It is likely, that the advancement triggers before the item is being send to the client, and then the inventory updates are send in the wrong order.How to reproduce
- Download the example datapack: Advancement Ghost Item Bug.zip
- Put the datapack into your world's datapack directory
- Give yourself a vine
- Make sure you are in survival mode (in creative the ghost item will behave like a regular item)
→You now have a ghost vine in your inventory
relates to
is duplicated by
The
BugWhen a function reward of an advancement that triggers on inventory_changed removes the item, the advancement detected, the item is left behind has a ghost item on the client.
Presumably, that happens because of when in the tick the advancement triggers. It is likely, that the advancement triggers before the item is being send to the client, and then the inventory updates are send in the wrong order.How to reproduce
- Download the example datapack: Advancement Ghost Item Bug.zip
- Put the datapack into your world's datapack directory
- Give yourself a vine
- Make sure you are in survival mode (in creative the ghost item will behave like a regular item)
→You now have a ghost vine in your inventory
The bug
When a function reward of an advancement that triggers on inventory_changed removes the item, the advancement detected, the item is left behind has a ghost item on the client.
Presumably, that happens because of when in the tick the advancement triggers. It is likely, that the advancement triggers before the item is being send to the client, and then the inventory updates are send in the wrong order.How to reproduce
- Download the example datapack: Advancement Ghost Item Bug.zip
- Put the datapack into your world's datapack directory
- Give yourself a vine
- Make sure you are in survival mode (in creative the ghost item will behave like a regular item)
→You now have a ghost vine in your inventory
is duplicated by
is duplicated by
is duplicated by
Thank you for your report!
We're tracking this issue in MC-187281, so this ticket is being resolved and linked as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – ✍️ Feedback and Suggestions – 📖 Game Wiki
– I am a bot. This action was performed automagically! Please report any issues in Discord or Reddit
Thank you for your report!
We're tracking this issue in MC-187281, so this ticket is being resolved and linked as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – ✍️ Feedback and Suggestions – 📖 Game Wiki
– I am a bot. This action was performed automagically! Please report any issues in Discord or Reddit
Thank you for your report!
We're tracking this issue in MC-187281, so this ticket is being resolved and linked as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – ✍️ Feedback and Suggestions – 📖 Game Wiki
– I am a bot. This action was performed automatically! Please report any issues in Discord or Reddit
Oh, I made a mistake. The 1 at the end of the command is read as an item modifier. This makes this command fail, of course. If the 1 is removed it works as it should. So nevermind, this issue isn't one and can be closed.
There is an Issue still here, however. I mentioned the commands being executed as an advancement reward. This changes things. There is a bug here, need to rewrite that report
and this is in some way a duplicate of MC-187281
This Issue can be closed, thank you.
Thank you for your report!
We're tracking this issue in MC-187281, so this ticket is being resolved and linked as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki
– I am a bot. This action was performed automatically! Please report any issues on Discord or Reddit
The ghost item is created by the /clear execution that is triggered by placing the item back into the inventory; see MC-187281.
I think this is the same as
MC-118841, which was dubiously merged intoMC-29318Yeah, at the time that seemed to be the likely cause, I guess.
Oh actually, you found a different one. I only saw
MC-135205, which was resolved as dupe ofMC-41113, when I searched.Maybe this is related to
MC-146043?Confirmed in 1.16 Release Candidate 1.
Confirmed in 1.16.4
Confirmed in 20w51a
I experience the same Issue using the same advancement trigger and a reward in which the item gets switched from offhand to mainhand with the new /item command.
item_bug.zip
It seems this happens with anything in the reward block that changes the players inventory. I haven't found a workaround.
{ "criteria": { "crafting_table": { "trigger": "minecraft:inventory_changed", "conditions": { "items": [ { "item": "minecraft:crafting_table" } ] } } }, "requirements": [ [ "crafting_table" ] ], "rewards": { "loot": [ "test:diamond" ] } }{ "type": "minecraft:advancement_reward", "pools": [ { "rolls": 1, "entries": [ { "type": "minecraft:item", "name": "minecraft:diamond" } ] } ] }When running /give @s vine in survival with the datapack enabled the item is instantly removed without leaving behind a ghost item. Has anyone else been able to reproduce this in 1.18?
I've been testing this in 1.18.2 and I was not able to replicate this behavior. The vine disappears and there is no ghost item.
HOWEVER, I have still noticed some interesting behavior when using rewarded functions and moving items within the inventory.
My testing setup:
1. Place a shulker box in a the world at 0 -61 0 and replace the player's first inventory slot with an item (in my example it's a diamond).
2. Create an inventory_changed advancement which rewards a function which copies the player's hotbar into a shulker box:
3. Now move the diamond in the first hotbar slot to the second hotbar slot (open inventory GUI, hover over second slot, and press 1 button).
This should cause the diamond to move to the second slot and the "inventory changed" message displays in chat.
However, when you open the shulker box there will be two diamonds in the inventory spots corresponding to where the item started and where it ended. This turns out to be an intermediate inventory state that is normally not visible to the player.
If we repeat the same steps previously but this time add a command to our function file which removes the inventory_change advancement:
you will notice the "inventory changed" message prints twice and the shulker inventory should accurately reflect the player's inventory.
This demonstrates that minecraft handles inventory changes in two steps:
1. The game copies the item from the initial slot to the destination slot while holding any item in the destination slot in some storage space. This change is reflected in the first inventory_changed advancement granted.
2. The game then takes the item in storage space and places it into the initial slot. This change is reflected in the second inventory_changed advancement granted.
The inventory_changed advancement returns the function so fast it is able to resolve both of these steps in-game. I am unsure whether this behavior is intended by the devs or not, hence why I am leaving this as a comment.
If you wish to avoid this behavior, one can simply remove the function reward from the advancement and run a command as every player with the advancement in a tick function:
execute as @a[advancements={[advancement]=true}] run [function]I'd suggest making a report for that; it doesn't seem intended for that to happen.