Updated:
Get a command block
Command blocks are not in the creative inventory. Use /give @s minecraft:command_block, in creative mode with operator rights. On a server, also set enable-command-block=true in server.properties. Other command-only items are listed in the hidden items guide.
Start with one block
Place an Impulse block set to Needs Redstone, type say test and put a button on it. If "test" appears in chat, the block, the redstone input and the command path all work.
The three block types
- Impulse (orange): runs once each time it is powered.
- Repeat (purple): runs every game tick while active, 20 times a second.
- Chain (green): runs after the block that points into it.
Get a command working in Impulse first, then move it to Repeat or a chain. The command block types guide goes deeper.
Why it works in chat but not in the block
Relative coordinates change their anchor. In chat, ~ ~ ~ is your position. In a command block it is the block's position.
/summon minecraft:zombie ~ ~1 ~
In a command block, this zombie appears on top of the block, not above you. To use a player's position, wrap it in /execute at:
/execute at @p run summon minecraft:zombie ~ ~1 ~
See the execute guide for as and at.
What each setting means
| Setting | Meaning | Use it for |
|---|---|---|
| Needs Redstone | Runs only while it gets a redstone signal | Buttons and levers |
| Always Active | Runs without a signal | Repeat blocks that keep watching, and every chain block after the first |
| Unconditional | Runs whatever happened before | Normal steps |
| Conditional | Runs only if the block behind it succeeded | Give the item only if the payment worked |
Set chain blocks after the first one to Always Active. If they stay on Needs Redstone, they do nothing even when their turn comes.
Building a chain
Place chain blocks so each arrow points into the next block. A conditional block needs the block behind it to succeed, so if the chain stops halfway, make the blocks unconditional for a moment and check the order with say.
Debug in this order
- Run the command in chat.
- Put it in an Impulse block and run it once.
- Check that relative coordinates point where you expect.
- Narrow the selector before switching to Repeat.
- Add chain blocks one at a time and test after each.
Keep Repeat blocks light
A Repeat block runs 20 times a second, so a wide @e can slow the game. Filter by type and distance, such as @e[type=minecraft:zombie,distance=..20] (see target selectors), and wire a lever so you can switch it off. Never put destructive commands like /kill or /fill into a Repeat block until you have tested them once.
Common questions
- I cannot open or edit the block. You must be in creative mode with operator rights. The command block not working guide has a full checklist.
- Chat fills up with command output. Run
/gamerule minecraft:command_block_output falseon Java 1.21.11 and later,/gamerule commandBlockOutput falseon Java 1.21.10 and earlier, or/gamerule commandblockoutput falseon Bedrock.
Check your command
The Command Error Doctor checks common syntax mistakes in your browser.