Command blocks
A command typed in chat runs once and is gone. To have it run by itself, or fire when someone steps on a plate, it has to live in a command block
Want to start from a ready-to-use example?
Open the Command Block library, choose a use case, and follow the Java or Bedrock screen one block at a time with commands ready to copy
Command BlockGetting one
Command blocks are not in the creative inventory and cannot be crafted — the give command is the only way to get one
/give @s minecraft:command_block 1
You need creative mode and cheats enabled for this to work. Place the block, then right-click it to open the command window Build a give command with the tool
The three types, and when to use each
Press the type button in the command block window to switch. The block changes colour with its type, so you can tell them apart from outside
| Type | Runs when | Used for |
|---|---|---|
| Impulse | Once per redstone pulse | Buttons, pressure plates, a door that opens on press |
| Repeat | Every tick, for as long as it is active | Systems that must keep checking — spotting when someone enters a restricted area |
| Chain | When the block pointing into it has finished | Several commands that must run in order |
Repeat fires very frequently. Put something heavy like a large fill inside one and the server will stutter immediately — keep repeat blocks for light checking commands
Needs redstone versus always active
The second button controls whether the block waits for a redstone signal. Getting it wrong is one of the top reasons people think their command is broken when it is not
- Needs Redstone — requires a lever, button, or plate wired to it; with no signal it does nothing. This is the default for impulse blocks
- Always Active — runs without any redstone at all — what most repeat and chain blocks need
If a repeat block does nothing at all, check this button first — it starts out set to needs redstone
Chaining commands together
When several commands must run in sequence, start with a repeat or impulse block and follow it with chain blocks, each one facing the next
- The way a block faces is the way execution flows — read the arrow on the block
- Every chain block in the run should be set to always active, or the chain breaks at whichever one is not
- The whole run happens within a single tick, so ordering is far more precise than delaying with redstone
A common run at the start of a round: set the game mode, clear inventories, teleport to the start, then announce it
/gamemode adventure @a
/clear @a
/tp @a 0 70 0
/title @a title เริ่ม!
Common problems
| Symptom | Common cause |
|---|---|
| It does nothing at all | Still set to needs redstone, or you did not press Done after typing the command |
| Works in chat but places things wrongly from the block | ~ counts from the block, not from the player |
| Only the first block in the chain runs | The blocks do not face each other, or a chain block is still on needs redstone |
| The game stutters badly after placing a repeat block | The command inside is too heavy to run every tick |
| Chat fills up with command block output | Turn it off with the commandBlockOutput game rule |
Tools that end up inside command blocks
Other guides to read next
- Minecraft command basics — Start from zero: how to enable cheats, where commands can be typed, and enough about selectors and coordinates to get going
- Target selectors in depth — A deep look at the square-bracket arguments, from type and distance through limit and sort, plus how to work out why a command matched nobody
- Coordinates: numbers, ~, and ^ — Why ~ and ^ cannot be mixed, why blocks end up in the wrong place, and which form to reach for in which situation
- Why an old give command stops working — Legacy NBT, 1.20.5 components, and 1.21.5 components side by side — compared using commands built by the generator itself
- Scoreboard basics — Create an objective the game tracks for you — or track it yourself from a command block — then use the score as a condition elsewhere
- The execute command — The most powerful command in the game, taken apart piece by piece — how as differs from at, and why reordering changes the result
- My command does not work — Work back from the error the game shows you, with the usual cause behind each one