Commands/setblock

Changes a block to another block.


 * Syntax


 * Java Edition
 * where  is the name of the block state, and   is that block state's value (see Block states). Multiple block states and their values can be included, separated by a comma. (For example,  )
 * where  is the name of the block state, and   is that block state's value (see Block states). Multiple block states and their values can be included, separated by a comma. (For example,  )
 * where  is the name of the block state, and   is that block state's value (see Block states). Multiple block states and their values can be included, separated by a comma. (For example,  )
 * where  is the name of the block state, and   is that block state's value (see Block states). Multiple block states and their values can be included, separated by a comma. (For example,  )
 * where  is the name of the block state, and   is that block state's value (see Block states). Multiple block states and their values can be included, separated by a comma. (For example,  )


 * Bedrock Edition


 * Arguments


 * x y z (BE: 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 (BE: tileName: Block)
 * Specifies the new block. Must be a block id (for example,  or  ).


 * tileData: int (optional)
 * Specifies additional data to further describe the new block. Must be between 0 and 15 (inclusive). If not specified, defaults to.


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


 * Result


 * 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


 * — modifies the data tags of a block or entity
 * — copies blocks from one region to another
 * — fills a region with a block

History
Befehl/setblock 命令/setblock