Minecraft Blogs / Tutorial

10 commands (and tricks) admins might want to know

  • 9,654 views, 2 today
  • 7
  • 3
ShelLuser avatar ShelLuser
Level 56 : Grandmaster Engineer
Hi gang!


Minecraft has come a long way over the years. Once a game where you literally had to collect every single block the hard way if you wanted to use those to build something (there was no Creative mode yet) right to where we are now: a gaming environment where the sky is pretty much the limit. And even that 256 block limit can be raised if you want to ;)

Some players even argue that the game is becoming a little too complex to their liking and although I don't really share that opinion I can definitely understand where it's coming from. So I figured; let's do a top 10.

These are 10 commands (and 'tricks') which I think every admin and/or map maker needs to know about.

#10 /weather

Everyone knows about /toggledownfall in the previous versions of Minecraft because for some reason we all seem to dislike the idea of walking around in a virtual rainstorm. We really don't want our avatar to become wet ;) And of course there's also the issue of the rain particles which can add to our lag.

However we can no longer toggle the rain on and off so instead we now need /weather clear to make it stop raining. You can either use the command as-is but you can also add a value which will make the weather stay clear for an x period of time.

#9 /gamerule

Stopping a rainstorm is one thing, but if it really bothers you so much then why not simply prevent it from ever raining again? You can do that by setting a so called game rule, and there are rules for pretty much everything. If you don't want the weather to change at all then simply set the doWeatherCycle gamerule to false. Is it bothering you that it gets dark all too quickly while you're busy building? Not a problem: doDaylightCycle is yet another rule you can enable or disable.

Some very useful game rules are:
  • doWeatherCycle - Stops Minecraft from automatically changing the weather. So if you prefer a never ending rainstorm then simply set this gamerule to false, then change the weather using the /weather command and you're all set.
  • doDaylightCycle - A bit the same as the rule above but this time it controls the movement of the sun and moon. Set this to false and it will remain day (or night) forever.
  • keepInventory - Normally you drop all the items in your inventory if you die. But if you dislike that behavior then you can simply turn it off using this gamerule.
  • mobGriefing - Mobs such as Enderman and Creepers have a nasty habit of destroying parts of the land. Creepers blow things up and Enderman like to steal blocks. This will put a stop to that :)
  • doMobSpawning - And of course if you don't want new mobs to appear at all then simply turn then off. After this command Minecraft will no longer spawn any new mobs into your world.

#8 /locate

As you know Minecraft automatically generates quite a few special structures in a world. We have villages with villagers in them, desert pyramids, strongholds which contain the magical end portals and even shipwrecks!

ShipwreckMust. resist. exploring... ;)

Now, I happened to find this one by total accident (I teleported myself to 5000 ~ 5000 on my server, looked around and suddenly discovered this) but what if you really need a specific structure for your project? Well, simple: /locate is all you need.

Just type in the command and if you have command suggestions turned on (this is enabled by default) then Minecraft will present you with a full list of all the structures it knows about. Select one and then the game will check if there is something in your surroundings. If so then you'll get the coordinates; just click on them and the teleport command you need will be automatically pasted into the chat. Convenient, right?

#7 /effect

When you're exploring your world then sometimes you can come across darker areas. If you're above ground then you could consider changing the time to daylight but that won't do you much good while you're underground. Now what? Simple really: give yourself the Night Vision effect: /effect give @p minecraft:night_vision. By default you'll get an effect for 30 seconds, if you want to have it applied for a longer period then you'll just have to specify the time (in seconds) as well. So adding 300 to the command would give you Night Vision for 300 seconds, so 5 minutes.

But there's much more you can do here ;)

10 commands (and tricks) admins might want to know

Here I wanted to know how many creepers there were around me. Now, I could have used another command for that but other than the amount I also wanted to roughly know where they were. So I made them glow: /effect give @e[type=minecraft:creeper] minecraft:glowing 180, the result can be seen above.

#6 Toolbars

The creative inventory is a very extensive set of windows; they contain pretty much every block in the entire game (with some notable exceptions such as command blocks and structure blocks). But having to search through the whole inventory just to get the block(s) you need for your projects can be very time consuming. And although we do have a /give command that too can become quite bothersome, for example having to find the right name(s) for the block(s) you want. This can become especially bothersome if you work on a project in multiple worlds (maybe both in single player and on a server).

The solution? Toolbars.

If you look at the above screenshots you'll notice that I have a very specific set of blocks in my hotbar. This is actually a toolbar which I can load at any moment whenever I need access to one of those blocks. And I have some more...

my toolbars
My toolbars: redstone, admin, transport & SokoCraft

How does it work?

This only works in creative mode and it's very simple: place some blocks which you plan on using more often in your hotbar. Then press c + 1 - 9. So: press 'c' and then press a number from 1 to 9 (there are 9 toolbars in total). This will save your toolbar. Then you can load this toolbar at any time by pressing x + 1 - 9. So, once again, press 'x' and then a number from 1 to 9.

As you can see in my example above I have defined several toolbars. Whenever I need to work on redstone I simply press control-1 (I re-assigned the controls) and then my hotbar gets filled with the redstone items you see. Whenever I need to do 'admin' stuff which requires a command or structure block (or just the debug stick) then I press control-2. Couldn't be easier.

And it gets better: these toolbars are stored locally. So it doesn't matter where you are, in a local game or on a remote server somewhere: as long as you have access to creative mode then you can access your toolbars.

Fun story: I once even scared a server owner with this. They gave me access to creative mode but not access to using commands (so no operator status). And much to their surprise I suddenly held a command block in my hand, was I somehow trying to hack their server?! Fortunately that misunderstanding was quickly explained, but it is something to keep in mind.

This feature also makes the /clear command much more appealing I think (this clears your inventory) simply because you don't have to rummage through the whole creative inventory again.

#5 /setblock & /fill

I know I'm cheating a little bit here but these two commands roughly do the same thing: they place specific blocks in your world. Sure, normally you can easily place blocks yourself but sometimes that can be quite a bother. Although you can place & break blocks instantly it still takes time.

Let's say you need to get rid of some trees in front of you. I suppose you could "chop" them down and then manually remove the leaves (maybe with some shears?) but why bother? => /fill ~1 ~ ~1 ~20 ~10 ~20 minecraft:air. This will clear out the entire area in front of you (assuming that you're looking eastwards). It will remove blocks within a 20 x 20 x 10 area. Remember: air is also considered a block in Minecraft ;)

And trust me when I say that this will be a lot faster than manually chopping those trees down.

/setblock is also extremely useful though I do have to admit that I don't use this command very often myself. Still.. let's say you're flying in the air and you want to start building something. How do you start? You can't just place a block in thin air, right? Well.. you can with this command: /setblock ~ ~ ~ minecraft:acacia_log. And voila, one acacia log block floating in the air. Now you can use that to place your other blocks against.

#4 F3

F3 can do a lot more than just showing the debug screen, it also gives you access to tons of extremely useful keyboard combinations. For example... You build this house in creative, you're working on the roof and now you want to check how things look inside. What do you do?

I suppose you could try using teleportation (/tp) but that only works if you either know the exact coordinates or if you know how many blocks you need to move. I suppose you can change gamemodes but having to type that entire command all the time is also bothersome, but do you really want to start looking for the door instead?

A much easier way is to press F3-n. So: press and hold F3, then press 'n'. This will switch you between creative and observer mode. So instead of having to go through a whole lot of trouble you can now simply fly into the house and look around. Fly back out, switch back to creative and you can continue building.

Another very useful combination is F3-c. This will copy your current location to the clipboard. So if you're busy while a user asks for your help then you can simply copy your location, teleport to them to help them out, and then paste in the command to teleport yourself back. Easy! (this is a new feature in 1.13 which I started using a lot).

There are many very useful commands available here, for a full overview press F3-q.

And now we're entering the dreaded top 3! :)

#3 /data

This command is in my opinion one of the best changes in Minecraft 1.13 because it unlocks options which we've never had before. That is: not using vanilla commands of course, I'm not taking mods or external software into consideration here. But this command is totally awesome.

Let's say that we're working on a villager farm and we need to know if a villager has enough items to breed (as you might know a villager needs to be 'willing' which can happen from trading or it having enough food in its inventory). So how do we check for this? We can't exactly ask what items it has. But we can check for this ourselves: /data get entity @e[type=minecraft:villager,distance=..5,limit=1] Inventory.

Well, seems we're getting there ;)

We caught a player cheating and because of that we're going to confiscate a chest which contains the items they illegally obtained. Only problem is that we're also helping out another player and our own inventory is kind of full right now, so using /clear isn't an option. Now what?

Simple: /data merge block -293 56 258 {Items:[]}, and the chest is empty. Maybe we should also check if the player has hidden any items in their enderchest: /data get entity @p[name=cheater,limit=1] EnderItems. And what do you know...

[17:51:07] [Client thread/INFO]: [CHAT] ShelLuser has the following entity data: [{Slot: 0b, id: "minecraft:chest", Count: 1b}]

Darn' cheater ;)

Fortunately we can also easily solve that: /replaceitem entity @p[name=cheater] enderchest.0 minecraft:air.

But basically; /data can be used to pretty much get any type of information about entities or specific block entities, and if we're not working on players them we can also use /data to change or set any kind of properties.

A friend and me both play on my LAN server and I wanted to give her a gift but without overdoing it (not giving something overly expensive because it would ruin her survival game). So I decided to place a loot chest, the same kind which can be found in a desert temple:
  • (while pointing at the chest): /data merge block 511 63 -287 {LootTable:"minecraft:chests/desert_pyramid"}
And presto: now the chest contains a random selection of items. Even I don't know exactly what's going to end up in there.

So a few days later I logged onto the server, my friend wasn't online, but I still wanted to know if she had already discovered the chest. And I discovered that she had indeed opened it. How? Easy: /data get block 511 63 -287. Instead of showing me a loot tabel entry I now saw several items in the chest, and that could only have happened after it got opened.

Ok, last example: need to rename a horse while you don't have a nametag on you? Easy:
  • /data merge entity @e[type=minecraft:horse,distance=..5,limit=1] {CustomName:"\"Mustang\"",CustomNameVisible:1}

#2 Target selectors

You've seen me using these quite a few times already, and if you're going to use commands yourself then you need to know about these as well:
  • @p - target nearest player.
  • @r - target a random player.
  • @a - target all players.
  • @e - target all entities (so: mobs & players alike).
  • @s - target / select the entity used in the current command (special use only).
Want to give a stone sword to a random player? Easy: /give @r stone_sword.

But of course there's more than this, you can also limit your selection to specific players or entities only. For example, if I want to check the tags on a group of animals but only those which are near me (say within 15 blocks) then I can add extra selectors: /tag @e[distance=..10] list. This would list all tags on all entities within 10 blocks away from me.

Maybe I only want to check up on the sheep, but those which are at least 5 blocks away from me but no more than 20 blocks? It'll be more typing but it's still quite easy:
  • /tag @e[type=minecraft:sheep,distance=5..20] list
Target selectors can help you to make all sorts of crazy selections. Selecting a random sheep? Easy: @e[type=minecraft:sheep,limit=1,sort=random].

Or maybe another fun example from my LAN server: My friend Aya has a treasure chest where she keeps some valuable stuff. Things like a trident, ores, iron & gold, etc. So: were we sure that mobs couldn't open chests? What if a zombie decided to peek in there? So I was asked if I could somehow set up an alarm system: whenever the chest got opened while she was not around then she should get a warning about that. All it took was one command:
  • execute if entity AyanamiKun unless entity @p[name=AyanamiKun,distance=..15] as AyanamiKun run title @s title {"text":"Treasure opened!", "color":"red","italic":"true"}
I'm not going to explain the whole selector setup in full detail because that would take a tutorial of its own, but selectors are extremely important when you're going to use commands more seriously. But this also brings us to the final command...

#1 /execute

Execute is pretty much the holy grail of Minecraft in my opinion because it gives you access to an insane amount of options, many commands from 1.12 have been merged into /execute making this an extremely versatile (but also somewhat complex) feature. You've already seen a small example in the previous item.

The command itself does what it implies: it executes a specific command, but also allows you to set specific conditions for those commands. That sounds really expensive so let's look at some examples.. The command I showed above has multiple conditions which need to be met: the command only runs if AyanamiKun is actually online and if she's more than 15 blocks away from the chest. When those conditions are met then the /title command gets run as if Aya were to run it, this means that she gets to see the eventual title (it's also why @s works).

Another example: you're busy in the End with some kind of project and a player who is busy in the Overworld asks if you can stop the rain. Because the End is just that you can't really use the /weather command here but you can in the Overworld. So you can simply use: /execute in Overworld run weather clear, and done. This same trick can also help you to teleport to another dimension without having to use any kind of portal: /execute in the_end run tp @s 5 70 5; this would teleport you to the End, right next to the End portal.

Maybe checking if there are any creepers around you: /execute if entity @e[type=minecraft:creeper].

Or maybe test to see if a player has a crafting table in their inventory? => /execute if entity @a[nbt={Inventory:{id:"minecraft:crafting_table"}]}]. Maybe we want to zap the players who meet this criteria:
  • /execute if entity @a[nbt={Inventory:{id:"minecraft:crafting_table"}]}] at @s run summon minecraft:lightning_bolt ~ ~ ~

All in all this is an extremely extensive command which can do pretty much anything, and therefor it's a must-know in my opinion.

And there you have it! 10 commands and tricks which I think are very useful to know about.

Create an account or sign in to comment.

Planet Minecraft


© 2010 - 2023