Skip to content

replaceitem command in Minecraft

The replaceitem command in Minecraft allows players to easily swap out items in containers, inventories, or entities. By specifying the target and slot, players can quickly update their items without the need to manually remove and add new ones. Mastering the replaceitem command can streamline inventory management and make item manipulation more efficient in the game.

replaceitem Syntax:

Terminal window
replaceitem entity <target> slot.<slot> <item> [amount] [data] [nbt]
replaceitem block <x> <y> <z> slot.<slot> <item> [amount] [data] [nbt]

Minecraft replaceitem Options:

OptionDescription
entitySpecifies the target entity.
blockSpecifies the target block coordinates.
slotSpecifies the equipment slot to modify.
itemSpecifies the item to replace with.
amount(Optional) Sets the amount of items.
data(Optional) Sets the data value of the item.
nbt(Optional) Sets the NBT data of the item.

replaceitem Parameters:

ParameterDescription
targetSpecifies the target entity.
slotSpecifies the equipment slot to modify.
itemSpecifies the item to replace with.
amount(Optional) Sets the amount of items.
data(Optional) Sets the data value of the item.
nbt(Optional) Sets the NBT data of the item.

Give an Iron Sword to Player

Terminal window
replaceitem entity @p slot.weapon.mainhand iron_sword

This command will give the closest player an Iron Sword in their main hand slot.

Clear Player’s Offhand Slot

Terminal window
replaceitem entity @p slot.weapon.offhand air

It will clear the offhand slot for the closest player.

Equip Diamond Chestplate on Player

Terminal window
replaceitem entity @p slot.armor.chest diamond_chestplate

This command equips a Diamond Chestplate on the closest player’s chest armor slot.

Remove All Items from Player’s Inventory

Terminal window
replaceitem entity @p slot.weapon.hotbar.0 air
replaceitem entity @p slot.weapon.hotbar.1 air
replaceitem entity @p slot.weapon.hotbar.2 air
replaceitem entity @p slot.weapon.hotbar.3 air
replaceitem entity @p slot.weapon.hotbar.4 air
replaceitem entity @p slot.weapon.hotbar.5 air
replaceitem entity @p slot.weapon.hotbar.6 air
replaceitem entity @p slot.weapon.hotbar.7 air
replaceitem entity @p slot.weapon.hotbar.8 air

This sequence of commands will remove all items from the hotbar of the closest player.

Give Arrow to All Players in a Radius

Terminal window
execute as @a[distance=..10] run replaceitem entity @s slot.weapon.offhand arrow 64

It gives 64 arrows to all players within a radius of 10 blocks.

Replace Golden Pickaxe with Diamond Pickaxe in Chest

Terminal window
replaceitem block 100 64 20-45 slot.weapon.mainhand diamond_pickaxe 1

This replaces a Golden Pickaxe with a Diamond Pickaxe in a chest at coordinates (100,64,20-45).

Restore Player’s Missing Leggings

Terminal window
replaceitem entity @p slot.armor.legs diamond_leggings

This will equip Diamond Leggings to the closest player’s leggings slot.

Swap Player’s Helmet with Gold Helmet

Terminal window
replaceitem entity @p slot.armor.head gold_helmet

It swaps the current helmet of the closest player with a Gold Helmet.

How do I use replaceitem in Minecraft?

To use the replaceitem command in Minecraft, execute the following command:

Terminal window
replaceitem --option <value>

What is the syntax for the replaceitem command in Minecraft?

The syntax for the replaceitem command in Minecraft is as follows:

Terminal window
replaceitem <entity/player> <slot.armor> <inventory.enderchest> <block> <container> <slot.hotbar> <options>

How can I replace an item in a player’s inventory using the replaceitem command?

To replace an item in a player’s inventory with a new item, you can use the following command:

Terminal window
replaceitem entity @p slot.inventory.0 minecraft:diamond_sword

Can I replace an item in a specific slot of a player’s inventory using replaceitem?

Yes, you can replace an item in a specific slot of a player’s inventory by specifying the slot number in the command. Here’s an example:

Terminal window
replaceitem entity @p slot.inventory.4 minecraft:iron_shovel 1

How do I replace an item in a specific slot of a chest using the replaceitem command?

To replace an item in a specific slot of a chest, you can use the replaceitem command with the block and container parameters. For example:

Terminal window
replaceitem block 100 1 2 slot.chest.2 minecraft:golden_apple 5

Is it possible to replace an item in a specific slot of an ender chest using replaceitem?

Yes, you can replace an item in a specific slot of an ender chest by specifying the slot number in the command. Here’s an example:

Terminal window
replaceitem block 0 1 0 slot.enderchest.1 minecraft:enchanted_book 1 0 {StoredEnchantments:[{id:16s,lvl:1s}]}

How can I replace an item in a specific slot of a dispenser using the replaceitem command?

To replace an item in a specific slot of a dispenser, you can use the replaceitem command with the block and container parameters. For example:

Terminal window
replaceitem block 10 2 3 slot.dispenser.0 minecraft:arrow 64

Can the replaceitem command be used to replace armor worn by a player?

Yes, the replaceitem command can be used to replace armor worn by a player. You can specify the slot.armor parameter in the command. Here’s an example:

Terminal window
replaceitem entity @p slot.armor.chest minecraft:diamond_chestplate

Applications of the replaceitem command

  • Managing player inventories
  • Swapping items between inventory slots
  • Equipping players with specific items
  • Modifying player armor
  • Setting up custom loot tables
  • Creating custom item drops
  • Implementing custom item rewards
  • Managing item durability
  • Applying enchantments to items
  • Customizing player equipment