Skip to main content
Back to Minecraft Commands

Minecraft command block basics

A first button-activated command block for Minecraft Java Edition 26.3.

These examples use Java Edition 26.3 syntax. Command syntax and game rules can differ in other versions and in Bedrock Edition.

1. Prerequisites and obtaining a block

Use a separate test world, allow commands and switch to Creative mode. On a Vanilla server, you need operator permission level 2 or higher to edit command blocks; ask the administrator rather than changing permissions yourself.

The game rule minecraft:command_blocks_work controls whether command blocks work. If they are disabled, enable them in your test world using this player-chat command with sufficient permissions. On a server, ask the administrator; in the server console, omit the leading slash. No restart is needed:

/gamerule minecraft:command_blocks_work true

In player chat, enter the following command with a leading slash to give yourself one command block. The block command itself will be entered separately later.

/give @s minecraft:command_block 1

2. The three block types

  • Impulse: runs once when activated. Use this type for the first experiment.
  • Chain: runs when reached by an executing command block chain. The arrows determine the chain direction; activation and condition settings still apply.
  • Repeat: runs every game tick while active. Do not use it for this item-giving experiment: it can generate many items very quickly.

3. Settings and execution context

Place the command block and open its interface in Creative mode. Select Impulse, Unconditional and Needs Redstone.

  • Unconditional ignores the previous block's success. Conditional requires the command block behind it, relative to its arrow, to have succeeded; it is not a check of who pressed a button.
  • Needs Redstone requires power. Always Active removes that power requirement; it does not turn an Impulse block into a repeating block.

Player chat commands use a leading slash. In the command block, enter the command below without a slash. The execution point is the command block, not the player who activates it.

@p selects the nearest player to the execution point, not necessarily the player pressing the button. @s selects the executing entity; a command block has no player entity of its own. Do not simply copy @s from a player-chat example.

4. First experiment: a button and one stone

  1. Enter this command in the Impulse block:
give @p minecraft:stone 1
  1. Confirm the input, then attach a button directly to the command block. Use sneak-place if normal interaction opens the block interface.
  2. Keep inventory space free, stand near the block and press the button once. For a predictable first test, make sure no other player is closer to the block.
  3. The nearest player receives one stone item per activation. If the inventory cannot accept it, the item may be dropped into the world.

Release the button and wait for its signal to end before activating it again. Remove the button or the block after the experiment.

5. Troubleshooting

  • Cannot obtain or edit the block? Check Creative mode, allowed commands and your server operator level.
  • Nothing happens? Check that minecraft:command_blocks_work is true, then check Impulse / Unconditional / Needs Redstone, the button's power signal and whether the chunk is loaded. Inspect Previous Output in the block interface; enable output tracking if needed.
  • Wrong recipient? Check which player is nearest to the block. The button does not identify its user to this command.
  • Too many items? Disconnect power and check that the block is not set to Repeat or triggered by a repeating circuit.
  • Syntax error? Compare the command exactly, including minecraft:stone and the amount 1. Use Java syntax, not Bedrock-only arguments.

Sources and version notes

Use the Java Edition sections of the Minecraft Wiki for command block settings and target selectors. Mojang's release notes describe changes in the versions linked below; syntax and interface labels can differ between releases.