Skip to content
WikilyWIKILY
All games23 Wikis · pick your game
Commands and cheatsAll commands

Switch game

23 Wikis · pick your game
Block States and Predicates

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.

Details

Block syntaxid[state=value,state=value]{data}. The minecraft: part may be left out. Spaces inside the brackets are allowed.
StatesEach state can be set once. States that are left out keep the default value of the block.
Unknown statesA state or value the block does not have is refused, for example minecraft:stone[facing=east].
Block dataData in { } after the block sets what the block holds, such as the items in a chest or the text on a sign.
Placing commandsThe /setblock and /fill commands take one exact block. Tags are refused with "Tags aren't allowed here; only actual blocks are".
Block testsUsed by /execute if block, /fill ... replace and /clone ... filtered. They take a block id or a tag starting with #.
Testing statesOnly the states you list are compared. With a tag, a block that does not have a listed state does not match.
Testing dataOnly the values you list are compared, and the block must hold data at all.

Ways to write a block

idThe 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}]}

Block tests

idThat block in any state/execute if block ~ ~-1 ~ minecraft:grass_block run say on grass
#tagAny 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

Commands that use block tests

execute if blockRuns the rest only if the block matches/execute if block ~ ~-1 ~ #minecraft:logs run say on a log
execute unless blockRuns the rest only if the block does not match/execute unless block ~ ~ ~ minecraft:air run say solid
fill ... replaceReplaces only the matching blocks in the area/fill ~-5 ~ ~-5 ~5 ~ ~5 minecraft:air replace #minecraft:leaves
clone ... filteredCopies only the matching blocks/clone 0 64 0 10 70 10 20 64 0 filtered #minecraft:wool move

Examples

/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:dirt

Turns 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:stone

Copies only the stone blocks of the area to the new spot.

/execute if block ~ ~ ~ #minecraft:stairs[facing=east] run say facing east

Says the text if you stand in any stairs block that faces east.

Join the creator communityThe people who build the Minecraft Java Edition wiki are on our Discord. Ask questions or suggest pages.Join Discord (opens Discord in a new tab)