Is there a way to set an "Adventure Mode Boundary" in Minecraft?

I am trying to create this village where players can spawn in, and then set out to explore the world and build and do normal minecraft stuff. I don't want them to destroy this village, so I want them to be in adventure mode when they are in the village and then switch them to survival when they leave, and vice-versa. When they return to the village, they get switched back to adventure mode.

In other words, I want to set an "Adventure Mode Boundary" to protect buildings. I am working without mods. I am hoping there is an simple way using command blocks.

  • Why not just use spawn protection? Set it to the radius you want, set the world spawn point to the center of the village, and don't make any of the players ops. Commented Jul 27, 2015 at 19:25

4 Answers 4


While @BassetHound has given a nice and easy solution, I'd like to provide a more powerful and robust solution, in case the protected area is not adequately described by a sphere of radius R. For example, your server might have a main road that is off-limits, but players are encouraged to build houses next to it, or catacombs beneath.

To do so, we'll set up a scoreboard objective, which will be changed based on the location of the player, allowing us to define the protected area with multiple different commands, thus allowing arbitrary shapes.

Start by setting up the objective itself, let's call it inTown:

scoreboard objectives add inTown dummy

Now, create a fill clock and run the following commands

scoreboard players set @a inTown 0
scoreboard players set @a[score_inTown=0,x=X1,y=Y1,z=Z1,dx=dX1,dy=dY1,dz=dZ1] inTown 1
scoreboard players set @a[score_inTown=0,x=X",y=Y2,z=Z2,dx=dX2,dy=dY2,dz=dZ2] inTown 1
scoreboard players set @a[score_inTown=0,x=XN,y=YN,z=ZN,dx=dXN,dy=dYN,dz=dZN] inTown 1

Each of these will define an area from (Xn,Yn,Zn) to (Xn+dXn,Yn+dYn,Zn+dZn) as part of your town, and set the score for players in that area to 1. If a player is not in any of these areas, his score will remain at 0 instead.

Of course, you can use other target selector arguments to define your area as well.

Now, add two commands to the end of your clock to set the gamemodes correctly:

gamemode 0 @a[score_inTown=0,m=2]
gamemode 2 @a[score_inTown_min=1,m=0]

Adding the m selector ensures that gamemodes are only set when appropriate. Players in spectator or creative mode are not affected. Just before changing the gamemode, you could use the same target selectors as above to inform your players of the change using the tellraw or title commands.


An easy way to do this would be to set up a command block and an extremely fast clock in the middle of the village that is perpetually setting the game mode of all players within a certain radius (r) of the command block to adventure:

/gamemode 2 @a[r=??]

Replace ?? with the radius of the village.

The problem lies with setting the players' gamemode to survival when they go outside the village. What could work is setting up a different command block on a slower clock that sets the gamemode of anyone in or slightly outside of the village to survival. When that command block activates and a player is inside of the village, the adventure mode command block should immediately reset the player's back to adventure. But if the player were to leave the village, the survival command block would be able to reach the player without interference from the adventure command block (if that makes any sense at all). Here's that command:

/gamemode s @a[rm=??, r=??+7]

Replace ??+7 with the radius of the village plus seven, and ?? with the radius of the village.

That should do the trick. Both commands would need to be run in the same X and Z co-ordinates. Players in the village would obtain survival mode for a split second, but not long enough to do anything.

Let me know if that helps.

  • As much as i recall, that's exactly it. Even tho i don't get the thing about the +7 for the radius.
    – Sime Kappa
    Commented Jul 27, 2015 at 14:08
  • 1
    @SimeKappa It'll set the gamemode of anyone within the village and seven blocks outside of the village to survival. Since the adventure command block is faster, it will reset the players who are inside and only inside of the village back to adventure, but not the players seven blocks outside of the village, leaving them to go out into the world in survival. Commented Jul 27, 2015 at 14:16
  • 1
    I imagine you can avoid the "survival for a split second" issue with a scoreboard. But then, you can do anything with a scoreboard, so that's not terribly surprising.
    – Kevin
    Commented Jul 27, 2015 at 18:28
  • 3
    You could use [rm=??+1]. Commented Jul 27, 2015 at 18:40
  • @NeilSlater I'm referring to my idea, not the answer. Commented Jul 27, 2015 at 20:41

An easy version would be this:

/gamemode survival @a[gamemode=adventure,distance=10..]
/gamemode adventure @a[gamemode=survival,distance=..10]

Put this into a clock, for example a ticking function (archive), a repeating command block and a chain command block behind it, etc.

This puts every player into Adventure mode who is 10 blocks or closer and everyone outside that radius into Survival mode. The gamemode restriction in the selector prevents the players to be put into the same gamemode over and over, which would lag the game.

You'll likely want to restrict it somehow, for example by team.


Another way to do it would be to use the Mining Fatigue status effect.

Here is a command you can use:

/effect @a[r=???+6] 4 2 255

and put it on a repeating command block.

This command will give them mining fatigue 255 as long as they are in the specified radius so they cannot break the blocks as long as they are in the range.

The +6 on the end is so that they cannot break blocks when they step outside the village and try to break from out there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .