Updated:
Put a diamond helmet on the nearest player
| Version | Command |
|---|---|
| Java 1.17 and later | /item replace entity @p armor.head with minecraft:diamond_helmet |
| Java 1.16 and earlier | /replaceitem entity @p armor.head minecraft:diamond_helmet |
| Bedrock Edition | /replaceitem entity @p slot.armor.head 0 diamond_helmet |
Java replaced /replaceitem with /item in 1.17. Bedrock still uses /replaceitem and needs a slot number after the slot name (0 for armor slots).
Slot names
| Slot | Java | Bedrock |
|---|---|---|
| Head, chest, legs, feet | armor.head, armor.chest, armor.legs, armor.feet | slot.armor.head 0 etc. |
| Main hand | weapon.mainhand | slot.weapon.mainhand 0 |
| Off hand | weapon.offhand | slot.weapon.offhand 0 |
| Hotbar | hotbar.0–hotbar.8 | slot.hotbar 0–8 |
| Inventory | inventory.0–inventory.26 | slot.inventory 0–26 |
| Ender chest | enderchest.0–enderchest.26 | slot.enderchest 0–26 |
Blocks as hats (Java)
/item replace entity @p armor.head with minecraft:glass
In Java Edition any item can go in the head slot. Blocks such as pumpkins, glass or colored wool are drawn on the player's head, which is handy for costumes and team markers.
Equip a mob
/item replace entity @e[type=minecraft:zombie,limit=1,sort=nearest] weapon.mainhand with minecraft:diamond_sword
This equips a mob that already exists. To spawn a mob with gear, use summon with equipment (1.21.5 and later) or HandItems/ArmorItems (1.21.4 and earlier).
Count and enchantments
/item replace entity @p hotbar.0 with minecraft:golden_apple 16
/item replace entity @p armor.feet with minecraft:diamond_boots[enchantments={feather_falling:4}]
The count goes after the item. The enchantment format above is for 1.21.5 and later; on 1.20.5–1.21.4 write [enchantments={levels:{feather_falling:4}}].
Copy an item from another slot
/item replace entity @s armor.head from entity @s weapon.mainhand
With from instead of with, Java copies the item that is already in another slot, including its name and enchantments. This puts a copy of what you are holding on your head. The source can also be a block: from block 100 64 100 container.0.
Clear a slot
/item replace entity @p armor.head with minecraft:air
Putting air in a slot empties it. The old item is deleted, so be careful with valuable gear.
Put an item in a chest slot
/item replace block 100 64 100 container.0 with minecraft:diamond 64
Use block and coordinates instead of entity. container.0 is the top-left slot.
Common problems
- Unknown command (Java): use
/replaceitemon 1.16 and earlier and/item replaceon 1.17 and later. - Error on Bedrock: add the slot number, for example
slot.armor.head 0. - No enchantment: check that the enchantment format matches your version.
Check your command
The Command Error Doctor checks common syntax mistakes in your browser.