How to get a command block in Minecraft, and why it does nothing
GuideJava 1.13 → 26.3 · Bedrock5 min read5 commands
Type /give @p minecraft:command_block: command blocks only come from commands. If yours does nothing, check the command_blocks_work game rule and redstone.
You get a command block with a command: /give @p minecraft:command_block on Java, /give @p command_block on Bedrock. There is no crafting recipe. If the block then does nothing, the usual cause on current Java versions is a game rule, not your command.
The basic (impulse) command block. Needs cheats on, or operator rights on a server.
give @p minecraft:command_blockSame block, Bedrock spelling: no minecraft: prefix needed and the count is written out.
give @p command_block 1The other three are repeating_command_block, chain_command_block and command_block_minecart. We checked all four IDs on a Java 26.3 server by putting each in an armor stand’s hand; the game named them Command Block, Repeating Command Block, Chain Command Block and Minecart with Command Block. Change the item in the /give generator to get the line for any of them.
Why does my command block do nothing?
Since Java 1.21.9, whether command blocks run at all is a game rule. It is command_blocks_work on 1.21.11 and later and commandBlocksEnabled on 1.21.9 and 1.21.10. We placed the same always-active block twice on 26.3, once with the rule on and once with it off, and read the block’s SuccessCount:
- setblock 5 -60 5 minecraft:command_block{Command:"say on",auto:1b}Changed the block at 5, -60, 5
- data get block 5 -60 5 SuccessCount5, -60, 5 has the following block data: 1
- gamerule command_blocks_work falseGame rule command_blocks_work is now set to false
- setblock 7 -60 5 minecraft:command_block{Command:"say off",auto:1b}Changed the block at 7, -60, 5
- data get block 7 -60 5 SuccessCount7, -60, 5 has the following block data: 0
With the rule off there is no error and no message. The block just sits there with a count of 0. Turning the rule back on did not wake it up either: the count was still 0 until we broke the block and placed it again, and then it ran at once.
If this rule is false, every command block in the world is ignored.
gamerule command_blocks_work true| Version | Command |
|---|---|
| Java 1.21.11, 26.1 – 26.3 | gamerule command_blocks_work true |
| Java 1.21.9 – 1.21.10 | gamerule commandBlocksEnabled true |
| Java 1.21.8 and older | Command blocks work does not exist in Java 1.21.8 — left out. |
Each version refuses the other’s spelling with Incorrect argument for command; we got that from 26.3 for commandBlocksEnabled and from 1.21.10 for command_blocks_work.
The same rule under its first name.
gamerule commandBlocksEnabled trueServers before 1.21.9
Older servers have no such rule. There the switch is the line enable-command-block=true in server.properties (minecraft.wiki, server.properties), read when the server starts. Our 1.21.4 test server refused both rule names, had that line set to true, and its command blocks ran. We did not test it set to false.
It needs redstone, or Always Active
A command block placed by hand starts in Needs Redstone mode. Nothing happens until it gets a signal, or until you switch the button in its menu to Always Active (that is the auto:1b in our test blocks). We placed one without auto, read the count, then put a redstone block next to it:
- setblock 13 -60 5 minecraft:command_block{Command:"say needs redstone"}Changed the block at 13, -60, 5
- data get block 13 -60 5 SuccessCount13, -60, 5 has the following block data: 0
- setblock 13 -60 6 minecraft:redstone_blockChanged the block at 13, -60, 6
- data get block 13 -60 5 SuccessCount13, -60, 5 has the following block data: 1
Opening the menu needs Creative mode and operator rights (minecraft.wiki, Command Block: Usage); with no player on the server that is one thing we could not try.
Skip the menu: place the block with its command inside
/setblock can place a command block that already holds a command and is already active. This is the form we used for every test on this page; the /setblock generator takes the same data in its NBT field.
A repeating command block above you with the command inside and Always Active on. No redstone, no menu.
setblock ~ ~1 ~ minecraft:repeating_command_block{Command:"say hi",auto:1b}A repeating block really does run every game tick. Ours added 1 to a scoreboard each time, and the score went from 87 to 114 between two reads a moment apart. A leading slash inside the block is fine too: {Command:"/say slash",auto:1b} ran with a success count of 1.
If the chat fills up with command block messages, /gamerule command_block_output false turns them off (commandBlockOutput on 1.21.10 and older). For what to put in the blocks, the parkour course guide builds a whole minigame out of them.
FAQ
What is the command to get a command block?
/give @p minecraft:command_block on Java and /give @p command_block on Bedrock. Cheats must be on, or you must be an operator on a server.
Can you craft a command block or find it in Creative?
No. There is no recipe, and it is not in the normal Creative tabs (minecraft.wiki, Command Block: Obtaining). A command is the way to get one.
Why is my command block not working?
On Java 1.21.11 and later check /gamerule command_blocks_work: with the rule set to false our test block never ran. Then check that the block is powered by redstone or set to Always Active.
What are the IDs of the other command blocks?
repeating_command_block, chain_command_block and command_block_minecart, next to the plain command_block. All four were accepted as item IDs on our Java 26.3 server.
More drops
- Update drop3 commands/effect with tags: one command for a whole set of effects (26.4 snapshot)Four effects from one line, and the tag file you have to write first.Java 26.4 Snapshot 10 · 26.3
- Guide8 commandsBoss fights from one command block: mounts, riders and a live health barA flying ghast fortress and a boss bar that tracks real health every tick.Java 1.21.11 – 26.3
- Next drop · 32,768 is the wall. One game rule moves it; here is the name for your version.Java 1.19.2 → 26.3 · 4 commands