Monday, May 9, 2016

Command Blocks - Introduction

Whether you are new to Minecraft or a seasoned veteran, you've probably typed a command at some point. One of the most useful commands is the one that changes the gamemode - sound familiar? So while commands may sound intimidating, you've already used some of them and there is no reason why you shouldn't learn more. That is, of course, unless you hate a fun learning challenge!



When working with commands and command blocks, there are a few useful tips that can spare you from many headaches and rage-quits. Starting with the basics, I'll outline some advice that I've gradually accumulated in my exploration of the great commands. Because commands are such a robust topic, this series will be broken into several parts to make it more digestible. The other benefit of this technique is that more advanced readers can easily skip the parts they are comfortable with. However, I aim to reach people of all experience levels with these writings - there should be something for everyone!

Basics

As you likely know, you can access the chat menu in Minecraft by typing the forward-slash "/" key. Anything typed after this forward-slash key will be interpreted as a command by Minecraft. Typing in this box without the forward-slash will broadcast your message to the global chat. You can type many useful commands directly into Minecraft by using this chat menu, but the length of the command or text you enter is limited to about 99 characters. As you will soon learn, commands can and often need to be much longer than this. Fortunately, command blocks have a command character limit of nearly 33,000 and this allows us to do some really fun things!


Enabling Cheats

To work with commands, you must first make sure that cheats are enabled. When you create a new save file, you will have the option to turn on cheats. If the save file that you are playing does not have cheats enabled, you have two options. The first is to open the game to your LAN or Local Area Network. This is accomplished by pressing escape and clicking the OPEN TO LAN button. Here you will have the option to set gamemode and whether or not cheats are allowed. An alternative method is to download a program such as NBTExplorer that allows you to edit the NBT data for the save files and manually change whether or not cheats are allowed. Once cheats are allowed, you can use commands to change all of the other gamerules.
 

Getting Command Blocks

If you're ready to dive in to the world of commands, the first command you should use is the one that gives you a command block. Once you have cheats enabled, simply type

          • /give @p command_block 
You can substitute @a or @e or even your playername for @p and you should still get the command block. If you want more than one command block, simply append the number that you want after the command.

The /give command is a Classic!

Writing Commands

Minecraft has a feature which makes it easier to program commands and reduces the probability of programming errors being made. Once you are in either a chat box or a command block, hit the TAB key. You will be presented with a list of possible commands that you can scroll through with tab. Even better, the TAB key will auto-complete any command that you start to type, at least as much as it can. You will still have to enter some parts manually and have some idea of what the syntax of a given command is, but if you make a mistake with a command you will be reminded of the syntax by Minecraft. It is very forgiving in this way, and makes the world of commands much more accessible for beginners.

Gamemodes

You can work with command blocks in survival and creative mode, but not in adventure or spectator mode. Personally, I recommend being in creative mode (/gamemode 1) if you are doing a substantial amount of programming. Although command blocks do not show up in the creative inventory, they are easy to obtain once you have one when you're in creative. You can click the middle mouse button (usually the scroll wheel) and whatever block you are looking at will appear in your hand. This way you can avoid typing the /give command again and again to get more command blocks. If you're needing to program command blocks, you're probably already playing creative in the first place.

 

Let me give some words of caution about creative mode: When you left-click a single time on a block in creative mode, the block gets destroyed. This isn't a big deal if it is just a standard block, but when the block that is accidentally destroyed stores an elaborate command that you don't have recorded elsewhere, the rage-quit desire builds. The best scenario is that you are able to figure out what the command was without too much effort and reprogram it. The worst scenario is that you don't have any backups and your map no longer works. What is a cautious command block programmer to do?

Destroy Them All!

Swords 

It may seem counter-intuitive, but swords are the only reliable way that I've found to work with command blocks in creative mode without risking frustration upon every accidental click. Because swords are a special kind of attack weapon, you can left-click on blocks with a sword in creative without destroying them. Any time you are near a command block or plan to program one, make sure that you have a sword (any sword) in your active hand. While swords may not break blocks in creative mode, you can still use them to right-click on command blocks and program them. Swords truly are the perfect tool!

 

In upcoming entries, we will dive deeper into command blocks, the different types, settings, nuances, and commands! Be sure to let me know if you like these types of advice articles and want to see more. Feel free to offer up potential subjects as well!

No comments:

Post a Comment