From Minecraft Wiki
Jump to: navigation, search


First introduced

1.7.2 (13w37a)
PE Alpha 0.16.0 (PE Alpha 0.16.0 build 1)

Changes a block to another block.

  • Java Edition
setblock <x> <y> <z> <block> [dataValue|state] [oldBlockHandling] [dataTag]
setblock <pos> <block> [<mode>][upcoming 1.13]
  • Pocket Edition
setblock <position: x y z> <tileName: string> [tileData: int] [oldBlockHandling: string]
x y z (PE: position: x y z)
Specifies the position of the block to be changed. May use tilde notation to specify a position relative to the command's execution.
block (PE: tileName: string)
Specifies the new block. Must be a block id (for example, minecraft:stone or stone).
dataValue (PE: tileData: int) (optional)[until 1.13]
Specifies additional data to further describe the new block. Must be between 0 and 15 (inclusive). If not specified, defaults to 0.
state (optional)[Java Edition only][until 1.13]
Specifies additional data to further describe the new block. Must be a valid state for the block specified in block.
oldBlockHandling (PE: oldBlockHandling: string or mode[upcoming 1.13]) (optional)
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 will be changed (non-air blocks will be "kept").
  • replace — The old block drops neither itself nor any contents. Plays no sound.
If not specified, defaults to replace.
dataTag (optional)[Java Edition only][until 1.13]
Specifies the data tag for the new block. Must be a compound NBT tag (for example, {CustomName:Fred}).
Fails if the arguments are not specified correctly, if tried to change a non-air block in keep mode, tried to replace a block with an identical copy in keep or replace mode, or if the coordinates are in an unloaded chunk.
On success, changes the block at the specified position.
See also
  • /blockdata — modifies the data tags of a block
  • /clone — copies blocks from one region to another
  • /fill — fills a region with a block

Promotional Content