Minecraft Wiki
Advertisement

Changes a block to another block.

Syntax[]

  • Java Edition
setblock <pos> <block> [destroy|keep|replace]
  • Bedrock Edition
setblock <position: x y z> <tileName: Block> <blockStates: block states> [destroy|keep|replace]
setblock <position: x y z> <tileName: Block> [destroy|keep|replace]

Arguments[]

JE<pos>: block_pos
BE: position: x y z: CommandPosition

Specifies the position of the block to be changed.
In Java Edition, must be a block position composed of <x>, <y> and <z>, each of which must be an integer or a tilde and caret notation. In Bedrock Edition, must be a three-dimensional coordinates composed of <x>, <y> and <z>, each of which must be a floating-point number or tilde and caret notation.

JE<block>: block_state
BE: tileName: Block: enum

Specifies the new block.
In Java Edition, must be in the format of block_id[block_states]{data_tags}(does not accept block tags), in which block states and data tags can be omitted when they are not needed. In Bedrock Edition, must be a block id.

BE: blockStates: block states: BlockStateCommandParam

Specifies the block states to use for the block.
Must be a blockstate argument as ["<state1>":<value1>,"<state2>":<value2>,...]. For example: ["old_leaf_type":"birch","persistent_bit":true].

destroy|keep|replace

Specifies how to handle the block change. Must be one of:
  • destroy — The old block drops both itself and its contents (as if destroyed by a player). Plays the appropriate block breaking noise.
  • keep — Only air blocks are changed (non-air blocks are unchanged).
  • replace — The old block drops neither itself nor any contents. Plays no sound.
If not specified, defaults to replace.

Result[]

CommandTriggerJava EditionBedrock Edition
anythe arguments are not specified correctly Unparseable Unparseable
specified position is unloaded or out of the world Failed Failed
try to place block in Debug mode N/A
/setblock ... keeptry to change a non-air block Failed
/setblock ... keep
/setblock ... replace
try to replace a block with an identical copy (ignoring the block entity)
try to replace some kinds of redstone components with an unstable block (e.g. replacing one of two adjacent standing redstone torches with a TNT block)[1] Successful
anyOtherwiseSuccessful

Output[]

CommandEditionSituationSuccess Count/execute store success .../execute store result ...
anyJava EditionOn fail000
On success111
Bedrock EditionOn fail0N/AN/A
On success1N/AN/A

Examples[]

  • Put a chest facing east at your feet
  • Place a sign next to it in Java Edition
    • setblock ~ ~ ~-1 birch_sign{Text1:'"My chest"',Text2:'"Do not open!"'} (Note the two sets of quotes around the text. They are required.)
  • Put a top quartz slab at the top of your head

See also[]

  • /data — modifies the data tags of a block or entity
  • /clone — copies blocks from one region to another
  • /fill — fills a region with a block

History[]

Java Edition
1.7.213w37aAdded /setblock.
1.1116w32aAdded block state support to /setblock.
1.1620w06a/setblock ~ ~ ~ air destroy now can destroy liquids.[2]
Pocket Edition Alpha
v0.16.0build 1Added /setblock.
Bedrock Edition
1.16.210beta 1.16.210.53Added block state support to /setblock.
1.19.70beta 1.19.70.21Removed tileData: int argument.

References[]

  1. MC-255198
  2. MC-163286 — resolved as "Fixed".
Advertisement