Minecraft – Place items in specific slots

minecraft-commandsminecraft-java-edition

I'm trying to place items in certain slots in a players inventory and I know you can testfor an item in a specific slot:

/testfor @a[r=10] {Inventory[{Slot:103b,id:"minecraft:leather_helmet"}]} This is actually a command I used in 1.8

Instead of the testfor to test for the item in a slot, place the item in a slot, using a command like the give command to place the item in the specific slot:

/give @a[r=10] {Inventory:[{Slot:103b,id:"minecraft:leather_helmet"}]}

Can I do this in Minecraft 1.9?

Best Answer

It is possible, using replaceitem:

/replaceitem entity @a[r=10] slot.armor.head minecraft:leather_helmet 1 0 {}

I’ve tested this, and it seems to work. If you encounter any problems, please comment and I will look into it further. Source: Minecraft Wiki

PS. You can change it to an inventory slot with slot.inventory.(0-26). For other places, see the Minecraft Wiki