/replaceitem
In this tutorial, I will be showing you how to use the /replaceitem command along with showing some example commands.
/replaceitem block <x> <y> <z> <slot> <item> [amount]
OR /replaceitem entity <selector> <slot> <item> [amount]
The /replaceitem command is used to add items or blocks in a specific place in a specific entity or tile block (EG chest, hopper etc). It also has two different versions one for the adding it to a block, one for the entities. They both with very similarly.
First the block mode. After putting 'block' you then put in your coordinates, these can be normal ones of relative just make sure the coordinates lead to a block that has a container which can have items but inside it. Then for slot this is referring to where it should put it, eg the slot in the chest.
The best was to find what you want is by using Tab Completion but if you are using 'block' you will be wanting slot.container.0 as this is what puts it in a specific slot in the container. All the other different type of slots are for entities. The 0 is what slot, not when counting what slot you want it will be one less in the command as the first slot is 0. slot.container works on all containers, so hoppers too for example.
Then you put in the item. Your can optionally also put in amount too. If you want data tags on your replaceitem you can add it straight after item. Here is an example below.
/replaceitem block <x> <y> <z> <slot> <item> [amount]
OR /replaceitem entity <selector> <slot> <item> [amount]
The /replaceitem command is used to add items or blocks in a specific place in a specific entity or tile block (EG chest, hopper etc). It also has two different versions one for the adding it to a block, one for the entities. They both with very similarly.
First the block mode. After putting 'block' you then put in your coordinates, these can be normal ones of relative just make sure the coordinates lead to a block that has a container which can have items but inside it. Then for slot this is referring to where it should put it, eg the slot in the chest.
The best was to find what you want is by using Tab Completion but if you are using 'block' you will be wanting slot.container.0 as this is what puts it in a specific slot in the container. All the other different type of slots are for entities. The 0 is what slot, not when counting what slot you want it will be one less in the command as the first slot is 0. slot.container works on all containers, so hoppers too for example.
Then you put in the item. Your can optionally also put in amount too. If you want data tags on your replaceitem you can add it straight after item. Here is an example below.
Then we have the entity mode, it works similarly although instead of putting in coordinates you put in a selector. Then you put the slot like you do for 'block' however you will never use slot.container. Instead use tab to see all of the options but if you want something in their inventory is it slot.hotbar for their first 9 slots then slot.inventory for the rest but with entity you can also do a lot more such as amour slots, horse slots (if a horse), players enderchest slots and more!
Then put your item, amount etc like with block.
Here is some examples using entity:
/replaceitem entity @p slot.hotbar.8 minecraft:stone 64
Gives the nearest player a stack of stone.
/replaceitem entity BluePvps slot.enderchest.0 minecraft:acacia_boat 1 0
Puts an acacia boat in my first enderchest slot.
Then put your item, amount etc like with block.
Here is some examples using entity:
/replaceitem entity @p slot.hotbar.8 minecraft:stone 64
Gives the nearest player a stack of stone.
/replaceitem entity BluePvps slot.enderchest.0 minecraft:acacia_boat 1 0
Puts an acacia boat in my first enderchest slot.