How to Use Command Blocks in Minecraft

Updated on December 11, 2015
Dreamhowl profile image

Dreamhowl has been playing Minecraft since 2012. She enjoys building, farming, and breeding animals. She especially enjoys magic modpacks!

What Are Command Blocks?

In Minecraft, the command block can automatically run specified server commands as long as it is activated by redstone. Command blocks was originally added to support Adventure mode but also allow custom map makers to improve interaction with the player. Command blocks cannot be crafted and are not located in the Creative mode inventory; players with server privileges can use the “give” command to give themselves or another player a command block. The “give” command is as follows:

  • /give <player name> 137

When typing the command in, exclude the brackets around the player’s name. The number following the name must be 137, as this is the command block’s ID number. Only players in Creative mode can place command blocks, and only players with operator status on the server can input and save commands. In Survival mode, command blocks cannot be edited or destroyed by any means. Command blocks can also be used in singleplayer or multiplayer worlds: simply turn on LAN mode and allow cheats.

Learn how to use command blocks in your singleplayer and multiplayer worlds!
Learn how to use command blocks in your singleplayer and multiplayer worlds! | Source

Why Use Command Blocks?

Have you ever played an adventure map where it is constantly nighttime, or where the weather never changes? You may have downloaded a custom map where players are awarded special items, enchantments or experience at the push of a button or completion of a task. All of these are made possible through command blocks. When making your own Minecraft map, you might need command blocks if:

  • You want it to always be day or night

  • You want to change the weather

  • You want to change the game difficulty

  • You want to play a certain sound

  • You want to give a player a message

  • You want to teleport to another location

  • You want to give players items

What types of maps do you play?

See results

YouTube is full of videos that feature and review various Minecraft maps. Multiplayer versus maps are especially popular. There are many categories of downloadable Minecraft maps that utilize command blocks to maximize the user experience. These are many of the reasons why map creators use command blocks. Some examples of custom map categories are:

  • Adventure maps

  • Parkour maps

  • Puzzle maps

  • Survival maps

Adventure maps are all about storyline and usually have the player act out the main role of the character in the adventure. While adventure maps previously relied on telling their stories through signs and books, they can now tell their tale through dialogue and sounds because of command blocks.

Parkour maps challenge the player to get from one end of the map to the other with as few deaths as possible. These maps often feature jumping puzzles, along with other dangerous challenges. Command blocks make it possible for players to set spawnpoints before challenging tasks.

Adventure maps use command blocks to express dialogue between characters.
Adventure maps use command blocks to express dialogue between characters. | Source

Puzzle maps focus on problem-solving skills, featuring mazes, traps and other difficult puzzles. Some puzzle maps also come with a storyline similar to adventure maps. The use of command blocks allows maps like these to deliver directions more easily, as well as story-related dialogue and sound.

Survival maps can either be solely focused on survival for single or multiplayer scenarios, or include a storyline along with the challenge of survival. Command blocks can provide a starting spawnpoint for players, as well as story-related information if applicable. The opportunities are endless.

How to Use Command Blocks

Setting up command blocks is easier than most Minecraft players think! While commands can get intricate, some commands (like setting the time of day) are simple and easy to program into a command block. Bigger projects can come later: to start, try learning the basics of how to place, set and use a command block!

Click thumbnail to view full-size
Command blocks can only be spawned and edited by players in Creative mode. The "give" command is the only way to obtain command blocks in Minecraft.
Command blocks can only be spawned and edited by players in Creative mode.
Command blocks can only be spawned and edited by players in Creative mode. | Source
The "give" command is the only way to obtain command blocks in Minecraft.
The "give" command is the only way to obtain command blocks in Minecraft. | Source

1. Switch Gamemode to Creative

Remember that command blocks can only be spawned in and placed in Creative mode! To switch your gamemode, make sure that you have the proper server privileges (if applicable) or that cheats are enabled. In your chat box, type “/gamemode c”, “/gamemode creative” or “/gamemode 1” without the quotation marks. In Creative mode, your health and hunger bars will disappear, and typing “e” will bring up the Creative mode inventory.

Click thumbnail to view full-size
Right-clicking on a command block will bring up the console command line.Remember that a single command block can only operate one command!
Right-clicking on a command block will bring up the console command line.
Right-clicking on a command block will bring up the console command line. | Source
Remember that a single command block can only operate one command!
Remember that a single command block can only operate one command! | Source

2. Right-Click on a Command Block

Once you are in Creative mode, right-click on a command block to access it. Remember that you need the “give” command to spawn a command block for use. Furthermore, command blocks will only work if they are hooked up to a redstone current. Right-clicking will bring up a dialogue box where you can put a server command. The maximum command length is limited to 254 characters, so don’t get too carried away!

This command block gives the player who pushes the button a command block!
This command block gives the player who pushes the button a command block! | Source

3. Enter a Command and Click Done

When you enter a command into the command block, you will need to specify what players are being targeted. This can be done by entering a player’s name, or a selection of three different variables: “@p” (nearest players), “@r” (random player) or “@a” (all players). These variables are especially useful in situations where the player triggering a command block is unknown. Once you’ve set your command, click “Done” to save it into the command block.

The following examples are simple and practical applications of the command block in both singleplayer and multiplayer Minecraft worlds. If you can think of any popular (and easy to learn) uses for the command block, feel free to chime in in the comment section of the article!

How to Change Game Rules

Game Rules are a recent feature that allow players and command blocks to adjust specific base settings of the Minecraft world. There are nine listed game rules that can be controlled with command blocks on your map. You can use game rules to create eternal daylight or darkness, disable mob spawning, disable mob drops and more! When entering the “gamerule” command, use the following formula:

  • /gamerule <gamerule> <true/false>

Game Rules and Their Effects in Minecraft

Game Rules
Game Effects
commandBlockOutput
Enables/disables text output of command blocks
doDaylightCycle
Enables/disables day/night cycle
doFireTrick
Enables/disables fire spread/dissipation
doMobLoot
Enables/disables mob drops
doMobSpawning
Enables/disables spawning of mobs
doTileDrops
Enables/disables blocks dropping items when broken
keepInventory
Enables/disables keeping inventory on death
mobGriefing
Enables/disables removal of blocks by creepers or endermen
naturalRegeneration
Enables/disables players to naturally regenerate health
Setting game rules on your Minecraft map can make gameplay more fun!
Redstone loops create repeating commands, like this rain weather machine!
Redstone loops create repeating commands, like this rain weather machine! | Source

How to Set the Weather

Some maps have a dark theme that goes perfect with rainy weather or thunderstorms, while others are best played in clear skies. There are many ways to control the weather with command blocks depending on your needs. For a simple weather command, enter the following into a command block:

  • /weather <input>

In this case, input is replaced with either “clear”, “rain” or “thunder” in the formula. You can connect a button or lever to the command block to switch the weather manually, or set up an automated redstone loop to continually reset the weather for you. This is easily accomplished using redstone repeaters, redstone, a button and a building block.

Command blocks can be set to save a spawnpoint in case of player death.
Command blocks can be set to save a spawnpoint in case of player death. | Source

How to Set a Spawnpoint

Spawnpoints are vital in many Minecraft maps, including adventure maps, parkour maps, puzzle maps and more. It is incredibly annoying to have to walk back from the beginning of the map each time each time a player dies. Using the “spawnpoint” command is like saving your game progress or reaching a checkpoint. Here is the “spawnpoint” command:

  • /spawnpoint

By connecting a command block to a building block with a button or pressure plate, players can set their spawnpoint to the location of the command block. If you want to get complex, you can add coordinates to the “spawnpoint” command to specify exactly where the spawnpoint is set. By having a spawnpoint command, players do not need to sleep in a bed to set their spawn.

Players can use the teleport command to travel to any location in the Minecraft world.
Players can use the teleport command to travel to any location in the Minecraft world. | Source

How to Teleport to a Location

Running from place to place can get exhausting, especially on a multiplayer server. Thankfully, with the use of the “teleport” command, players can travel to specific coordinates in the Minecraft world, or even the locations of other players. To use the “teleport” command, enter this into a command block:

  • /tp <playername> <x> <y> <z>

With command blocks, it is easiest to have a defined set of coordinates to teleport the player to, such as the location of the next part of the adventure map. If the command block isn’t meant for a specific player, you can use “@p” to select the nearest player. If you are on a multiplayer server, you can tailor the command block to just your use by inputting your Minecraft username.

It is easy to hide command blocks behind walls and structures for aesthetic appeal.
It is easy to hide command blocks behind walls and structures for aesthetic appeal. | Source

These are just a few ways to use command blocks in your singleplayer or multiplayer Minecraft world. There are far more intricate commands and redstone circuits that mapmakers use to provide fantastic player experiences. If you have any more ideas about simple uses for command blocks, feel free to share them in the comment section below!

Test Your Knowledge of Command Blocks!

view quiz statistics

Questions & Answers

  • When playing Minecraft, how do you remove blocks with the command block?

    In Minecraft, you can remove blocks at specific coordinates with the following command (replacing x, y, and z with the cooridnates of the block): /setblock x y z minecraft:air

© 2013 Jessica Marello

Comments

    0 of 8192 characters used
    Post Comment

    • EmpathyHeals profile image

      EmpathyHeals 

      3 years ago from Lincon, NE

      Sure go ahead, the generator isn't mine but it's public; go ahead and link to the game, as people can download it and use it in single player or on their server!

    • Dreamhowl profile imageAUTHOR

      Jessica Marello 

      3 years ago from United States

      @EmpathyHeals: That is a great generator! And the link to your game is interesting. Do you mind if I link to both in my hub?

    • EmpathyHeals profile image

      EmpathyHeals 

      3 years ago from Lincon, NE

      Thanks, this is great! I am in love with this http://bimbimma.com/mcstacker/ command generator for command blocks! It gives such excellent commands for them so you can spawn whatever. I have made this very educational game with command blocks, in case anyone wants it (you can download my hard work!) http://www.planetminecraft.com/project/dying-to-le...

    working

    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, levelskip.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://levelskip.com/privacy-policy#gdpr

    Show Details
    Necessary
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
    Features
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Marketing
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Statistics
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)