/

/setblock

op 2World

/setblock places one block at one position. The interesting part is what rides along with it: block states such as facing or half in square brackets, and block-entity NBT in braces for containers, signs and spawners.

Commandready
21
/setblock ~ ~ ~ stone
Press C to copy
x
y
z

~ ~ ~whole blocks

~ is relative to where the command runs from

This block has no block states.

Block entity NBTchests, signs, spawners, command blocks
Presets
Empty — this argument will be left off.
optional

Destroy drops the old block as an item

Examples

  • Stone below you
    /setblock ~ ~-1 ~ stone
  • Facing chest
    /setblock ~ ~ ~ chest[facing=north]
  • Command block with a command
    /setblock ~ ~1 ~ repeating_command_block{Command:"say hi",auto:1b}

Common questions about /setblock

How do I place a chest that already has items in it?

Add block-entity NBT with an Items list. From 1.20.5 each entry uses the component format: {Items:[{Slot:0b,id:"minecraft:diamond",count:64}]}.

What is the difference between replace, keep and destroy?

replace overwrites whatever is there. keep only places into air. destroy breaks the old block first, so it drops as an item.

How do I know which block states a block has?

Every block declares its own set, and the game rejects any state the block does not have. A stair has facing, half, shape and waterlogged; plain stone has none at all.