To use a command block, turn on cheats, run /give @s command_block in Creative mode, place the block, right-click it, type a command and give it a redstone signal. Command blocks cannot be crafted, and only operators in Creative mode can place or edit them.
Beginner Java Bedrock
What a command block is
A command block is a block that runs a command for you. It can run once when it gets power, again and again every tick, or as part of a chain. With command blocks you can build teleporters, shops, minigames, welcome messages and custom rules without mods.
How to get a command block
- Turn on cheats (Java: Allow Commands, Bedrock: Activate Cheats). On a Java server, set
enable-command-block=truein server.properties and restart. - Switch to Creative mode:
/gamemode creative. - Run
/give @s command_block. Usechain_command_blockorrepeating_command_blockfor the other two types. - Place it like any block.
Note Command blocks only run if the world allows them. The game rule is commandBlocksEnabled on Bedrock and command_blocks_work on Java 1.21.11 and newer. It is on by default.
The command block screen
Right-click the block to open it. The important parts are:
- Block type: Impulse, Chain or Repeat. See command block types explained.
- Condition: Unconditional runs every time. Conditional only runs if the block behind it worked.
- Redstone: Needs Redstone waits for a signal. Always Active (Auto on Java) runs without one.
- Command box: the command, with or without the leading slash.
- Previous Output: the last message the block produced. It is the first place to look when something fails.
- Bedrock extras: Hover Note, Delay in Ticks (20 ticks is one second) and Execute on First Tick. Java command blocks have no delay setting.
Your first command block
- Place a command block and put a stone button on top or beside it.
- Open the block and type
say Hello from a command block. - Leave it on Impulse, Unconditional and Needs Redstone, then close the screen.
- Press the button. The message appears in chat.
Now try something useful with a target selector, so it affects the player who stands near it:
give @p bread 3Watch out A command block has no name, position or body of its own. Selectors like @s do not mean the player who pressed the button. Use @p for the nearest player or build the command with execute.
Tips that save time
- Test every command in chat first. If it fails there, it will fail in the block.
- Command blocks stop when their chunk is not loaded. Keep them near spawn or in a ticking area (Bedrock:
/tickingarea, Java:/forceload). - Turn off command block spam with the command block output game rule. Its Java name changed to snake_case in 1.21.11, so use tab completion to find it.
- Label complex builds. Bedrock has Hover Note, and on Java signs next to the block do the job.
- Shorter is better: a repeat block that runs a heavy command every tick can lag a server.
Impulse, Chain and Repeat explained · 7 command block builds to copy · Command block not working? Fix it
FAQ
How do you get a command block in Minecraft?
Run /give @s command_block with cheats on. You cannot craft one, and you cannot find one in survival.
Can you use command blocks in Survival?
Yes. An operator places and sets them up in Creative mode, then switches back. They keep running, and players in Survival can trigger them with buttons and pressure plates.
Why are command blocks not working on my Java server?
Set enable-command-block=true in server.properties and restart the server. Also check that the command_blocks_work game rule has not been turned off.
Do I need the slash in a command block?
No. Both editions accept the command with or without the leading slash.
Can players break command blocks?
Only operators in Creative mode can break or edit them. In Survival the block cannot be broken by hand.
Checked by the Game Respawned editorial team against the current Java and Bedrock versions. Spotted something out of date? Tell us.