
Command reference
Block States and Predicates
Blocks in commands are written as an id, optional states in square brackets and optional block data in braces. Commands that test blocks also accept block tags.
| Block syntax | id[state=value,state=value]{data}. The minecraft: part may be left out. Spaces inside the brackets are allowed. |
| States | Each state can be set once. States that are left out keep the default value of the block. |
| Unknown states | A state or value the block does not have is refused, for example minecraft:stone[facing=east]. |
| Block data | Data in { } after the block sets what the block holds, such as the items in a chest or the text on a sign. |
| Placing commands | The /setblock and /fill commands take one exact block. Tags are refused with "Tags aren't allowed here; only actual blocks are". |
| Block tests | Used by /execute if block, /fill ... replace and /clone ... filtered. They take a block id or a tag starting with #. |
| Testing states | Only the states you list are compared. With a tag, a block that does not have a listed state does not match. |
| Testing data | Only the values you list are compared, and the block must hold data at all. |
| id | The block in its default state | /setblock 10 64 10 minecraft:stone |
| id[state=value] | The block with chosen states | /setblock ~ ~ ~ minecraft:oak_stairs[facing=east,half=top] |
| id{data} | The block with block data | /setblock ~ ~ ~ minecraft:chest{Items:[{Slot:0b,id:"minecraft:diamond",count:1}]} |
| id[state=value]{data} | States and data together | /setblock ~ ~ ~ minecraft:chest[facing=north]{Items:[{Slot:0b,id:"minecraft:diamond",count:1}]} |
| id | That block in any state | /execute if block ~ ~-1 ~ minecraft:grass_block run say on grass |
| #tag | Any block in the tag | /execute if block ~ ~-1 ~ #minecraft:logs run say on a log |
| id[state=value] | That block with the listed states | /execute if block ~ ~ ~ minecraft:oak_stairs[half=top] run say upside down |
| #tag[state=value] | Any block in the tag with the listed states | /execute if block ~ ~ ~ #minecraft:stairs[facing=east] run say facing east |
| id{data} | That block holding the listed data | /execute if block ~ ~ ~ minecraft:chest{Items:[{id:"minecraft:diamond"}]} run say has diamonds |
| #tag{data} | Any block in the tag holding the listed data | /execute if block ~ ~ ~ #minecraft:signs{is_waxed:1b} run say waxed |
| execute if block | Runs the rest only if the block matches | /execute if block ~ ~-1 ~ #minecraft:logs run say on a log |
| execute unless block | Runs the rest only if the block does not match | /execute unless block ~ ~ ~ minecraft:air run say solid |
| fill ... replace | Replaces only the matching blocks in the area | /fill ~-5 ~ ~-5 ~5 ~ ~5 minecraft:air replace #minecraft:leaves |
| clone ... filtered | Copies only the matching blocks | /clone 0 64 0 10 70 10 20 64 0 filtered #minecraft:wool move |
/setblock ~ ~ ~ minecraft:oak_stairs[facing=east,half=top]Places upside-down oak stairs facing east.
/setblock ~ ~ ~ minecraft:chest[facing=north]{Items:[{Slot:0b,id:"minecraft:diamond",count:1}]}Places a chest facing north with one diamond in its first slot.
/fill ~-5 ~ ~-5 ~5 ~ ~5 minecraft:stone replace minecraft:dirtTurns dirt into stone in an 11 by 11 square at your height.
/fill ~-5 ~ ~-5 ~5 ~ ~5 minecraft:oak_slab[type=top] replace minecraft:oak_slab[type=bottom]Turns bottom oak slabs into top slabs in the area.
/clone 0 64 0 10 70 10 20 64 0 filtered minecraft:stoneCopies only the stone blocks of the area to the new spot.
/execute if block ~ ~ ~ #minecraft:stairs[facing=east] run say facing eastSays the text if you stand in any stairs block that faces east.

