![]() |
VOOZH | about |
/setblock| Permission level required |
|
|---|---|
| Restrictions | Cheat only[BE only] |
{
"title": "<code>/setblock</code>",
"rows": [
{
"field": "\n* 2 <sup class=\" nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Java Edition\">(link to Java Edition article, displayed as JE) only</span></i>]</sup>\n* 1 <sup class=\" nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Bedrock Edition\">(link to Bedrock Edition article, displayed as BE) only</span></i>]</sup>",
"label": "(link to Permission level article, displayed as Permission level<br>required)"
},
{
"field": "(link to Cheat article, displayed as Cheat) only<sup class=\" nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Bedrock Edition\">(link to Bedrock Edition article, displayed as BE) only</span></i>]</sup>",
"label": "(link to Commands#Restrictions article, displayed as Restrictions)"
}
],
"invimages": [],
"images": []
}
Changes a block to another block.
setblock <pos> <block> [destroy|keep|replace|strict]setblock <position: x y z> <tileName: Block> <blockStates: block states> [destroy|keep|replace]setblock <position: x y z> <tileName: Block> [destroy|keep|replace]JE: <pos>: block_pos
BE: position: x y z: CommandPosition
<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 single-precision floating-point number or tilde and caret notation.JE: <block>: block_state
BE: tileName: Block: enum
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
["<state1>"=<value1>,"<state2>"=<value2>,...]. For example: ["old_leaf_type"="birch","persistent_bit"=true].destroy|keep|replace and destroy|keep|replace|strict
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.strict — Place blocks as-is without triggering block updates and shape updates.replace.| Command | Trigger | Java Edition | Bedrock Edition |
|---|---|---|---|
| Any | The command is incomplete, or any argument is not specified correctly. | Unparseable | Unparseable |
| The specified position is unloaded or out of the world. | Failed | Failed | |
| Trying to place block in debug mode. | N/A | ||
/setblock ... keep | Trying to change a non-air block. | Failed | |
/setblock ... keep | Trying to replace a block with an identical copy (ignoring the block entity). | ||
| Trying 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 | ||
| Any | Otherwise | Successful | |
| Command | Edition | Situation | Success Count | /execute store success ... | /execute store result ... |
|---|---|---|---|---|---|
| Any | Java Edition | On fail | 0 | 0 | 0 |
| On success | 1 | 1 | 1 | ||
| Bedrock Edition | On fail | 0 | N/A | N/A | |
| On success | 1 | N/A | N/A |
setblock ~ ~ ~ chest[facing=east][Java Edition only]setblock ~ ~ ~ chest ["minecraft:cardinal_direction"="east"][Bedrock Edition only]setblock ~ ~ ~-1 birch_sign{Text1:'"My chest"',Text2:'"Do not open!"'} (Note the two sets of quotes around the text. They are required.)setblock ~ ~2 ~ quartz_slab[type=top][Java Edition only]setblock ~ ~2 ~ quartz_slab ["minecraft:vertical_half"="top"][Bedrock Edition only]| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 1.7.2 | 13w37a | Added /setblock. | |||||
| 1.11 | 16w32a | Added block state support to /setblock. | |||||
| 1.16 | 20w06a | /setblock ~ ~ ~ air destroy now can destroy liquids.[2] | |||||
| 1.21.5 | 25w02a | The behavior of / command has changed in how it handles block entity data. | |||||
Accepts a new option: strict. | |||||||
| New syntax for commands to use the new strict option. | |||||||
| Pocket Edition Alpha | |||||||
|---|---|---|---|---|---|---|---|
| v0.16.0 | build 1 | Added /setblock. | |||||
| Bedrock Edition | |||||||
| 1.16.210 | beta 1.16.210.53 | Added block state support to /setblock. | |||||
| 1.19.70 | Preview 1.19.70.21 | Removed tileData: int argument. | |||||
/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/setblock Command" – Microsoft Learn, June 17, 2024.