What a command block does and how to turn it on

A command block is a Minecraft block that runs text commands when activated. Unlike typing commands into the chat window, a command block executes them automatically when powered by redstone, triggered by a player, or set to run on a loop. Command blocks only work in Creative mode or on servers where the owner has turned them on — they do not appear in Survival mode by default.

To turn on command blocks on your server or world, open the world settings and toggle "Command Blocks" to on. In Java Edition, you can also type /gamerule commandBlockOutput true into chat to see what the block does when it runs. Without this rule enabled, the block will still work but will not print results to chat.

Command blocks come in three types: Impulse (runs once when powered), Chain (runs when the block before it finishes), and Repeat (runs every game tick while powered). The type you choose depends on whether you want a one-time action or something that repeats.

Key Takeaways

  • Command blocks must be turned on in world settings and only work in Creative mode or on servers with them enabled.
  • Place a command block, right-click it, and type a command into the text field — the command runs when the block receives redstone power or you click the "Activate" button.
  • Impulse blocks run once when powered, Chain blocks run after the previous block finishes, and Repeat blocks run every tick while powered.
  • Common uses include spawning mobs, changing game rules, teleporting players, and running timed events with redstone clocks.
  • Test commands in chat first to make sure the syntax is correct before putting them in a command block.

Placing and opening a command block

To place a command block, switch to Creative mode, open your inventory, and search for "command block" in the creative menu. Place it anywhere in your world like you would any other block. The block looks like a dark purple cube with a square symbol on the front face.

Right-click the command block to open its interface. You will see a text field labeled "Command" at the top, a dropdown menu showing the block type (Impulse, Chain, or Repeat), and buttons for "Previous Output" and "Activate". The "Activate" button lets you test the command without needing redstone power.

Type your command into the text field exactly as you would type it in chat, but without the forward slash at the start. For example, to spawn a zombie, type summon zombie instead of /summon zombie. Click "Done" to save the command.

Powering a command block with redstone

An Impulse command block runs its command once each time it receives redstone power. Place a redstone dust trail next to the block, or put a lever, button, or redstone torch adjacent to it. When the redstone power turns on, the block executes the command.

A Repeat command block runs its command every game tick (20 times per second) as long as it has redstone power. This is useful for commands that need to run constantly, like checking if a player is in a certain area. Be careful with Repeat blocks — a command that spawns mobs every tick will quickly crash your game.

A Chain command block runs only after the command block pointing into it finishes. Chain blocks must be powered by redstone and must have another command block (Impulse or Chain) pointing at them. This lets you create sequences of commands that run in order.

Common commands to use in command blocks

The summon command spawns a mob or entity. Type summon zombie ~ ~ ~ to spawn a zombie at the command block's location. The three tildes represent the X, Y, and Z coordinates — using tildes means "this location".

The teleport command moves a player. Type teleport @s 100 64 200 to teleport the nearest player to coordinates 100, 64, 200. The @s means "the player who triggered this" — useful in command blocks activated by a player.

The give command puts items in a player's inventory. Type give @s diamond 64 to give the nearest player 64 diamonds. The @s selector works the same way as in teleport.

The setblock command places or removes a block. Type setblock 100 64 200 stone to place stone at those coordinates, or setblock 100 64 200 air to remove the block there.

Testing commands before putting them in a block

Always test a command in the chat window first. Open chat, type the command with a forward slash at the start, and press Enter. If the command works, you will see a success message. If it has an error, Minecraft will tell you what went wrong.

Once the command works in chat, copy it (without the forward slash) into the command block. This saves time and prevents the command block from running a broken command over and over.

Use the "Previous Output" button in the command block interface to see what happened the last time the block ran. If the command did not do what you expected, this message will often explain why.

Creating timed events with redstone clocks

A redstone clock is a circuit that turns redstone power on and off repeatedly. The simplest clock uses a Repeat command block, a Comparator, and redstone dust in a loop. When the Repeat block runs, it powers the Comparator, which powers the redstone dust, which powers the block again.

You can also build a clock using repeaters. Place two repeaters facing each other with redstone dust between them, and set both to a delay of 4 ticks. This creates a pulse that turns on and off every 8 ticks. Connect this to an Impulse command block to run a command at regular intervals.

Redstone clocks are useful for spawning waves of mobs, running timed announcements, or triggering events at specific intervals. Experiment with repeater delays to control how often your command runs.

Frequently Asked Questions

Can I use command blocks in Survival mode?

No. Command blocks only work in Creative mode or on servers where the owner has turned them on in the world settings. In pure Survival mode, you cannot place or use them.

What does the @ symbol mean in commands?

The @ symbol is a selector that targets players or entities. @s means the player who triggered the command, @a means all players, @p means the nearest player, and @e means all entities. You can add conditions in square brackets, like @e[type=zombie] to target only zombies.

Why is my command block not running?

Check that redstone power is reaching the block — look for redstone dust or a powered lever next to it. Make sure the command syntax is correct by testing it in chat first. If you are using a Chain block, verify that another command block is pointing at it and has power.

Can I run multiple commands in one command block?

No, each command block runs one command. To run multiple commands in sequence, use Chain blocks. Point an Impulse block at a Chain block, then point that Chain block at another Chain block, and so on. Each one will run in order.

What happens if I put a command that crashes the game in a Repeat block?

The block will keep running the command every tick, which will keep crashing your game. To fix this, restart Minecraft, delete the command block before it loads, or disable command blocks in the world settings.