Command blocks let you run commands automatically when triggered, without typing them into chat

A command block is a special Minecraft block that executes commands when activated. Unlike typing commands into chat, command blocks run on their own — triggered by redstone, by a player walking nearby, or on a repeating loop. They let you automate tasks, spawn mobs, change weather, teleport players, or run complex sequences without manual input each time.

Command blocks only work in Creative mode or in Survival worlds where cheats are enabled. You cannot craft them from materials. Instead, you obtain them through the creative inventory or by typing a command into chat.

Key Takeaways

  • Command blocks are obtained from the creative inventory in Creative mode or by typing /give @s command_block in a world with cheats enabled.
  • The three types — Impulse, Chain, and Repeat — determine when and how often the block runs its command.
  • Redstone power, player proximity, or repeating timers can trigger command blocks to execute their stored commands.
  • Command blocks work best for automating spawning, teleporting, weather changes, and other tasks that would otherwise require repeated manual input.

Getting a command block into your world

In Creative mode, open your inventory and search for "command block" in the creative menu. Drag it into your hotbar and place it like any other block. You can place as many as you need.

In Survival mode with cheats enabled, open chat and type /give @s command_block. This adds one command block to your inventory. If cheats are not enabled, you must create a new world and toggle "Allow Cheats" to On before generating it, or use the world settings menu to enable cheats after creation.

Once placed, right-click the command block to open its interface. This is where you type the command you want it to run.

Understanding the three command block types

Impulse blocks (orange) run their command once when powered by redstone. They execute immediately when a redstone signal reaches them, then stop. Use impulse blocks for one-time actions like spawning a single mob or sending a message.

Chain blocks (green) run when the command block pointing into them completes. They execute in sequence, one after another, allowing you to chain multiple commands together. The first block in the chain must be powered by redstone or another trigger; each subsequent chain block runs automatically after the previous one finishes.

Repeat blocks (purple) run every game tick (20 times per second) as long as they receive redstone power. Use repeat blocks for continuous effects like constant healing, ongoing particle effects, or checking conditions repeatedly. Be careful with repeat blocks — they consume server resources if overused.

Powering a command block with redstone

Command blocks need a redstone signal to activate. Place a redstone wire, lever, button, pressure plate, or redstone torch adjacent to the command block. When the redstone component is powered, the command block receives power and executes.

For impulse blocks, the command runs once per redstone pulse. For repeat blocks, the command runs continuously while power is supplied. You can also use a redstone repeater to delay the signal, creating timed sequences.

A common setup is a button connected to an impulse command block. Press the button, the block receives power, and the command runs. For automated loops, connect a repeat block to a redstone torch or repeater that powers it continuously.

Writing commands for your command block

Commands in command blocks follow the same syntax as chat commands, but without the leading slash. For example, to spawn a zombie, type summon zombie. To teleport the nearest player 10 blocks forward, type tp @s ^ ^ ^10.

Common command block uses include spawning mobs with summon, changing game mode with gamemode, setting weather with weather, and teleporting players with tp. You can also use say to broadcast messages, give to add items to inventories, and fill to place or remove blocks in bulk.

The @s selector refers to the command block itself. Use @p for the nearest player, @a for all players, and @e for all entities. You can add conditions like [distance=..10] to target only entities within 10 blocks.

Setting up a command block to trigger on player proximity

To run a command when a player enters a certain area, use a repeat command block with a conditional check. Place the repeat block and type a command like execute as @a[distance=..5] run say Hello!. This checks every tick for players within 5 blocks and runs the say command for each one found.

Alternatively, use a pressure plate connected to an impulse command block. When a player steps on the plate, it sends a redstone signal, the command block receives power, and the command executes once. This is simpler for one-time triggers like opening a door or starting a sequence.

Chaining multiple commands together

Place an impulse command block, then place a chain command block directly behind it (the chain block must face the impulse block). The impulse block runs first, and when it completes, the chain block automatically executes. You can attach more chain blocks in sequence to create longer command sequences.

Power only the first impulse block with redstone. Each chain block will run in order without needing its own power source. This is useful for complex tasks like spawning a mob, giving it items, and teleporting it to a location — all in one button press.

Frequently Asked Questions

Can I use command blocks in Survival mode without cheats?

No. Command blocks require cheats to be enabled in your world. You can enable cheats in world settings after creating the world, or toggle "Allow Cheats" to On when creating a new world. Once enabled, you can obtain command blocks with the /give command.

What happens if I put the wrong command in a command block?

The command block will not execute, and you will see an error message in the chat log. Right-click the block again, fix the command, and try again. Command blocks do not break or delete themselves if a command fails — you simply edit and resubmit.

Can I use command blocks on a multiplayer server?

Only if the server has command blocks enabled in its server.properties file. Many public servers disable them to prevent griefing. Check with your server administrator or the server rules before attempting to place command blocks.

How do I make a command block repeat a command every few seconds instead of every tick?

Use a repeat command block connected to a redstone repeater set to a delay. A repeater set to 4 ticks (the maximum) delays the signal by 0.2 seconds. Stack multiple repeaters or use a more complex redstone circuit to achieve longer delays. Alternatively, use a command like /schedule function to delay execution within the command itself.