I am building an adventure map using Command Blocks. I tried to detect if a player crafts an Iron Chestplate, then clear it and replace another one with nbts to armor slot.
What I expect to happened:
The Iron Chestplate removed from player's inventory, then another one with nbts appear in armor slot.
What it actually happened:
The Iron Chestplate removed from player's inventory, buy nothing appeared in armor slot.
However, the Repeating Command Block with always active which I used to detect if a player crafts an Iron Chestplate showed an output saying "[11:06:22] Test passed, count: 1" and activates Redstone Comparator. The armor bar in adventure mode appears (See attachment "Armor bar appeared with ghost Iron Chestplate.png"). If I tried to clear items, it showed a message "Removed 1 items from player Leo204_LKY" though my inventory appears to be empty.
How to reproduce:
1. Give yourself a Command Block, a Repeating Command Block, a Chain Command Block and a Redstone Comparator.
2. Place them like attachment "Command Block placement.png"
3. Set the Command Blocks:
Repeating Command Block : Always Activate, Unconditional
execute if entity @a[nbt={Inventory:[{id:"minecraft:iron_chestplate"}]
Impulse (Normal) Command Block: Needs Redstone, Unconditional
clear @p minecraft:iron_chestplate
Chain Command Block: Always Activate, Unconditional
replaceitem entity @p armor.chest minecraft:iron_chestplate
(in 1.17) item entity @p armor.chest replace minecraft:iron_chestplate
4. Give yourself 8 Iron Ingots (Or if you changed the item in the command, give exactly the amount of items to craft it), and make sure your inventory is empty except the items to craft (This one will be useful to test /clear later and not necessary).
5. Craft an Iron Chestplate using crafting table, move it to your inventory.
6. Open your inventory and check the chest armor slot.
7. Set your own gamemode to adventure or survival, and check the armor bar.
8. Run the command /clear in chat.
Description
The armor will appear if you try to damage its durability by hurting yourself. But if you replace it with another chestplate manually, it disappears forever.
This also happens when trying to replace player's offhand. However shield will not activate and block attacks.
I have tried moving an Iron Chestplate from a chest to my inventory using the same command above, the bug also happens.
However, try replacing an item to hotbar or inventory that is visible in furnance or chest's GUI, the item will appear normally.
Sorry for my bad English.
Attachments
Comments 4
May relate to MC-29318
@Marty McFly
Maybe. Though if I try to replace the item into hotbar or inventory that can be seen in chest or furnance GUI, it won't happen.
Seems that it's fixed in 21w10a
May relate to MC-87019
Also happened in 21w05b.