Vanilla Minecraft Tricks

November 20, 2013 by Noah
I run a couple of Minecraft servers, and I always prefer to run the default vanilla server as provided by Mojang - mainly because the custom servers like Bukkit always lag behind by weeks or sometimes months every time a new version of Minecraft is released, and partly because there's just way too many custom plugins for Bukkit, many of which do the same things in different ways while being incompatible with each other and it's a huge mess.

I liked the idea of some of Bukkit's plugins, though, so I'm always trying to find creative ways to get similar results using just the vanilla server. Here's a few tricks I figured out myself or heard about from Reddit.

Spawn Region Mechanics

Most of these tricks involve command blocks and understanding a few quirks about how Minecraft vanilla servers work.

Upon creating a new world, give yourself a compass and follow it to find the center of the world spawn region. I usually put a block here to visually remind myself where the center is, because the spawn region is important for a couple of reasons.

Firstly, the spawn region is always kept loaded in memory, along with the 5x5 chunk radius surrounding the spawn point (where a chunk is a 16x16 block section of the world). This is important because it means that if you set up any Redstone devices that run on a loop, they'll run all the time even if all the players wander far away from the spawn area. So it's a good place to incorporate command block circuits to enforce global "rules" on your server.

The other important thing is the spawn protection radius, which is the number of blocks around the spawn point (where the compass points) in which non-operator players are not allowed to place or destroy blocks, or interact with most items. By default the radius is set to 16 blocks, and is configurable in the server.properties file.

In the spawn protection radius, non-op players can't place or destroy blocks, and they can't use any devices except for pressure plates and trip wires. They can't even open or close wooden doors, they can't use crafting tables or furnaces, etc. Only the server operators have rights in the protection radius.

However, the protected area is not safe from monsters or outside interference, so for example if a player lures a Creeper into the spawn region it can still blow up blocks (unless you turn off mob griefing with /gamerule mobGriefing off, which prevents Creepers and other mobs from changing blocks). Clever players can also fling TNT in from outside the protected region to destroy blocks inside. When in doubt, encase your Redstone circuits in bedrock bunkers and keep them hidden away from view. ;)

Command Blocks

Clever use of command blocks can enforce "rules" on a server, for example if you want to ban the use of TNT, you can have a command block be executed very rapidly that removes TNT from all player inventories, by running the command /clear @a minecraft:tnt.

All your command block redstone circuits should use a clock circuit of some kind (one that will run in an infinite loop). Ideally, the circuit should be self-starting, especially if the circuit is NOT within the 5x5 chunk spawn radius. This is because when the chunks that contain a redstone circuit are unloaded, the circuit stops running, and when the chunks are reloaded (because a player walks closer to them), you want your circuit to automatically start back up.

See clock circuits for some ideas. An example I use is where you have a redstone torch that powers a circuit, and the circuit eventually extends a piston over an earlier part of the circuit to interrupt its own power. With the power interrupted, the piston retracts, allowing the circuit to be powered again by the redstone torch, and so on.

Griefer Protection

The easy way to prevent players from breaking your structures is to build everything important within the protected spawn radius. If you also turn off mob griefing, and use a command block to remove TNT from player inventories, it's highly unlikely they'll find a way to break things in the spawn region.

Outside the spawn region, a useful tip I saw on Reddit is to apply the Mining Fatigue V effect to all players within a certain radius of your building. For example, create a redstone clock near the middle of your building that runs a command block to run this command:

/effect @a[r=60,m=0] 4 3 5
This will apply an affect to all players (@a), who are within 60 blocks of the command block and who are in Survival Mode (m=0), the Mining Fatigue effect (ID 4), for 3 seconds, at level 5. Mining Fatigue level 5 basically makes it 100% impossible for the player to mine a block, even if they have a diamond pickaxe, even if it's enchanted. The player can't even break a flower under this condition.

The 3 second interval would be adjusted depending on how frequently your clock runs the command. You want it to only affect players while they're within the general area of your building, and lift the effect quickly if they leave.

Controlling the Spawn Location

In certain maps, you might like to have much finer-grained control over where exactly users on your server will spawn. In vanilla Minecraft, users will spawn somewhere within a 20x20 radius area centered around where the compass points. See Spawn/Multiplayer Details.

On one of my servers, I wanted all players to appear in the center of a room when they joined the server (or died without a bed) so that I could somewhat randomly disperse them around the world by having them pick a pressure plate that would teleport them somewhere. See my blog post "Fun with Command Blocks".

Basically, if you go this route, the actual world spawn point will not be used. Instead you'll just have a command block running on a clock that teleports anyone who appears in the spawn region to a destination somewhere else (you should make sure you teleport them far away from the spawn region, so that they'll be outside the radius of the command block that teleported them... otherwise you get caught in an infinite loop of teleportation!)

Example command for this command block to run:

/tp @a[m=0,r=25] X Y Z
Substitute X, Y and Z for the coordinates to teleport to. This command would snipe all users within a 25 block radius of the command block and teleport them off to those coordinates. Also make sure to include the "m=0" -- this will make it only teleport Survival Mode players away. This way, you (the operator) can switch your mode to Creative and be able to get close enough to the command block to edit it or whatever you need to do. But it will keep all the other players away by teleporting them to your designated "spawn location".

Adventure Mode

Adventure Mode might be considered for certain circumstances as a method of anti-grief protection. On one of my servers, I built a huge Parkour course in the End Dimension, and I hadn't heard about using Mining Fatigue V to prevent players from griefing the parkour course, and things in The End aren't protected by the world spawn region, obviously.

What I did was encased the End Dimension Spawn Platform in bedrock, with the only exits to either go back through the Exit Portal, or step on a pressure plate that would teleport them into the Parkour course (if somebody destroys the pressure plate, then nobody can get into the parkour course, but it's better than allowing them to vandalize the course itself).

The pressure plate would run a few command blocks - one would clear all their inventory with /clear, another one would change their game mode to Adventure with /gamemode 2 @p, and the last one would finally teleport them into the course.

A command block clock in the overworld would set all adventure mode players back to survival in case they died and respawned, with /gamemode 0 @a[m=2].

The thing to know about Adventure Mode, though, is that it's basically "Strict" Survival Mode. If a block requires a specific class of tool to break it (stone needs a pickaxe, wood needs an axe), then only that tool is allowed to be used. If you swing an axe at stone, or a pickaxe at dirt, then your player just swings once as if hitting air, and then nothing.

You don't necessarily need to use the right material of tool, just the right tool. For example Adventure Mode allows you to destroy obsidian using a wooden pickaxe, even though the wooden pickaxe won't drop the obsidian block. So for Adventure Mode to work, you basically need to remove ALL tools from their inventory.

Even without tools, blocks that can be broken by hand are still vulnerable. So avoid using glass, torches, flowers, redstone devices (including buttons) which are in reach of the player, etc., as they can break these without needing any tools at all.

Update (8/14/15): As of Minecraft 1.8, the Adventure Mode behavior has been changed. Briefly:

  • Players in Adventure Mode can't break or place **any** blocks by default, even if they have the correct tool (e.g. with a pickaxe, they can **not** mine stone blocks by default).
  • The exception is that items have new `CanDestroy` and `CanPlaceOn` tags, so for example you could `/give` an Adventure Mode player a pickaxe with a `CanDestroy:["stone"]` tag, and that pickaxe can *only* destroy stone blocks but nothing else that isn't explicitly listed in the `CanDestroy` tag.
So, Adventure Mode as a way to grief-protect an area is even better in Minecraft 1.8 because it stops them from being able to break anything at all, and you don't have to /clear their inventory either!

Helpful Links

Tags:

Comments

There are 36 comments on this page. Add yours.

Avatar image
ImmortalPvP posted on March 1, 2014 @ 06:45 UTC

I'm sorry, but i dont understand how to control griefing. Could you tell me step by step. (if you want)

Avatar image
Noah (@kirsle) posted on March 1, 2014 @ 06:47 UTC

I wrote a more detailed post about griefer control with command blocks here:

http://www.kirsle.net/blog/kirsle/minecraft-anti-griefing-in-vanilla

Avatar image
Harlem Burdett posted on March 10, 2014 @ 06:23 UTC

Do You No How To Do Setup The .spawn Things

Avatar image
Kate posted on May 14, 2014 @ 05:11 UTC

Any idea how to set up a couple of basic commands like .spawn or .sethome?

Avatar image
Henry posted on September 1, 2014 @ 16:59 UTC

use /setblock [x] [y] [z] minecraft:redstone_block 0 destroy for a redstone clock that goes of every second more than 2 times its the fastest clock ever no need for circuit!

Avatar image
Henry posted on September 5, 2014 @ 22:41 UTC

Oh and the x y z cords have to be touching the command block for instace ~ ~1 ~ or ~1 ~ ~ or ~ ~ ~1 and so on

Avatar image
Noah (@kirsle) posted on September 5, 2014 @ 22:54 UTC

That produces an insane number of redstone block item drops. Is there a way to do it that doesn't result in drops? (/gamerule doTileDrops false not being a good option)

Command: setblock ~1 ~ ~ minecraft:redstone_block 0 destroy

Screenshot

Avatar image
Noah (@kirsle) posted on September 5, 2014 @ 23:06 UTC

I found a way of doing this that involves two command blocks (I believe this is the way most people do it but I figured it out myself as well)...

It kinda exploits the order in which Minecraft processes command blocks, though, i.e. you have to put them in the correct order (X/Y/Z coordinates-wise).

You have two command blocks with one empty space between them, like

[X] [_] [X]

(the empty space can be vertical as well, probably)

One command block sets that empty space to be a redstone block; the other sets the space to be air (or, anything that's NOT a redstone block, maybe).

Like:

  • setblock ~1 ~ ~ minecraft:redstone_block 0 replace
  • setblock ~-1 ~ ~ minecraft:air 0 replace

Then place a redstone block between the two to start the process. If the redstone block you place disappears and never comes back, the command blocks are in the wrong order, and you should swap their commands (and be sure to fix the X/Y/Z coordinates to be opposites as well, in this example, the redstone_block uses ~-1 instead of ~1 and the same for the air block).

When it works, the redstone block appears to stay in place forever.

Like I said, this exploits the ordering in which the game processes command blocks. If the game ever switches order in a future update, or if they multi-thread the command blocks, this clock may break.

But basically, when you place the redstone block between the command blocks, you power both blocks at exactly the same time, but the game can't run both of their commands at exactly the same time, so it does them in a certain order (I don't know the order off-hand, but logically it would be, the block with the lower numbers in the X, Y, Z coordinates is run first).

So the first command block runs, and replaces the redstone block with air. Then the game still has to execute the other command block (since it was powered, even though "now" it isn't), and this block puts the redstone block back where it was originally. End of game tick.

Then the game's like, "oh, redstone block here, power the command blocks! First one, then the other" and so on.

If the blocks are in the wrong order (i.e. the one that replaces with redstone runs first).... player places Redstone, command block 1 puts Redstone there (no net effect), command block 2 puts Air there. End of tick. Now there is no redstone block, and the command blocks don't get run again.

Avatar image
Steve Digs posted on October 13, 2014 @ 17:18 UTC

I use this for clocks too. But I replace stone instead of air so I can turn the commands on and off easy when testing. Just break the redstone and the updating stops. Put a stone block back and it starts again.

Clock top: /fill ~ ~-1 ~ ~ ~-1 ~10 redstone_block 0 replace stone Clock Bottom: /fill ~ ~1 ~ ~ ~1 ~10 stone 0 replace redstone_block

This makes a 10 block long clock in the +Z direction

Avatar image
PDXTony posted on October 27, 2014 @ 18:47 UTC

The server processes command blocks along the x axis
first then y axis highest to lowest. (this is in reference to the commandblock clock mentioned in the post. which is very handy since it eliminates block/chunk updates and reduces lag)

Avatar image
Angie posted on November 18, 2014 @ 16:20 UTC

We're running a vanilla build, 1.8, on a linux host, in creative only.. for a group of young crafters. How can I offer the players the option to protect their creations from damage from the inexperienced/etc, without modding?

Thanks in advance!!

Avatar image
Steve Digs posted on November 18, 2014 @ 17:27 UTC

Without mods I think the only way would be to turn the server into survival or adventure and then give creative mode at assigned areas. Each player would have an area for creative mode and when outside of that switch to a different mode. /gamemode 1 @p[r=30,name=Steve_Digs] Or, all players but one get switched to adventure mode in a specified area. /gamemode 2 @a[r=30,name=!Steve_Digs]

Avatar image
LOLOLOL posted on November 27, 2014 @ 16:46 UTC

Put this command in a command block (above ground)

/setblock ~ ~ ~ mob_spawner 0 replace {EntityId:Zombie,SpawnRange:6,RequiredPlayerRange:12,SpawnCount:1,MaxNearbyEntities:6,MinSpawnDelay:100,MaxSpawnDelay:600,SpawnData:{Equipment:[{id:268,Count:1},{id:301,Count:1}{id:300,Count:1,tag:{display:{color:5013401}}},{id:299,Count:1,tag:{display:{color:6717235}}{id:397,Count:1,Damage:3,tag:{SkullOwner:}}]},SpawnPotentials:[ {Type:Zombie,Weight:4,Properties:{Equipment:{id:268,Count:1,Damage:58},{id:301,Count:1{id:300,Count:1,tag:{display:{color:5013401}}},{id:299,Count:1,tag:{display:{color:6717235}}{id:397,Count:1,Damage:3,tag:{SkullOwner:}}]}}, {Type:Skeleton,Weight:2,Propertie{Equipment:[{id:267},{id:301,Count:1,tag:{display:{color:1644825}}},{id:300,Count:1,tag:{displa{color:1644825}}},{id:299,Count:1,tag:{display:{color:1644825}}},{id:397,Count:1,Damage:3,ta{SkullOwner:}}]}}, {Type:Zombie,Weight:4,Properties:{Equipment:[{id:272,Count:1},{id:305,Count:1},{id:304,Count:1}{id:303,Count:1},{id:397,Count:1,Damage:3,tag:{ench:{id:0,lvl:2}],SkullOwner:}}]}}, {Type:Zombie,Weight:4,Properties:{Fire:2400,Equipment[{id:283,Count:1,tag:{ench:{id:20,lvl:1}]}}{id:317,Count:1},{id:316,Count:1},{id:315,Count:1}{id:86,Count:1,tag:{ench:[{id:0,lvl:2}{id:1,lvl:10}]}}]}}, {Type:Zombie,Weight:4,Properties:{Equipmen[{id:267,Count:1,tag:{ench:{id:16,lvl:2}]}}{id:309,Count:1},{id:308,Count:1},{id:307,Count:1}{id:397,Count:1,Damage:3,tag:{ench[{id:0,lvl:2}],SkullOwner:}}]}}{Type:Zombie,Weight:1,Properties:{Equipment:[{id:278,Count:1,tag:{ench:{id:16,lvl:4},{id:17,lvl:4{id:18,lvl:4},{id:21,lvl:3},{id:34,lvl:3}]}},{id:313,Count:1,tag:{ench:[{id:1,lvl:4},{id:2,lvl:4}]}}{id:312,Count:1,tag:{ench:[{id:3,lvl:4}]}},{id:311,Count:1,tag:{ench:[{id:0,lvl:4}]}}{id:397,Count:1,Damage:3,tag:{SkullOwner:,ench:[{id:0,lvl:4},{id:1,lvl:4},{id:3,lvl:4}{id:5,lvl:3},{id:6,lvl:1}]}}],CustomNameVisible:1,CustomName:Herobrine,PersistenceRequired:1}}, ]}

Activate the command block with a button

Avatar image
Anonymous posted on December 19, 2014 @ 00:16 UTC

How do i have the command block keep the command after i break it??

Avatar image
Noah (@kirsle) posted on December 19, 2014 @ 00:22 UTC

You don't. The command block item (in your inventory) doesn't keep its NBT tags. Those are only for the placed block.

Avatar image
captainbuildit posted on February 6, 2015 @ 03:14 UTC

Can i join your server? I just started my own vanilla one too. Your tips work and i love them!

Avatar image
Jeff posted on February 14, 2015 @ 09:31 UTC

What's the command for this;;

Your making a custom map. It's in survival/ adventure. You don't want to have that people are cheating with their gamemode. Whats the commandblock(s) command(s) for that if people say; /gamemode 1 / /gamemode creative ?

Avatar image
ThunderBear21 posted on March 4, 2015 @ 18:10 UTC

Curious how to keep players from placing blocks in the pseudo spawn area. I have them spawn going to one point and they can't break blocks. But they can still place blocks.

Any Ideas???

BTW this is the most helpful site for vanilla. Thanks

Avatar image
Noah (@kirsle) posted on March 4, 2015 @ 19:02 UTC

In adventure mode players can't place blocks either, unless the block item has an explicit CanPlaceOn flag set.

Edit: as of Minecraft 1.8

Avatar image
ThunderBear21 posted on March 6, 2015 @ 00:06 UTC

Kisle,

I can change them in and out of adventure mode but how do I include or exclude groups such as staff??? We are already using scoreboard and that only allows for players to be on one team I think.

Thunder

Avatar image
Noah (@kirsle) posted on March 6, 2015 @ 00:12 UTC

You might be able to use scoreboard objectives and apply those to the individual players rather than teams.

/scoreboard objectives add staff dummy Staff
/scoreboard players set <name> staff 1

Repeat the second command for each staff user.

And in the command block selector,

/gamemode 2 @a[r=30,score_staff_min=1]

Avatar image
Lol posted on April 6, 2015 @ 04:16 UTC

I love you

Avatar image
Hi I'm not saying my name, ok? posted on May 12, 2015 @ 21:10 UTC

I created total LAG!!!!!!!!! Created a block made of anything you want and seirowd it with tnt an put the command in the command block and put an iron door in front of the presser plate and Derum role plz? guess what... LAGGGGGGGGGGGGG!!!!!!!!!!

Avatar image
Benji_does-MC posted on May 26, 2015 @ 15:13 UTC

i cant use any command in a world in multiplayer

Avatar image
Noah (@kirsle) posted on May 26, 2015 @ 15:47 UTC

On multiplayer you have to be a server operator to use command blocks (because you have to be an op to use commands at all).

Avatar image
MC ruler posted on June 18, 2015 @ 07:01 UTC

Kirsle

Im making a server and what is the command to welcome someone to the server with their name in the message so everyone knoes that they're online. I want the message to go to everyone

Avatar image
Heibel posted on June 24, 2015 @ 13:27 UTC

Well, this page was named "Vanilla Minecraft Tricks" so i was wondering if you can give me a hand on particicles, (like having it revolving around players, out of blocks, and such)

Avatar image
Ryo Stonewell posted on June 30, 2015 @ 03:33 UTC

hi, I was just wondering, is there a command that you can use, either with comm blocks or after pressing / that makes certain or all entity names permanently visible no matter where you look or how far away you are? of course, I'd like to have them fade the further away you get, as I'm assuming this may reduce lag.

Avatar image
Thejs posted on August 10, 2015 @ 14:46 UTC

My world burn - how can i remove the fire for a second?

Avatar image
Guest posted on August 14, 2015 @ 18:08 UTC

is there a way to make it that when a player spawns on LAN it activates redstone (to set of a title)

Avatar image
Noah (@kirsle) posted on August 14, 2015 @ 19:35 UTC

You could do that on their first spawn by using scoreboard objectives. Something like...

1) Make a dummy objective named "spawned" or something:

/scoreboard objectives add spawned dummy Spawned

2) Make a redstone clock at your spawn area that repeatedly powers a command block that checks for users that don't have this point:

testfor @a[!score_spawned=1]

When this command block's output is true (i.e. it detected a player whose "spawned" score is not 1), the block itself will output a redstone signal.

3) On the other side of the block (away from the side that gave it power), run some redstone dust over a couple more command blocks:

  • tell @a[!score_spawned=1] Welcome to the server!
  • scoreboard players add @a[!score_spawned=1] spawned 1

These blocks would show the welcome message to the newly spawned user and then set their spawned score to 1 (so that the command blocks won't match that user again in the future).

This all will cover newly joining players who connect for the first time. If they return to the same server later, they'll still have the spawned=1 score and not be greeted again (there isn't an "on spawn" handler you can use directly, so messing with scoreboards is the only way to do this afaik).

There's also statistics you can try, but none are very useful for this... the best being stat.timeSinceDeath which resets every time the player dies and presumably begins at 0 when they first spawn... but you'd end up showing the welcome message on every respawn even after dying.

Relevant links:

Avatar image
Halobot posted on August 19, 2015 @ 14:02 UTC

How do you attach a command to a certain key on your computer so that you can press that button to activate the command

Avatar image
Des posted on August 24, 2015 @ 20:33 UTC

How do you keep from hackers?

Avatar image
DJ_ALI posted on September 12, 2015 @ 04:41 UTC

hahahah. I learn this from a site: (i forgot the site XD) if you want to make an adventure map that no one can cheat in it when you are creating the world dont allow cheats and keep gamemode 0. once you entered new world go open to lan allow cheats on and start and now you can cheat and make your map and at the end go to default gamemode and restart your map and it will disallow cheats again I HOPE IT HELPED but other players can cheat in your map in the same way lololol

Avatar image
EnderCube posted on October 5, 2015 @ 19:45 UTC

To protect the spawn from tnt cannons use a command block who kill any ignited tnt entity with a radius. Also kill creepers To counter hackers use a command block to teleport players with more than a certain flying score, (reset it when the player jump) to an encased bedrock jail and set his spawn point there, give them a special objective dummy and make a command to teleport them back(clock) because hackers can scape. Then when you log in just ban them. Search for anty fly hack in google For anti pvp at spawn use potion effects: resistance 4 and weakness 4. Trick: the fastest way to execute two command blocks at the same time is powering one and placeing the other above

Avatar image
dreamstar3193 posted on November 18, 2015 @ 04:00 UTC

pigs

Add a Comment

Used for your Gravatar and optional thread subscription. Privacy policy.
You may format your message using Markdown syntax.