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

Switch game

23 Wikis · pick your game
/setblock

Command

/setblock

Places a block at a position, replacing whatever is there.

Syntax

/setblock <pos> <block> [(destroy|keep|replace|strict)]

Arguments

ArgumentKind of valueWhat to type
<pos>Block positionThe position of the block to change, as three coordinates. ~ is relative to where the command runs and ^ is relative to the direction faced.
<block>BlockThe block to place: its id, optionally with block states in square brackets and block data in curly braces.

Details

Permission level2: operators, worlds with cheats on, command blocks and functions
Works inSingleplayer with cheats enabled, multiplayer servers, command blocks and functions. Needs permission level 2 (gamemasters): operators, players in a world with cheats enabled, command blocks and functions.
ResultReports "Changed the block at X, Y, Z". The number /execute store saves is 1.
replace (default)Swaps the old block for the new one. The old block drops nothing. This is what happens when no mode is written.
destroyBreaks the old block first, as if it had been mined, so it drops its items and shows the breaking effect. Then the new block is placed.
keepPlaces the block only if the position currently holds Air. Otherwise the command fails with "Could not set the block".
strictPlaces the block exactly as written, without it adjusting its shape to the blocks around it and without updating neighboring blocks.
Nothing changedIf the position already holds exactly that block, the command fails with "Could not set the block".
Position limitsThe position must be in a loaded chunk ("That position is not loaded") and inside the world's build height ("That position is out of this world!").
Block states and dataBlock states go in square brackets right after the id, for example minecraft:oak_stairs[facing=east,half=top]. States that are not written keep their default value, and in every mode except strict the block still adjusts to its neighbors. Block tags (ids starting with #) are not allowed.

Examples

/setblock ~ ~ ~ minecraft:stone

Places Stone at your position.

/setblock ~ ~-1 ~ minecraft:diamond_block replace

Replaces the block under your feet with a Block of Diamond.

/setblock 10 64 10 minecraft:oak_stairs[facing=east]

Places Oak Stairs facing east at the coordinates 10, 64, 10.

/setblock ~ ~1 ~ minecraft:air destroy

Breaks the block one above your position so that it drops its items.

/setblock ~ ~ ~ minecraft:torch keep

Places a Torch at your position only if there is Air.

/setblock ~ ~2 ~ minecraft:redstone_lamp[lit=true] strict

Places a lit Redstone Lamp two blocks above you without any block updates.

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)