Minecraft:Commands/setblock: Difference between revisions
More actions
imported>MinecraftBedrockPlayer7 mNo edit summary |
Fix template calls: add MC/ prefix |
||
| (One intermediate revision by the same user not shown) | |||
| Line 4: | Line 4: | ||
* 2 {{only|java|short=1}} | * 2 {{only|java|short=1}} | ||
* 1 {{only|bedrock|short=1}} | * 1 {{only|bedrock|short=1}} | ||
|others= | |others=Cheat only{{only|bedrock|short=1}} | ||
}} | }} | ||
Changes a [[Minecraft:block]] to another block. | Changes a [[Minecraft:block]] to another block. | ||
| Line 16: | Line 16: | ||
== Arguments == | == Arguments == | ||
{{ | {{MC/Argument|pos|block_pos|position: x y z|CommandPosition}} | ||
: Specifies the position of the block to be changed. | : Specifies the position of the block to be changed. | ||
: {{ | : {{MC/Arg desc|je=block_pos|be=CommandPosition}} | ||
{{ | {{MC/Argument|block|block_state|tileName: Block|enum}} | ||
: Specifies the new block. | : Specifies the new block. | ||
: {{ | : {{MC/Arg desc|je=block_state|be=Block}} | ||
{{ | {{MC/El|be|short=1}}: {{MC/Argument|be=1|blockStates: block states|BlockStateCommandParam}} | ||
: Specifies the | : Specifies the block states to use for the block. | ||
: {{Arg desc|be=BlockStateCommandParam}} | : {{MC/Arg desc|be=BlockStateCommandParam}} | ||
{{code|destroy{{!}}keep{{!}}replace}} and {{code|destroy{{!}}keep{{!}}replace{{!}}strict}} | {{code|destroy{{!}}keep{{!}}replace}} and {{code|destroy{{!}}keep{{!}}replace{{!}}strict}} | ||
: Specifies how to handle the block change. Must be one of: | : Specifies how to handle the block change. Must be one of: | ||
:* <code>destroy</code> — The old block | :* <code>destroy</code> — The old block drops both itself and its contents (as if destroyed by a player). Plays the appropriate block breaking noise. | ||
:* <code>keep</code> — Only [[Minecraft:air]] blocks are changed (non-air blocks are unchanged). | :* <code>keep</code> — Only [[Minecraft:air]] blocks are changed (non-air blocks are unchanged). | ||
:* <code>replace</code> — The old block drops neither itself nor any contents. Plays no sound. | :* <code>replace</code> — The old block drops neither itself nor any contents. Plays no sound. | ||
| Line 41: | Line 41: | ||
{{Result table|The command is incomplete, or any argument is not specified correctly.|unparseable|unparseable}} | {{Result table|The command is incomplete, or any argument is not specified correctly.|unparseable|unparseable}} | ||
{{Result table|The specified position is unloaded or out of the world.|fail|fail}} | {{Result table|The specified position is unloaded or out of the world.|fail|fail}} | ||
{{Result table|Trying to place block in | {{Result table|Trying to place block in debug mode.||N/A}} | ||
{{Result table|cmd=/setblock ... keep|Trying to change a non-air block.||fail}} | {{Result table|cmd=/setblock ... keep|Trying to change a non-air block.||fail}} | ||
{{Result table|cmd=/setblock ... keep<br>/setblock ... replace<br>/setblock ... strict|Trying to replace a block with an identical copy (ignoring the block entity).}} | {{Result table|cmd=/setblock ... keep<br>/setblock ... replace<br>/setblock ... strict|Trying to replace a block with an identical copy (ignoring the block entity).}} | ||
| Line 50: | Line 50: | ||
== Output == | == Output == | ||
{{Output table}} | {{MC/Output table}} | ||
{{Output table|edition=je|On fail|0|0|0}} | {{MC/Output table|edition=je|On fail|0|0|0}} | ||
{{Output table|On success|1|1|1}} | {{MC/Output table|On success|1|1|1}} | ||
{{Output table|edition=be|On fail|0}} | {{MC/Output table|edition=be|On fail|0}} | ||
{{Output table|On success|1}} | {{MC/Output table|On success|1}} | ||
{{Output table}} | {{MC/Output table}} | ||
== Examples == | == Examples == | ||
| Line 61: | Line 61: | ||
** <code>setblock ~ ~ ~ chest[facing=east]</code>{{only|java}} | ** <code>setblock ~ ~ ~ chest[facing=east]</code>{{only|java}} | ||
** <code>setblock ~ ~ ~ chest ["minecraft:cardinal_direction"="east"]</code>{{only|bedrock}} | ** <code>setblock ~ ~ ~ chest ["minecraft:cardinal_direction"="east"]</code>{{only|bedrock}} | ||
* Place a sign next to it {{ | * Place a sign next to it {{MC/In|java}} | ||
** <code>setblock ~ ~ ~-1 birch_sign{Text1:'"My chest"',Text2:'"Do not open!"'}</code> (Note the two sets of quotes around the text. They are required.) | ** <code>setblock ~ ~ ~-1 birch_sign{Text1:'"My chest"',Text2:'"Do not open!"'}</code> (Note the two sets of quotes around the text. They are required.) | ||
* Put a top quartz slab at the top of your head | * Put a top quartz slab at the top of your head | ||
| Line 70: | Line 70: | ||
=== ''Java Edition'' === | === ''Java Edition'' === | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine|java}} | |{{MC/HistoryLine|java}} | ||
|{{HistoryLine||1.7.2|dev=13w37a|Added {{ | |{{HistoryLine||1.7.2|dev=13w37a|Added {{MC/Cmd|setblock|link=none}}.}} | ||
|{{HistoryLine||1.11|dev=16w32a|Added | |{{HistoryLine||1.11|dev=16w32a|Added block state support to {{MC/Cmd|setblock|link=none}}.}} | ||
|{{HistoryLine||1.16|dev=20w06a|{{ | |{{HistoryLine||1.16|dev=20w06a|{{MC/Cd|/setblock ~ ~ ~ air destroy}} now can destroy liquids.<ref>{{bug|MC-163286|resolution=Fixed}}</ref>}} | ||
|{{HistoryLine||1.21.5|dev=25w02a|The behavior of {{ | |{{HistoryLine||1.21.5|dev=25w02a|The behavior of {{MC/Cmd|setblock}} command has changed in how it handles block entity data.|Accepts a new option: <code>strict</code>.|New syntax for commands to use the new strict option.}} | ||
}} | }} | ||
=== ''Bedrock Edition'' === | === ''Bedrock Edition'' === | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine|pocket alpha}} | |{{MC/HistoryLine|pocket alpha}} | ||
|{{HistoryLine||v0.16.0|dev=build 1|Added {{ | |{{HistoryLine||v0.16.0|dev=build 1|Added {{MC/Cmd|setblock|link=none}}.}} | ||
|{{HistoryLine|bedrock}} | |{{MC/HistoryLine|bedrock}} | ||
|{{HistoryLine||1.16.210|dev=beta 1.16.210.53|Added | |{{HistoryLine||1.16.210|dev=beta 1.16.210.53|Added block state support to {{MC/Cmd|setblock|link=none}}.}} | ||
|{{HistoryLine||1.19.70|dev=Preview 1.19.70.21|Removed <code>tileData: int</code> argument.}} | |{{MC/HistoryLine||1.19.70|dev=Preview 1.19.70.21|Removed <code>tileData: int</code> argument.}} | ||
}} | }} | ||
== See also == | == See also == | ||
* {{ | * {{MC/Cmd|data}} — modifies the data tags of a block or entity | ||
* {{ | * {{MC/Cmd|clone}} — copies blocks from one region to another | ||
* {{ | * {{MC/Cmd|fill}} — fills a region with a block | ||
== References == | == References == | ||
| Line 99: | Line 99: | ||
== Navigation == | == Navigation == | ||
{{Navbox commands}} | {{MC/Navbox commands}} | ||
de:Befehl/setblock | |||
ja:コマンド/setblock | |||
pt:Comandos/setblock | |||
ru:Команды консоли/setblock | |||
uk:Команди консолі/setblock | |||
zh:命令/setblock | |||
Latest revision as of 20:13, 9 April 2026
Template:Infobox command Changes a Minecraft:block to another block.
Syntax
- Java Edition
setblock <pos> <block> [destroy|keep|replace|strict]
- 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
Template:El: <pos>: block_pos
Template:El: position: x y z: CommandPosition
- Specifies the position of the block to be changed.
- {{#vardefine:onlyje|Template:IN,}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|block_pos}}{{#vardefine:be-arg|block_pos}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
Template:El: <block>: block_state
Template:El: tileName: Block: enum
- Specifies the new block.
- {{#vardefine:onlyje|Template:IN,}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|block_state}}{{#vardefine:be-arg|block_be}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
- REDIRECT Template:Edition
Template:Rcat: blockStates: block states: BlockStateCommandParam
- Specifies the block states to use for the block.
- {{#vardefine:onlyje|Template:IN,}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|blockstatecommandparam}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
Template:Code and Template:Code
- 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 Minecraft: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.
- If not specified, defaults to
replace.
Result
Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table
Output
{{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-table-lines|-2}}{{#vardefine:output-table-lines-now|}}{{#vardefine:command-num-now|}}{{#vardefine:command-line-now|}}{{#vardefine:commands-num|}}{{#vardefine:output-edition-num-now|}}{{#vardefine:output-edition-line-now|}}{{#vardefine:output-editions-num|}}{{#vardefine:je-outputs-dis|}}
{{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:situation-{{#var:output-table-lines}}|On fail}}{{#vardefine:output1-{{#var:output-table-lines}}|0}}{{#vardefine:output2-{{#var:output-table-lines}}|0}}{{#vardefine:output3-{{#var:output-table-lines}}|0}}{{#vardefine:command-row-{{#var:commands-num}}|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-editions-num|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-edition-{{#var:output-editions-num}}|je}}{{#vardefine:output-edition-row-{{#var:output-editions-num}}|1}} {{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:situation-{{#var:output-table-lines}}|On success}}{{#vardefine:output1-{{#var:output-table-lines}}|1}}{{#vardefine:output2-{{#var:output-table-lines}}|1}}{{#vardefine:output3-{{#var:output-table-lines}}|1}}{{#vardefine:command-row-{{#var:commands-num}}|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-edition-row-{{#var:output-editions-num}}|Expression error: Unrecognized punctuation character "{".}} {{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:situation-{{#var:output-table-lines}}|On fail}}{{#vardefine:output1-{{#var:output-table-lines}}|0}}{{#vardefine:output2-{{#var:output-table-lines}}|N/A}}{{#vardefine:output3-{{#var:output-table-lines}}|N/A}}{{#vardefine:command-row-{{#var:commands-num}}|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-editions-num|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-edition-{{#var:output-editions-num}}|be}}{{#vardefine:output-edition-row-{{#var:output-editions-num}}|1}} {{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:situation-{{#var:output-table-lines}}|On success}}{{#vardefine:output1-{{#var:output-table-lines}}|1}}{{#vardefine:output2-{{#var:output-table-lines}}|N/A}}{{#vardefine:output3-{{#var:output-table-lines}}|N/A}}{{#vardefine:command-row-{{#var:commands-num}}|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-edition-row-{{#var:output-editions-num}}|Expression error: Unrecognized punctuation character "{".}}
{{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-table-lines|-2}}{{#vardefine:output-table-lines-now|}}{{#vardefine:command-num-now|}}{{#vardefine:command-line-now|}}{{#vardefine:commands-num|}}{{#vardefine:output-edition-num-now|}}{{#vardefine:output-edition-line-now|}}{{#vardefine:output-editions-num|}}{{#vardefine:je-outputs-dis|}}
Examples
- Put a chest facing east at your feet
setblock ~ ~ ~ chest[facing=east]Template:Onlysetblock ~ ~ ~ chest ["minecraft:cardinal_direction"="east"]Template:Only
- Place a sign next to it in Template:Editions
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
setblock ~ ~2 ~ quartz_slab[type=top]Template:Onlysetblock ~ ~2 ~ quartz_slab ["minecraft:vertical_half"="top"]Template:Only
History
Java Edition
Bedrock Edition
See also
- REDIRECT Template:Command
Template:Redr — modifies the data tags of a block or entity
- REDIRECT Template:Command
Template:Redr — copies blocks from one region to another
- REDIRECT Template:Command
Template:Redr — fills a region with a block
References
<references/>
External links
de:Befehl/setblock ja:コマンド/setblock pt:Comandos/setblock ru:Команды консоли/setblock uk:Команди консолі/setblock zh:命令/setblock