top of page

Replace Item

This is a pretty simple but useful command. It allows you to replaceitem in a players inventory (among other things) and is the only way to modify player data. It must be hardcoded however you can't replaceitem in my inventory with the item someone else is holding for instance. In that case you can do /give or summon an item. Below is a link to selectors incase you don't know what they are as they always come in handy.

After typing in /replaceitem you can either type block or entity depending on which you want to modify. If you choose block then you will have to enter the three coordinates (immediate values, relative values or directional values are allowed as per usual, basically you can type in the coordinate or do ~ ~ ~1 to do a block from a position or ^ ^ ^1 or do a block from a position and rotation), if you choose entity you have to enter a selector, (hence the link above). So far you should have /replaceitem block ~ ~1 ~ or /replaceitem entity @e[type=horse]. Obviously you can change the selector and the coordinates.

​

After you specify the entity or block you need to say the slot you want to replace. The slots are armor.headarmor.chestarmor.legsarmor.feet, container.0 to container.53, enderchest.0 to enderchest.26horse.0 to 

horse.14horse.armorhorse.chesthorse.saddlehotbar.0 to hotbar.8

inventory.0 to inventory.26villager.0 to villager.7weapon.mainhand and weapon.offhand. These are fairly self explanatory, however I'm still going to clarify a few things. First for all the number ones since it starts counting at 0 the amount of slots is the highest number + 1, so far container a double chest can have 54 slots and that's why it ends on 53, this seems bizarre but 99.99% of programs start from 0. Next container is for blocks, ie chest, hopper, furnace and barrel, even though there are 54 possible container slots you can't use them unless the block supports it, ie hoppers can only use 0-4. Sometimes inventory can refer to the full 36 slots however in this case it is the 27 slots that you can access only by pressing e or opening a container or block, ie not your hotbar. Last thing, enderchest is for players not the specific block, since all enderchests have the same value and values change for players, it makes no sense being able to change just one for all players it goes against the way it works, therefore it is a modification done to players.

​

Next is the item and then following is the count. The item is simple, acacia_boat for acacia boat etc, then the count is the number of items in the stack. The item also works for nbt. Now time for some full examples. /replaceitem entity @p weapon.mainhand diamond_sword{Venomous:1s} 1/replaceitem block ~ ~-1 ~ container.53 oak_log 64

I know this might be a bit complicated for a beginner tutorial however I want to keep all the commands here (except for one subcommand of execute that is really complicated). Just practice some and if you really get stuck then just look at this tutorial, I try my best to update the resources and tutorials to make sure you guys can get the best experience possible.

​

bottom of page