Minecraft – How to use /setblock and what are the possible options

minecraft-java-edition

The new Minecraft command /setblock is very exciting but poorly documented.

How do I use the command? For example to set a yellow stained glass at a certain location? To create a chest full of enchanted swords?

Best Answer

Here's the structure of the /setblock command:

/setblock x y z block data method [dataTag]

xyz are the coordinates of the block
block is the TileID of the block (includes id:0 now!)
data is the block data (i.e. 5:1 spruce wood)
method is one of three things: keep, replace, or delete

  • keep spawns the block at the coordinates.
  • replace replaces the block at the coordinates with the block ID.
  • delete removes the block at the coordinates and then spawns the new one in

dataTag (optional) is tile entity data.

From Minecraft wiki