Kirsle.net logo Kirsle.net

Minecraft Anti-Griefing in Vanilla

February 13, 2014 by Noah
This is a trick I picked up somewhere from /r/Minecraft that lets you implement anti-griefing on a 100% vanilla Minecraft server.

It requires you to have operator rights on the server, and it involves command blocks. Give yourself a command block by typing the command /give your_name command_block, and place it somewhere in the center of the area you don't want being griefed. I usually will hide it just below the ground, or in a small hidden-away room in the middle of a building or something. Right-click it, and enter this command:

effect @a[m=0,r=36] 4 2 5 true
When activated, this command will apply a status effect to all Survival Mode players (m=0), within a radius of 36 blocks from the command block (r=36). The effect will be Mining Fatigue (effect ID 4), level 5, which will last for 2 seconds. The word "true" at the end will hide the particle effects (supported in Minecraft 1.8+; for older versions, remove the word "true" from the command). See Status effect on the Minecraft wiki for details.

Mining Fatigue slows down the player's mining speed by 20% per level, so at level 5 your speed is slowed by 100%. What this basically means is that nobody can break anything while under Mining Fatigue 5. You can't even break a dandelion using a diamond axe. It makes the area completely grief-proof.

Adjust the radius to however large you think you'll need to cover the entire area you want protected. If the area is very large (i.e. so that the command block might end up being unloaded from memory when its chunk goes away), you'll need multiple command blocks positioned around the area to make sure the Mining Fatigue is still in effect.

Anyway, now you just need to hook up the command block to a redstone clock so that it's triggered repeatedly. My favorite is to just use a hopper clock. A comparator clock has too fast of a pulse and the command block will never be executed.

With a hopper clock, just place two hoppers that connect to each other. For example, place a normal block like stone, and then with a hopper, right-click on the side of the stone block so the bottom of the hopper connects to the side. Remove the stone block, go to the side where it used to be, and hold down Shift and right-click the hopper to attach the second one.

Edit for 1.8: It seems the timing has been changed in hoppers on Minecraft 1.8, and a two-hopper clock is "too fast" and won't trigger the command block repeatedly (it will trigger it one time and then never again). Instead of using 2 hoppers that feed into each other, you can use 4 hoppers that feed in a circle, each one connecting to the next one. This slows down the rate that the command block gets executed by 50% but it still works in Minecraft 1.8.

Put a single item into one of the hoppers. If it worked, the item should disappear from the hopper's GUI and then reappear shortly after; the item is being passed back and forth between the hoppers. Now, pick one hopper and put a comparator and then a repeater next to it. Whenever this hopper has the item, the comparator will get a signal and the repeater will amplify it. And there you go. Here's a screenshot of the full setup:

Hopper Clock

What about creepers and endermen?

Even if you prevent players from destroying blocks manually, they could still lure a creeper in and cause it to explode and damage the nearby blocks. In Minecraft 1.8+ you can select entities by type using command blocks, so you may wanna add some more command blocks to killl any creepers or endermen that get too close (the endermen are optional, but if your build involves a lot of natural blocks like dirt and sand you may wanna keep them away too):

Creepers: kill @e[type=Creeper,r=36]
Endermen: kill @e[type=Enderman,r=36]

You may also be able to do the same for the `PrimedTnt` entity but that may be trickier considering the speed at which TNT can be launched. You'd need a particularly fast redstone clock to keep up.

Tags:

Comments

There are 68 comments on this page. Add yours.

Avatar image
Mitch posted on April 20, 2014 @ 21:32 UTC

Thank you for this very helpful and informative article. I used this method in a mob arena on a personal server (Only 2 to 3 people) and it works phenomenally. Keep up the good work, kirsle.

Avatar image
K0demonkey posted on July 22, 2014 @ 18:28 UTC

I am trying this on a 1.7.10 server and cannot seem to to get it to work.

I have your hopper clock working, but I cannot get the effect to work.

I also want it to apply to everyone, but the owner of the building.

Should this work?

/effect @a[r=15,m=0][name=!PLAYERNAME] 4 3 5

Where PLAYERNAME is the owner of the building.

Avatar image
Noah (@kirsle) posted on July 22, 2014 @ 18:47 UTC

To make sure the command block is working, just put a button on it and push it. If a redstone clock is too fast (i.e. so the redstone signal stays lit constantly) it won't keep reactivating the command block, so if that's the case, fix your clock. ;)

I don't think you can select players by name, however you could set up scoreboard teams for each player (if you aren't already using teams for something else on your server), i.e. where $USERNAME and $TEAM_NAME are the same value:

/scoreboard teams add $USERNAME
/scoreboard teams join $TEAM_NAME $USERNAME

Then your command block could do,

/effect @a[r=15,m=0,team=!USERNAME] 4 3 5

If you are already using teams for something else, you can accomplish the same with objectives.

/scoreboard objectives add $USERNAME dummy
/scoreboard players set $USERNAME $USERNAME 1

Then the username (i.e. caskir) would have a caskir score set to 1, and repeat for all users you want to set up anti-griefing areas for.

Then the command block (untested, might work, if not try score_$USERNAME=0):

/effect @a[r=15,m=0,score_$USERNAME=!1] 4 3 5

Avatar image
Eric posted on July 23, 2014 @ 20:54 UTC

"/effect @a[r=15,m=0] 4 60 5" should work, replace the 60 with however long you want the effect to last. To stop the owner from getting the effect, do "/effect OWNER 4 0" 1 tick later (repeater right after)

Avatar image
Mactso posted on August 7, 2014 @ 07:53 UTC

This was VERY helpful.

I've built a large (biome scale!) labyrinth and was looking for a way in vanilla to prevent digging besides bedrock.

I'm using a slow hopper clock with a long effect time.

i.e. 40 second pulse (6 bones in one hopper set and about 50 in the other) /effect @a[r=80] 4 240 5

I started with r=36 but realized it probably has less load with one large area and one clock instead of smaller areas and many more clocks.

I also send flavor messages from a linked command block about feeling weary.

something like. /msg @a[r=80] You feel weary.

Thanks! This was AWESOME.

Avatar image
_Ladyhawk_ posted on September 11, 2014 @ 19:25 UTC

This was very helpful! Thank you :) We are building a rather large spawn city in our server, a place where players can hang around. The downside is that we get console spammed by the command block messages :(

Avatar image
Noah (@kirsle) posted on September 11, 2014 @ 19:46 UTC

To cut back on command block spam:

  • /gamerule commandBlockOutput false will hide command block output in-game
  • /gamerule logAdminCommands false will hide command block output in the server console. It will also hide other admin commands (i.e. when a user changes their own game mode, etc.) though.
Avatar image
_Ladyhawk_ posted on September 11, 2014 @ 19:59 UTC

Thank you so much! It worked :D Command Blocks are very new to us. We have used plugins for everything until this last update. It's been exciting learning more about what we can do with them. Again, thanks for your help and fast reply :)

Avatar image
Krowerom posted on September 11, 2014 @ 20:03 UTC

Thanks kirsle, that is really useful :)

I used the co-ordinates to define the area rather than radius, and as myself and Ladyhawk are 'mods' we are the only people in a team, so:

/effect @a[x=100,y=40,z=100,dx=100,dy=70,dz=100,team=] 4 3 5

sets a 100x70x100 box starting at 100,40,100 and anyone not in a team gets the mining fatigue. And now we don't get spammed with people going afk at spawn :P

Avatar image
djmatt3 posted on November 16, 2014 @ 13:42 UTC

For the tnt issue you can set up a fill clock which runs really quick of command blocks and redstone blocks, you'll have to google it though as i've only heard of it.

Avatar image
Angie posted on November 18, 2014 @ 19:54 UTC

Is there a way to establish this for specific dwellings and then add owners?

I have a server with a group of kids/new crafters. I'm trying to generate a solution much like what bukkit offers through WorldEdit / WorldGuard, without modding Vanilla.

These kids are so new they unintentionally break stuff all the time. I want to give each of them an area that is theirs to craft, but is protected from all other players. Eventually, I'll also create community areas and protect them from all players, but first, I need to help the players protect their dwellings from each other.

Avatar image
Noah (@kirsle) posted on November 18, 2014 @ 20:27 UTC

Some ideas:

  • Make the server's game mode set to Adventure by default (gamemode=2 in server.properties) which will prevent players from creating/destroying blocks in general except in their designated areas.
  • As the server admin you can build out community areas and railroads to connect each person's area so they can find their way around but they can't break anything in the community areas.
  • Give each person an area where they get creative mode upon entering, and are switched back to adventure mode when they leave.

Assuming each person gets a large area (several chunks big), it'd probably be a good idea to keep the command blocks that enforce the game modes within the spawn chunks of the server. Use a compass and go to the spot that the compass points to, to find the center of the spawn region.

The 5x5 chunk radius (about 80x80 blocks) around the spawn point is always loaded in memory, so redstone circuits will always run here even if nobody is around. You can dig out a "bunker" underground to put all your command blocks and redstone clocks.

Command blocks can't select players by name (afaik), but it can select them by team. So you can create one team for each player and assign them to it with these commands:

  • /scoreboard teams add <team_name>
  • /scoreboard teams join <team_name> <player_name>

So for example to make a team named "caskir" for the player named "caskir":

  • /scoreboard teams add caskir
  • /scoreboard teams join caskir caskir

As a bonus, you can assign a color to a team, and the players will have their name appear in that color (both above their head and in the player list when you hit Tab), example, /scoreboard teams option <team_name> color light_purple - more info on the Scoreboard wiki

For each area you want to assign to a person, use some command blocks along these lines (I'm using the team/player name caskir in these examples):

  • /gamemode 1 @a[team=caskir,r=60,x=123,y=60,z=123]
  • /gamemode 2 @a[team=caskir,r=80,rm=60,x=123,y=60,z=123]

The first command will set the player into Creative Mode when they're within 60 blocks of the coordinates 123,60,123 (you'd have to find and write down the X/Y/Z coordinates of the center of each area in advance). The second command will set the player's game mode to Adventure when they're at least 60 blocks away from that coordinate (actually, within a ring that's between 60 and 80 blocks away).

So when they approach their area they're put into Creative and when they leave they're put into Adventure.

To allow multiple people to share the same creative area, just add extra command blocks that do the same commands but with the other person's team.

The command block that puts them into Adventure mode uses a "ring shape" radius (minimum 60 blocks, maximum 80 in this example), so that you can allow the same player to have creative mode in more than one area as long as the outer perimeters don't overlap. In this example there's a 20 block width zone around the area where they'll be switched to adventure mode (if they're not already) when leaving the area. Note that if they teleport out or use a Nether Portal to leave their creative mode area, it will be more difficult to manage their game mode (you may want to disable the nether on your server, or restrict players from being able to hold a Flint & Steel so they can't light their own portals).

Remove nether portal ingredients from player inventories:

  • /clear @a flint_and_steel
  • /clear @a obsidian
  • /clear @a lava_bucket

Removing just the Flint & Steel and Obsidian isn't necessarily enough, cuz a crafty player could build the portal by molding it (make a frame out of dirt, fill with lava, pour water over...) and then light the portal by using wood planks and lava so they catch fire and eventually spread to light the portal. ;)

Avatar image
Angie posted on November 18, 2014 @ 22:21 UTC

The kids are building their world, I am not. I don't think they'd be very happy with me if I stripped them of their ability to create their world as they see fit. ;)

I just want to give them a way to protect their own dwelling from others who have no clue what they're doing and just mash stuff.

Avatar image
Noah (@kirsle) posted on November 18, 2014 @ 22:31 UTC

If everyone has creative mode, there's nothing you can really do in vanilla Minecraft to prevent people from messing with each other's stuff.

The only way to prevent blocks from being changed is by putting players in Adventure Mode, or using Survival Mode w/ the Mining Fatigue 5 effect.

They might be able to flip it backwards, have everyone with Creative Mode by default and switch them into Adventure when entering an area they don't "own", i.e. /gamemode 2 @a[team=!caskir,...] would select all players who aren't on that team. If the players all have operator rights though, they can switch their own teams around and get past any such restrictions.

Maybe just take regular world backups and tell everyone to play nice. If somebody does blow up the world, restore from a backup.

Avatar image
Angie posted on November 18, 2014 @ 22:38 UTC

They're 6, 7, and 8 year olds...

I saw this vid and wonder if I could (what you're saying above) just somehow visit each player's "home" (there are about 20 so far) and set it so that only that player can mod within the radius. I am happy to use a flip to Adventure, or even tp them back out, but the kids like showing each other what they build, they just don't like the bull in the china shop syndrome.

https://www.youtube.com/watch?v=0xBjxgzkiT0

I'm not well versed in the syntax, however, and don't know how to set exemptions. I'd be happy with protecting each of their dwellings as the OP and exempting just that particular player for that zone. Is this possible? If so, what's the command syntax please.

Avatar image
Noah (@kirsle) posted on November 18, 2014 @ 23:02 UTC

That video's doing basically the same thing we've been talking about. Switches players into Adventure Mode and applies Mining Fatigue + Haste when they get close to the building, and puts them back in Survival when they leave.

If you're the only OP on the server, some other ideas:

  • Default game mode is Survival, they can build/destroy in the community areas if they want.
  • Set up areas for each person, where anybody except the owner (and other whitelisted people) are switched to Adventure Mode upon entering (see my previous posts above).
    • In Minecraft 1.8, Adventure Mode is more restrictive than in 1.7, making it so players can't break anything at all, including redstone and torches and other weak blocks. So, per that YouTube video, using the Mining Fatigue + Haste is unnecessary because Adventure Mode players can't affect blocks anyway. They also can't place blocks.
  • You could set up a little "device" in each area to let the owner of the area switch themselves back and forth between Creative and Survival.

The device could just be a couple command blocks with buttons attached, with commands like:

  • /gamemode 1 @a[name=whatever]
  • /gamemode 0 @a[name=whatever]

Alternatively, you can have creative mode be switched on by default for the owner whenever they enter their area, and turned off when they leave. In that case, these are all the commands you'd need for each area:

  • Keeping outsiders under control:
    • Adventure Mode when entering: gamemode 2 @a[name=!owner,r=60,x=123,y=60,z=123]
    • Survival Mode when exiting: gamemode 0 @a[name=!owner,r=80,rm=60,x=123,y=60,z=123]
  • Giving the owner creative only for their area (2 command blocks per whitelisted person):
    • Creative Mode when entering: gamemode 1 @a[name=owner,r=60,x=123,y=60,z=123]
    • Survival Mode when exiting: gamemode 0 @a[name=owner,r=80,rm=60,x=123,y=60,z=123]

If using a game mode toggle device for the area's owners (instead of automatic creative mode), you'd just want a command block to set them back to survival in case they leave their area so they can't take their creative mode with them:

gamemode 0 @a[name=owner,r=80,rm=60,x=123,y=60,z=123]

Avatar image
Angie posted on November 18, 2014 @ 23:10 UTC

Will these suggestions work if I substitute Creative for Survival... So, I make it so that all but the owner of the area are switched to adventure while within the radius, and then when they depart, they're flipped back to creative.

I've tested the Adventure mode and, for the current skill levels anyway, if it doesn't prevent harm, it will deter effectively.

Most of the crafters are brand new, only a few can really read, and they're just playing/building.

Avatar image
Noah (@kirsle) posted on November 18, 2014 @ 23:15 UTC

It should work if the default game mode is creative too.

If they're flying really high in creative and enter somebody else's area though, they'll fall to their doom when they get switched to adventure. ;)

That part could probably be mitigated by giving effect buffs to adventure mode players (this could be centralized at the world spawn point to universally apply to adventure mode players)

  • /effect @a[m=2] 11 2 5 true

This would give adventure mode players Resistance V (Resistance reduces damage taken by 20% per level, so at level 5+ it makes them completely invincible except for the /kill command or falling into the void) for 2 seconds at a time (a redstone clock can make sure to run the command quickly enough that the 2 seconds won't expire for as long as they stay in adventure mode).

Avatar image
Angie posted on November 18, 2014 @ 23:19 UTC

Oh, yes indeed, it does!! Thank you so very much. This is perfect. Instead of Survival, we'll just flip/flop them from C to A and all is wonderful. :)

You have a new, devoted follower. Thank you for your time and assistance.

Avatar image
Angie posted on November 18, 2014 @ 23:21 UTC

What is the rm= setting?

Avatar image
Noah (@kirsle) posted on November 18, 2014 @ 23:23 UTC

It specifies a minimum radius. Target selector arguments

So if you combine r and rm (i.e. r=20,rm=10) it only targets players between 10 and 20 blocks away. If you use rm without r, it will target players at least X blocks away but with no maximum radius (if you want people to have multiple areas, don't do this cuz it will conflict with their other areas).

Avatar image
Angie posted on November 18, 2014 @ 23:27 UTC

Awesome. Thank you. Really.

Really! I've been fighting with this for three days, trying to keep the kids from wreaking havoc on each other without even realizing it. They're from all over and just having a blast.

Avatar image
Angie posted on November 19, 2014 @ 03:06 UTC

Well, ok.. SO, maybe it doesn't work.

If I set the command as you mentioned -

Keeping outsiders under control: Adventure Mode when entering: gamemode 2 @a[name=!owner,r=60,x=123,y=60,z=123]

Survival Mode when exiting: gamemode 0 @a[name=!owner,r=80,rm=60,x=123,y=60,z=123]

If I enter the first command, followed by the second command, everyone suddenly is in Adventure, and they never return to Creative until I change the gamemode for the entire world back to Creative.

What am I missing?

This idea you mentioned (copied below) sounds like what I thought I was doing (minus teams - or with teams, and set all to creative, and yes, I'm the only OP), and exactly what I need, but I (once again) don't know enough yet to know the syntax, or how to implement. Can I just input the commands? Do i have to utilize command blocks?

Good grief.. and I was so sure I had it figure out.

Avatar image
Noah (@kirsle) posted on November 19, 2014 @ 03:37 UTC

The command blocks are needed for the whole thing to be automatic. You could just type the commands, but it wouldn't be automatic then. ;)

Adventure mode when entering: gamemode 2 @a[name=!owner,r=60,x=123,y=60,z=123]

Sets gamemode to 2 (adventure) for all players that:

  • Aren't named "owner"
  • Are within a 60 block radius of coordinates X=123, Y=60, Z=123.

Survival mode when exiting: gamemode 0 @e[name=!owner,r=80,rm=60,x=123,y=60,z=123]

Sets gamemode to 0 (Survival) for all players that:

  • Aren't named "owner"
  • Are at least 60 blocks away, but not further than 80 blocks away, from coordinates X=123, Y=60, Z=123.

So, assuming a given player (not "owner") is far away from 123,60,123 when the command blocks start running (say they're at coordinate 700,60,700), nothing would happen to them each time the command block runs.

As they walk closer to 123,60,123 (the center of the affected area of the command blocks)...

  • When they get 80 blocks away (say, 43,60,123), their game mode would be getting set to Survival (which it probably already is anyway)
  • When they get closer, say 59 blocks away (64,60,123) their game mode would be set to Adventure.
  • They can continue walking towards 123,60,123 and their mode is constantly set to Adventure (nothing appears to change for them).
  • Suppose they walk 60 or so blocks past the center (184,60,123), their game mode starts getting set to Survival because they're within the 20 block margin between 60 and 80 blocks away.
  • They walk even further (more than 80 blocks), they're in survival and the command blocks are no longer doing anything because they're too far away.

So the main thing is to make sure the X, Y and Z coordinates are right. You can hit F3 to open the debug screen and see the coordinates of where your character is currently standing. I've just been using 123,60,123 as an example (Y=60 is about the average surface height in a Minecraft world).

Avatar image
Angie posted on November 20, 2014 @ 15:29 UTC

Ok, that makes sense.

Would I be better to use command blocks with hoppers, or some other configuration. And either way, the attempt at it I have already conducted doesn't cause it to run in a loop and I don't know what I'm missing.

Currently, I have tried two command blocks, one set with the "entry" into area and the other, the "exit". I have two hoppers, filled with redstone, and a comparator for each command block. They're touching and in the position I've seen on videos. BUT, it's as if I need another source/clock/mechanism to keep the commands executing.

Avatar image
Manda! posted on November 20, 2014 @ 16:11 UTC

My kids have started playing Minecraft with friends but one of the friends thinks its really funny to dig the ground out from below them so that they die leading to :'(

Is it possible to apply fatigue to bedrock for example? I can apply fatigue to cows (!!) but can't find the correct syntax/codes for bedrock...any ideas?

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

Ugh...

I can get the command block to activate to set the player that isn't the owner to adventure when they enter the radius, but when they leave the radius, they don't switch back..

If I can send a screenshot of the command blocks, maybe that would clear it up?

Thanks for any help.

Avatar image
Noah (@kirsle) posted on November 20, 2014 @ 19:23 UTC

Some other things to try will be to play around with the radii. Maybe the "60 block radius for the inner circle, 60-80 radius for the outer" are too close to each other and they conflict.

One other thing I just thought of, Redstone circuits only work while the chunks they're in are currently loaded by the server (depending on the server render distance I think). So if the area you're protecting is really large and it has its own command blocks inside for managing these things, then it'd be possible that the outer reaches of the area are too far away from the redstone/command blocks and they get unloaded from memory and thus stop working. If that's the case, it'd be better to centralize all the command blocks within the spawn chunks (5x5 chunk area around the center of the world spawn point, which can be found by using the compass).

As for the hopper clock issue, I mentioned in an edit to the original post above that Minecraft 1.8 changed the timing, and a 2-hopper clock is too fast and won't keep activating the command block repeatedly (you can test it by making the command block run a say command, and see if your chat screen gets spammed by it, or have it do something else equally visible like kill all zombies and then spawn some zombies and see if they get killed immediately, etc.), so in 1.8 you'd want to add more hoppers. I use 4 hoppers that all feed into each other in a circular shape.

Avatar image
Angie posted on November 20, 2014 @ 19:39 UTC

The way I have it set up, with levers, if I actively switch the lever it will take the player that isn't the owner, if within the radius, to adventure. However, if I have that player leave the area, then even if I toggle the lever, it doesn't switch them back.. It's like one way yes, the other no, and automatic - not even close.

I have the block configuration setup with just a few blocks from spawn, and the "dwelling" I'm protecting is probably withing 50 blocks of spawn.

Avatar image
Angie posted on November 20, 2014 @ 19:42 UTC

Commands currently being used:

gamemode 2 @a[name=!Cccgz,r=10,x=31,y=114,z=-42]

gamemode 1 @a[name=!Cccgz,r=13,rm=10,x=31,y=114,z=-42]

How to face with 4 hoppers in a circle? I can't honestly tell whether I have them facing in the right direction - don't know what to look for.

Avatar image
Noah (@kirsle) posted on November 20, 2014 @ 19:47 UTC

So the examples I've been using all have a certain ring radius where it switches their game mode back to adventure. If they're so far away that they're not in that ring they won't be switched back.

If everyone gets exactly one area to have creative mode, you can change the adventure mode command block to simply have a minimum radius and affect all players outside that radius, no matter how far away they are (this will also catch people who escape into the Nether and come back to the overworld far away. They'll probably retain creative mode while in the Nether but when they come back they'll be put into adventure mode if they're outside that radius).

gamemode 2 @a[name=!owner,rm=50,x=123,y=60,z=123]

That would catch all players 50+ blocks away from 123,60,123.

The other examples with having a minimum and maximum radius are for if you want one player to have creative mode in more than one area. Using a minimum-only one like ^ above would cause conflicts between the two areas (i.e. say they have one base at X/Z 600,600 and one at 200,200 and each one has a 50 block radius... well if they're at 200,200 then they're at least 50 blocks away from 600,600 so their game mode is being set to Adventure by 600,600 and Creative by 200,200.. it would lead to unpredictable results).

It may help to experiment with a simple superflat map and try to plot the points that the command blocks should affect (like put a wool block in the center of the area, put one 50 blocks away, then one 60 or 70 blocks away (these two blocks would be the inner and outer radii of the adventure mode ring) and figure out what's going on. A player standing between the 50 and 60 block wool blocks should be set to adventure mode.

Avatar image
Angie posted on November 20, 2014 @ 19:55 UTC

The way we're hoping to use it would be that all players are perpetually in creative UNLESS they enter the set radius of a specific "dwelling". Because each of them are building, all over the world, our only interest is to give a player the option to "protect" a built out area of their own (once they build it) so that inadvertent damage to a region around that area (like the 'house' itself) isn't a threat.

In function: If a player builds themself a house, they can request "protection" from me for that house. In theory, I would obtain the central coordinates for the house (or something close), estimate a reasonable radius, and set an automatic command from my "central hub" (within a short distance from spawn - only I can modify) that enables creative mode for just that player, while that player is in his/her "house". If another player enters the area to explore, they are automatically set to adventure (thereby preventing them from unintentionally damaging) until they leave the "area/house/radius". Once that other player leaves (non-owner), they're automatically returned to creative.

I think I may have to issues: there very well may be a conflict in the coordinates and radii settings, but first, I don't have an "automatic" command situation working. The commands (somewhat) work if I happen to toggle the lever under the proper circumstances. I need it to always be functioning, automatically.

Avatar image
Noah (@kirsle) posted on November 20, 2014 @ 20:03 UTC

The hopper block has a bottom part that "attaches" to an adjacent block (in the picture above they're attached to each other, so their bottoms are touching). To make a circle of hoppers, you'd do something like:

  • Place a normal block (i.e. stone) temporarily
  • Right-click one side of the stone block with a hopper. The bottom of the hopper attaches to the stone block.
  • Destroy the stone block. The hopper's bottom is still pointed to that side but there's nothing there now.
  • Hold Shift+Right-Click on a different side of the hopper. The new hopper's bottom should point to the side of the original hopper, and their bottoms make an "L" shape.
  • Shift+Right-Click on the side of hopper #2 so that their bottoms make a "C" shape.
  • Place the last hopper into the side of hopper #3. Now each hopper's bottom should point into the next hopper.

Here's a screenshot of how the hoppers end up looking from below (spectator mode):

Screenshot

It's a bit hard to see with the default texture pack but their bottoms are all pointed counter clockwise in a circle towards the next hopper.

Avatar image
Noah (@kirsle) posted on November 20, 2014 @ 20:19 UTC

I've built a simple test map that seems to work for me.

It's a simple Superflat world.

  • Diamond block indicates the center of the spawn region
  • Gold block indicates the center of a protected region
  • Blue carpet leads from the Diamond Block to the Gold Block (light blue carpet every 10 blocks)
  • Red wool block marks the inner border of the protected region (you go into Adventure Mode when inside this area)
  • Green wool block marks the outer border of the protected region (you go into Creative Mode when in this area)

So as you walk towards the Gold Block, you should start seeing notifications of your game mode switching to Creative while you're between the Green and Red Wool, and being switched to Adventure while between the Red Wool and Gold Block.

You can right-click the command blocks to see how they work. They use owner=testing so that the owner of the protected region is a player named "testing" (this will be sure to affect your character in-game because your player name probably isn't "testing")... if you edit the blocks to substitute your player name, it shouldn't modify your game mode at all when you wander around the Gold Block.

Edit: In "production" use, to suppress the noise generated by game modes constantly being updated, add an "m" flag to each command block's arguments to only target players with a specific game mode. I.E. so if they're already in Adventure Mode, they won't be set to Adventure Mode repeatedly.

Example: gamemode 2 @a[name=!owner,m=1,...] the m=1 will only match if they're currently in Creative Mode. If they're already in Adventure, it won't re-change them to Adventure.

And vice versa for creative mode (gamemode 1 @a[name=!owner,m=2,...])

Avatar image
Manda! posted on November 20, 2014 @ 22:55 UTC

Hi, this is a great article and I got really excited that the effect command would be exactly what I was looking for...

I'm trying to stop people from digging holes out of the bottom of the world so I thought

effect @a 4 3600 5

with something to set the block type=Bedrock would work but that's invalid.

Am I even on the right lines here or is there a better approach? A response would be much appreciated :)

Avatar image
Noah (@kirsle) posted on November 20, 2014 @ 23:03 UTC

@Manda:

You can't apply status effects to blocks. They only work on entities (players and mobs mostly, also they can technically apply to things like mine carts and armor stands but they won't have any effect ;) ).

Status effects also have no effect at all on creative mode players (at least, ones that stop them from breaking things). Even if you apply Mining Fatigue 5 (which normally makes it absolutely impossible to mine a block), a creative mode player is still unaffected (their arm will swing slowly but the block will still be destroyed just as quickly as without the effect).

One idea though is to use a command block that will execute a command relative to a creative mode player, which sets a square of bedrock blocks at Y=0 (the bottom of the world). Something like,

execute @a[m=1] ~ ~ ~ fill ~-3 0 ~-3 ~3 0 ~3 bedrock keep

Put that on a fast redstone clock. The command will target all players in Creative Mode (@a[m=1]), and end up running the command fill ~-3 0 ~-3 ~3 0 ~3 bedrock keep from the point of view of said player.

The fill command will create a 4x4 square of bedrock, 1 block tall, at level Y=0 (the very bottom row of blocks in the world), directly below the player (doesn't matter what height the player is at). So if they're trying to dig down through the bottom layer of bedrock, it will instantly repair itself. However, if somebody is standing directly on this layer, they may still be able to fall through in the brief moment between the block being destroyed and the command block replacing it.

To counter that you can make the bedrock 2 blocks thick (set the second 0 to be a 1), so if somebody is standing directly on the bedrock (feet at Y=2) and you break the block under them, they'll fall down one block and the bedrock will be replaced. The effect is their feet will be under the ground a little bit (they can still jump up out of there) but they won't fall straight into the void. And if the blocks repair themselves fast enough, nobody will be able to knock out 2 layers of the bedrock fast enough to make someone fall all the way through.

Keep in mind though that in a standard Minecraft world, only Y=0 is guaranteed to have bedrock everywhere. Layers from Y=1 to Y=4 have bedrock intermittently scattered around at various heights and positions. So using the command block to make a 2 block thick layer of bedrock will change the appearance of the world at that level (i.e. if you were to mine out a large area around bedrock, you'd be able to "trace the paths" of creative mode players by seeing the shapes that the obvious out-of-place bedrock blocks take ;) ).

Avatar image
Manda! posted on November 20, 2014 @ 23:22 UTC

Awesome, thanks very much for the speedy and thorough reply! I'll give it a go and hopefully peace will reign once more...!

Avatar image
Angie posted on November 20, 2014 @ 23:36 UTC

Noah, the download link you provided for the protection area test... forgive me, but what folder is that placed into so that I can load it from the game?

Seriously new to this.

:/

Avatar image
Noah (@kirsle) posted on November 20, 2014 @ 23:41 UTC

Put it in the "saves" folder inside the Minecraft profile folder. Two ways to get to the Minecraft profile folder:

  1. From inside Minecraft:
    1. Select "Options"
    2. Select "Resource Packs"
    3. Select "Open resource pack folder"
    4. Go up one level in the file browser
  2. If you're running Windows:
    1. Click the start button and click "Run"
    2. Type %appdata%\.minecraft\ and hit enter.

On Windows 7+ it's typically in C:\Users\<name>\AppData\Roaming\.minecraft and on Mac and Linux it'd be in /Users/<name>/.minecraft or /home/<name>/.minecraft respectively.

Extract the zip file into the "saves" folder in the Minecraft folder.

Avatar image
Angie posted on November 21, 2014 @ 00:33 UTC

So, no texturepacks folder.. I made one.
Only have from Options -> Resource packs. No go.. SO, I tried extracting the folder to "resourcepacks", that didn't work either, it doesn't show up in minecraft.

So, I deleted my copy, redownloaded, started from scratch. This time I didn't have either folder, texturepacks or resourcepacks.

Ok... fine, created. Does it show up in Minecraft? Nope.

Last attempt (and yes, running this on a windows machine at the moment, but if this continues.. heh, I should try this on a linux machine) I'll reboot..

I swear.

Avatar image
Noah (@kirsle) posted on November 21, 2014 @ 00:38 UTC

To clarify, you don't copy the world folder into your "resourcepacks" folder, you'd need to navigate Up one folder from there and you should see a "saves" folder, you put it inside there.

Assuming you're on Windows 7 or higher, hit Start, type %appdata% and hit Enter. It should open a folder named "Roaming" and there should be a ".minecraft" folder, open that and then there should be a "saves" folder. Put the world's folder in there.

Or, if you're familiar with how to run a Minecraft Server, usually a server folder has a folder named "world" in it.... basically, rename the folder from my zip file as "world" and use it in the Minecraft Server folder, and then start the server & connect in-game to it.

Avatar image
Angie posted on November 21, 2014 @ 01:30 UTC

And finally - How, exactly, does one get the redstone dust on top of the command blocks...

Oh, shift+right click. Ok, good.

And to light it? If I set a torch next to the dust, it will light the dust, but not activate the repeator or comparator. I promise, last question.

Avatar image
Angie posted on November 21, 2014 @ 01:33 UTC

Nevermind.. forgot the redstone in the hopper.

Avatar image
Angie posted on November 21, 2014 @ 02:51 UTC

So, if I die while in adventure, and respawn, I respawn in adventure. How is this possible if the entire server is set to creative by default?

Also, getting it to switch back to Creative once I leave the area that isn't "mine", I still don't switch back. In your example, I did.. and sometimes in my build I do, but it's almost like it's random? Decrease rm?

Avatar image
Noah (@kirsle) posted on November 21, 2014 @ 02:55 UTC

You might have to decrease rm (or increase r), make the creative mode transition area wider in case players are moving through it quickly or anything.

The default gamemode on servers only apply to brand new players joining for the very first time. It doesn't have any effect on respawns, unfortunately. So if they die in adventure mode and respawn, they'd have to go to somebody's house to get put back into creative mode. ;)

If everybody's spawn points are in their own houses (their protected areas), a third command block can be used to set the owner to creative mode while near their house. So when they die and respawn, they'd be in their house and they'd be put in creative mode right away.

Avatar image
Angie posted on November 21, 2014 @ 03:56 UTC

Ok, thanks.. I'll think on that. I've contemplated on having them respawn in their houses, but I like them starting where they left off when they signoff/on. Less confusing for them that way (especially the youngest ones).

I'm starting to wonder whether the majority of them can even handle Adventure mode. We're using an island biome with massive mountains and cliffs. It would work well on a superflat, but it's almost impossible for some of these kids. They've constructed dwellings on the very top/mesa of the mountains, with minecart rides on Swiss Family Robinson scale.

Yesh... I'm starting to wonder if bukkit isn't what I should consider. I just don't want to mess with modding the server. It's running on a linux system, virtualized, behind a firewall, and accessed through a hosted dns. The server is one of a couple that feed my LAN, VOIP, and other aspects of my internal network, and I just don't want the vulnerability the mods introduce (both in lag, updates, and security). Not to mention the time it takes to convert... I can't devote hours a day to this unfortunately.

Going off topic here, sorry. I am curious if you have any thoughts though, in addition to what you've already stated on the subject on your blog.

Avatar image
Praqoon posted on November 26, 2014 @ 12:07 UTC

Instead of imbuing players with undesirable effects I just opted to teleport any player within a 200 block radius, who isn't me, to some undesirable location...

/tp @a[m=0,r=200,!name=praqoon] 112518 66 176212

and food luck to them! :)

Avatar image
Agent117B posted on December 2, 2014 @ 06:18 UTC

Can you add a radius command to /clear @a flint_and_steel so it only removes this item in certain areas?

Avatar image
Agent117B posted on December 2, 2014 @ 13:42 UTC

in 1.7.10 sorry

Avatar image
Noah (@kirsle) posted on December 2, 2014 @ 20:05 UTC

The command should work in 1.7 too.

/clear @a[r=60] flint_and_steel to remove it from players within 60 blocks of the command block.

Avatar image
Anonymous posted on December 12, 2014 @ 04:10 UTC

I have a simple comment. Great!

Avatar image
Anonymous posted on December 29, 2014 @ 03:38 UTC

So when a player leaves the area and the circuit isn't loaded then returns, how can I get it to start back up again?

Avatar image
Noah (@kirsle) posted on December 29, 2014 @ 04:58 UTC

The circuit has to be self-starting. Most clocks are; i.e. hopper clocks. If the hoppers are unloaded from memory and then reloaded, one of them will detect the item in its inventory and push it into the next hopper and it will start working again automatically.

Manually started clocks (i.e. a ring of repeaters where you have to push a button, or place/destroy a redstone torch quickly to get it started) will stop working if they're unloaded. But they should be fine if you build them in the spawn chunks, as those never unload.

Avatar image
Tom_norge88 posted on April 3, 2015 @ 13:38 UTC

Wow Cool

Avatar image
Stardust1k posted on May 19, 2015 @ 17:43 UTC

I use a 56 second piston clock and give fatigue for 60 seconds. That way you dont spam your logs and the clock never fails even when reloaded.

Just google Etho's hopper clock.

Avatar image
Kylun11 posted on January 27, 2016 @ 02:01 UTC

It didn't work for me, but I used a / in front of everything. Would that affect anything?

Avatar image
dakota posted on March 25, 2016 @ 13:44 UTC

I'm making a horror map with command blocks and I don't want the player to go into the buildings yet. How do I keep them out (just until I want them to go in) without using pressure plates or the tp command? And also how do I make it so that when they walk into a room it teleports them out of the room(without the tp command)

Avatar image
dakota posted on March 25, 2016 @ 13:45 UTC

website looks AWESOME by the way. im learning to make my own in school.

Avatar image
Noah (@kirsle) posted on March 25, 2016 @ 17:07 UTC

@dakota:

  • One command- and redstone-free trick to keep them from entering a building might be to add barrier blocks to the doorway somewhere (/give @p barrier). Either on the outside of the door (preventing them from getting close to it), or on the inside. If you use a pressure plate on the inside that opens the door to leave, the barrier block could go above the pressure plate (at eye level) and still get the same effect.
  • For teleporting them out of a room, you'll have to use the tp command somehow or another.
Avatar image
Joe posted on May 2, 2016 @ 13:45 UTC

He Kirsle, nice to see that you are still active! I just want to know, how would you go about setting up a survival/adventure mode hybrid server? Adventure mode would need to be active in some areas of my world for an RPG element (players cannot alter terrain, mine, place blocks, etc) but it will also have a designated zone for survival. How would you set up command blocks to run adventure mode globally (as 75% of the world is RPG) and still have the remaining 25% be survival? Furthermore, if a player dies in RPG land, and they return to their bed in survival land, how could it be setup to autmatically detect that they have left the RPG realm upon death?

My initial idea was to create a huge area with adventure mode and put "nodes" of command blocks at its border to change the player to survival the moment they get toward the survival land. But I would imagine that this would not work if a player is walking, game turns into adventure mode for them upon entering RPG realm, and then when they die, they get sent back to survival realm but "skip" the node that is supposed to return their game mode to survival (as they get teleported to bed upoin death). Any ideas? Let me know if its still confusing, I can draw up a diagram if it helps :D

Avatar image
Noah (@kirsle) posted on May 2, 2016 @ 17:31 UTC

Depending on the size of the survival mode area, you could just put command blocks sprinkled around the area covering a range of (say) 40 blocks or so.

Each command block station could have two commands:

  • gamemode 0 @a[r=40]
  • gamemode 2 @r[rm=40]

The basic idea being "players within 40 blocks are survival, outside are adventure."

(It might be better to put these command blocks in your spawn chunks, with X/Y/Z coordinates in them, and have only one pair of blocks, with a radius large enough to cover your entire survival area. This eliminates the problem of command blocks being unloaded from memory depending on which chunks are active).

But you might run into issues where two of these command blocks overlap as a user's game mode would be rapidly toggled between both modes because two different sets of command blocks are acting on them.

So maybe another idea is to have the survival area command blocks just apply a temporary status affect to the players (maybe Mining Fatigue 0? something that's basically a no-op, but which expires after a certain length of time).

So your survival area would just keep re-assigning 5 seconds or so of a no-op status effect to all players in its area. Then, a global command block (in the server spawn chunks) could test for their status condition and set their game mode accordingly. If the commands keep re-giving the status at a faster interval than it expires, the user will stay on survival mode until they leave the area, the effect wears off, and the other command block switches them to adventure mode.

I don't know the specific commands to do this, though. You might also be able to use scoreboards and implement your own countdown timer, too. I did something similar with my Limbo in Vanilla Minecraft experiment.

In that system all users in the survival area would keep getting a dummy scoreboard assigned to say "5" or something, and a global command block (spawn chunks) would attempt to decrement that by 1 each second. When the number drops below 1 or so, another global command block would set all players with that scoreboard to adventure mode and remove that scoreboard from the player.

Avatar image
Joe posted on May 2, 2016 @ 20:27 UTC

Do you have any idea on how to set the command line up so that a command block in spawn chunks can load a "survival parameter" in a different part of the world? You mentioned x,y,z coordinates be put into the command line for: gamemode 0 @a[r=40] gamemode 2 @r[rm=40] Where in those commands would I begin entering the coordinates? Apologies for coming off noobish, I just started messing with command blocks after coming from console edition (been playing console edition for 3 years and NO commands still!)

And thank you so much for the help! Its really good advice, i will have to attempt this when I get out of my shift at work haha.

Avatar image
Joe posted on May 2, 2016 @ 20:33 UTC

EDIT: Also, is there a way to set these survival/adventure boundaries in a different format that isnt a radius? Like is there a command that changes the shapes border from radius based to paramter or square shaped?

Avatar image
Noah (@kirsle) posted on May 2, 2016 @ 21:03 UTC

@Joe: using the x/y/z parameters to the player selector.

http://minecraft.gamepedia.com/Commands#Target_selector_arguments

So it'd be like gamemode 0 @a[r=40,x=23,y=60,z=-123]

You might be able to get a box shape by using x/y/z as one corner and dx/dy/dz as the other instead of using the r or rm options, but I've never done anything with that so I'm not 100% sure that's how it works.

Avatar image
Joe posted on May 2, 2016 @ 21:19 UTC

Fair enough. Well, looks like I have some testing to do tonight! Thanks again for you assistance! You are the only source of info thats reliable about this question for anti-griefing within vanilla minecraft. And the only one still active and willing to help out haha. Would you mind if I came back here with my findings to report to you and the readers?

Avatar image
Sam posted on December 2, 2017 @ 06:42 UTC

This technique makes block grief-proof against player trying to mine, but not TNT blocks placed my players… Anyway great trick nonetheless !

Avatar image
me posted on January 20, 2018 @ 00:09 UTC

what i do is put villagers in a room on presure plates so they keeep walking on them

Avatar image
mabeltaylor posted on September 9, 2021 @ 07:14 UTC

Concrete is an energetic and durable structure material in Minecraft. It's anything but a dynamite look to any project you attempt in your game https://www.ourblogpost.com/how-to-make-concrete-in-minecraft/. The best part is that the material can be created in an assortment of tones, and it's anything but ignitable like fleece.

Add a Comment

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