This bug appears only in creative mode.
If you setup a repeating command block, let it replace an item in your inventory with /item replace hotbar.0 with netherite_sword and spam shift + left click in your inventory on it three times, the item will disappear, but it is still there in your nbt data.
When you replace the slot with a sword a weird effect will appear. If you try to break a block it will make a break sound and particles but it will be replaced instantly by the server because you cant break blocks with a sword. (In singleplayer the server of the singleplayer world)
Linked issues
duplicates 1
Attachments
Comments 3
Can confirm in 21w40a. Here are some extra details regarding this problem.
The Bug:
The /item command can create "ghost items" that the client can't see.
Steps to Reproduce:
In creative mode, place a command block and enter the following command:
/item replace entity @p hotbar.0 with netherite_sword
Press left shift and left click on the item while the inventory UI is open 3 times in rapid succession.
The item will disappear but still be stored in your nbt data.
Try to break a block and watch closely.
Observed Behavior:
The block is broken but immediately replaced by server because you cannot break blocks with a sword in creative mode. The client sees no sword but it is in your nbt data.
Expected Behavior:
The client would be able to see the sword and would not be able to break the blocks.
MC-238022 seemed to fix this but it has shown up again.
This duplicates MC-239935
Looks like a reoccurrence of MC-219018