Minecraft – How to put colored carpet on the head

minecraft-commandsminecraft-java-edition

I was messing with command blocks today and I tried to put colored carpet on my head. I don't really know that much about command blocks and that kind of stuff. I already know /replaceitem entity @p slot.armor.head minecraft:carpet 1 0, but I want to know the command for colored carpet.

Best Answer

The replaceitem syntax for entities is:

/replaceitem entity <selector> <slot> <item> [amount] [data] [dataTag]

The carpet's colour is represented by its data value (sometimes called "damage value"). Currently you have it set to 0, which is white. You can see these values here.

For example, for lime carpet:

/replaceitem entity @p slot.armor.head minecraft:carpet 1 5