A command block lets you run game commands automatically when a player walks near it or activates it

A command block is a special block in Minecraft that executes commands — the same text instructions you type into the chat window — without you having to type them each time. Instead of typing /give @s diamond over and over, you can put that command in a command block, and it runs whenever you want it to. Command blocks only work in Creative mode or on servers where the owner has turned them on, because they can change the game world in ways that would break Survival mode play.

Command blocks are useful for building mini-games, creating automatic farms, spawning mobs in specific patterns, or running sequences of events when a player steps on a pressure plate. They are the backbone of most custom maps and adventure worlds that other players have built and shared.

Key Takeaways

  • Command blocks only appear in Creative mode or on servers with cheats enabled; you cannot craft them in Survival mode.
  • You obtain a command block by typing /give @s command_block in the chat, then place it like any other block.
  • Right-click the command block to open its interface and type the command you want it to run.
  • Command blocks execute when powered by redstone, when a player walks over them (if set to "Always Active"), or when you click the "set up" button in the interface.
  • Chain command blocks and conditional command blocks let you link multiple commands together in sequence.

Getting a command block in Creative mode

In Creative mode, open your inventory and search for "command block" in the search bar at the top. Click it once to add it to your hotbar, then place it in the world like you would any other block. If the search bar is not visible, press E to open inventory, then look for a small text box near the top of the window.

If you prefer using commands instead, type /give @s command_block into the chat window and press Enter. The command block appears in your inventory when ready. The @s part means "myself" — if you wanted to give a command block to another player, you would type their name instead.

Opening the command block interface and entering a command

Once you have placed a command block in the world, right-click it (or press the secondary action button on console controllers). A window opens showing a text field labeled "Console Command". This is where you type the command you want the block to run.

Type your command exactly as you would in the chat window, but do not include the forward slash at the start. For example, to give yourself a diamond sword, type give @s diamond_sword. To summon a creeper at your location, type summon creeper. You can find a full list of commands in the official Minecraft wiki or in-game by typing /help in chat.

After you type the command, click "Done" or press Enter. The command block is now ready to run that command whenever it is activated.

Setting how the command block activates

Below the command text field, you will see a dropdown menu that says "Impulse", "Chain", or "Repeat". For most uses, leave it on "Impulse" — this means the block runs the command once each time it is powered by redstone. "Repeat" runs the command every game tick (20 times per second) as long as redstone power is flowing to it. "Chain" is used to link multiple command blocks together in a sequence.

You will also see a checkbox labeled "Always Active" or "Needs Redstone". If you check "Always Active", the command block runs its command repeatedly without needing any redstone signal. If you leave it unchecked, the block only runs when redstone power reaches it — from a lever, button, pressure plate, or redstone wire.

For testing or straightforward one-time commands, check "Always Active" and set the type to "Impulse". For more complex builds, use redstone to control when the block activates.

Powering a command block with redstone

If you want the command block to run only when you trigger it, leave "Always Active" unchecked and connect redstone to it. You can use a button, lever, pressure plate, or redstone wire. When the redstone signal reaches the command block, it lights up and runs the command once (if set to Impulse) or repeatedly (if set to Repeat).

A common setup is to place a pressure plate on top of the command block or next to it, then run redstone wire from the plate to the block. Now whenever a player walks on the plate, the command block activates. You can also use a button on the side of the block for manual set up, or a tripwire hook to detect when a player walks through a doorway.

Chaining multiple command blocks together

If you need to run several commands in order — for example, summon a mob, then give it armor, then make it hold a weapon — you can chain command blocks together. Place the first command block and set it to "Impulse" with "Always Active" off. Place a second command block directly in front of it (in the direction the first block is facing), and set that one to "Chain".

In the second block, type your second command. The chain block will only run if the first block's command succeeds. You can add more chain blocks in a line, and they will all execute in order when the first block is powered. This is much cleaner than trying to run multiple commands from a single block.

You can also use "Conditional" mode on chain blocks to make them run only if the previous command succeeded, or skip them if it failed. This is useful for error-checking in complex command sequences.

Common command block uses and examples

One of the simplest uses is to give items to players. Place a command block with "Always Active" on, set to "Impulse", and type give @s diamond 64. Every time the game loads that chunk, all players in the area receive 64 diamonds. This is useful for starting a mini-game or adventure map.

Another common use is spawning mobs. Type summon zombie ~ ~ ~1 to spawn a zombie one block in front of the command block. You can add properties like summon zombie ~ ~ ~1 {Health:5} to spawn a zombie with only 5 health points, making it easier to defeat. Combine this with a repeating command block and redstone to create a mob spawner for a mini-game.

You can also use command blocks to teleport players. Type teleport @s 100 64 200 to send yourself to coordinates 100, 64, 200. Use @a instead of @s to teleport all players at once, or @p to teleport only the nearest player.

Frequently Asked Questions

Can I use command blocks in Survival mode?

No. Command blocks only work in Creative mode or on multiplayer servers where the owner has enabled cheats. In pure Survival mode, the game does not allow you to place or use them. If you want to use command blocks on a server, ask the owner to enable cheats in the server settings.

What does the "Conditional" checkbox do?

When you turn on "Conditional" for a command block, it only runs if the previous command block in the chain succeeded. This is useful for checking whether something worked before moving to the next step. For example, if you try to give a player an item but they have a full inventory, the command fails, and any conditional blocks after it will not run.

Why is my command block not running?

Check three things: first, make sure "Always Active" is on, or that redstone power is reaching the block. Second, verify that your command is spelled correctly — even a small typo will cause it to fail. Third, make sure you are in Creative mode or on a server with cheats enabled. If you are still stuck, look at the command block's output by clicking it and reading any error messages in the text field.

Can I copy a command block with the same command inside?

Yes. In Creative mode, hold Ctrl (or Cmd on Mac) and left-click the command block to copy it, then right-click to paste it. The new block will have the exact same command, settings, and redstone configuration. This is much faster than typing the command into multiple blocks.

What is the difference between @s, @a, and @p?

@s means "myself" — the player running the command. @a means "all players" in the world. @p means "the nearest player" to the command block. You can also type a specific player's name instead, like give Steve diamond to give a diamond only to the player named Steve.