Minecraft: Basic Command Block usage

Minecraft: Basic Command Block usage

My Minecraft tag: MatrixPSJAs many readers are probably aware, I’m a keen Minecraft player. I think its a great creative game and works really well for multiplayer. By the end of this short article you’ll be able to place ‘command blocks’ and get them to give you riches beyond your wildest dreams as well as engage you in deep and meaningful conversation. (Slight exaggeration may be present in that previous sentence).

Recently after a dry spell of not playing it I decided to get back into the Mining scene and dragged along my friend and fellow Minecrafter AdsWhite.

From then I have decided to craft a little PvP (Player VS Player) match arena but knew I lacked the knowledge of how to use the Minecraft logic / programming systems to put together a neat little map.

I can do simple redstone circuits, but how do you teleport people into maps, get them specific weapons, keep track of scores etc.

So time to don the learner’s goggles and dive straight experimenting with Command Blocks and OP Commands!


1) What are Minecraft Command Blocks

A good question that I knew you were going to ask! +10 points for you

These little blocks enable you, the world creator, to specify a single command at a specific time. This command may give or take away a certain item, change a player’s game mode or even make it rain.

Minecraft Command BlockBasically any command you can enter into the Minecraft console can be saved into a command block to run at a later time. Great for creating adventure maps or PvP maps!

They store a command and fire it when they are powered. So if you know about redstone circuitry you’re halfway to controlling the game.

Shown here to the right, they look quite distinct yet are placed and interacted with in the same way any other block is. You wont have come across them in normal survival maps as they simply don’t exist.


2) Being creative and placing command blocks

I’ll assume that as you’re still reading you know that Minecraft has a survival mode as well as a ‘creative’ mode. The latter allows you to place any block anywhere in the game. Without restrictions and effort to acquire blocks you can create some architectural masterpieces, as well as just plain old fun maps!

To begin with the map you’re working on must have ‘cheats enabled’. What this really means is that the console window can be opened by pressing the forward slash key, “/”.

Once you’ve got cheats enabled, you can enter creative mode by typing the following into the console:

     gamemode creative

Pretty self-explanatory right 😉

Redstone Circuitry: No command block
Redstone Circuitry panel but no command block?!

If you open your inventory you should see its now filled with dozens of different blocks and tabs. Here you can drag blocks into the bottom row and then place them as normal.

The third tab along the top, the pile of redstone dust, not surprisingly is where you’ll find the redstone circuitry and other logical components. However, you’ll notice that there is no command block. I’m not entirely sure why it isn’t in the panel yet.

Obtaining a Command Block in creative mode is simple however, just type the following into the console:

     give <yourname> 137

This should then place a command block in your inventory which you can put down as normal. Boom!


3) Learning your first command… already done!

Now you’ve placed your command block its time to get it doing something. You may think you don’t know any useful Minecraft commands, but you just used one.

The way you got your first command block, by typing give <yourname> 137 told the game to give your character the block with the ID of #137.

If you right-click on the command block you’ll see the GUI (Graphical User Interface) where you can enter the command you want to run. Type in the following:

     give <yourname> 266

Put a switch on a block next to your new programmed command block… then give it a flick!

You should be rewarded with a fine gold bar. Sweet!


4) Improving the GIVE command

It’s all well and good going around giving yourself gold, or even diamonds, but what happens when you want to give someone else a gift. Unless you know in advance, you can’t program in their name.

For example if you’ve got a maze with a treasure room at the end, you want the winner to be the one who gets the prize, not the 3 other players still lost in the cobblestone.

Thankfully the Minecraft wizards have thought of this problem and have given us 3 variables to use instead of the player’s name. So in our previous examples, take out your name and use…

  • “@a” to give a gold bar to everyone on the map!
  • “@r” to give a gold bar to a random player,
  • “@p” to give a gold bar to the closest player.

On top of using a variable like @p in your give command, you can also specify a quantity.

Try this little command out:

     give @p 344 12

Happy days – omelettes for all!


4.1) Common ID’s for items

You can jump over to the Minecraft Wiki to find all the object codes, but here are a few common ones I’ve used so far:

     46  - TNT
     137 - The Command Block
     264 - Diamonds!
     266 - Gold Ingot
     272 - Iron Sword
     297 - Bread 
     322 - Golden Apple


5) Lets talk a second…

Obviously one of the most primitive interactions on Minecraft is the ability to communicate with other players. Command blocks are also able to talk to players, or more accurately, at players.

Going back to our maze example mentioned above, once one player enters the winning centre and claims their prize, a message could be broadcast to everyone to let them know the race is over.

Add another command block onto the ground and type the following command into its GUI:

     say Hello World

Needless to say that when it triggers, it will send that to everyone’s screen.

If you wanted to send a message to a specific player, for example our maze winner, you would use the discreet and private communication method:

     tell @p Well done on winning this simple maze, have a cookie!

This method will only appear to the closest player, which if placed correctly, will be the maze winner.


6) Finally: easy comes, easy goes…

We learnt in the first few sections of this tutorial how to give items to players. How about doing the opposite? Taking objects from people.

This method could be useful in making sure no one enters a certain area with any objects (such as a PvP or Hunger Games style map), or taking a payment in exchange for a new object.

To completely strip a player of everything in their inventory,  enter:

     clear @p

If you wanted a melee combat server, you could periodically run the following to remove all bows (Item #261) from all players:

     clear @a 261

Row of Command Blocks in Minecraft

Summary of Command Block Tutorial #1

You should now be able to use individual command blocks to give and take away various items from a player, as well as sending them messages. Where specified in the examples above, you should also be able to use the command block to apply the command to the nearest player, all the players, or one at random.

If it’s helped, which it probably has if you’re still reading, please give it a share or mention it in a Minecraft YouTube video you produce using this information.

Thanks for reading this Minecraft article. Hope it helps
A Like or a Share would be hugely appreciated

There are lots more to cover about command blocks but we’ll start exploring them in another article.

Until then, happy mining!