Minecraft – Gamemode vanilla 1.8 command block

minecraft-commandsminecraft-java-edition

I have made it so any one entering an area is switched to adventure game mode and then when he leaves the area he is switched back to survival.

How ever I am trying to do the same thing else where in the game but the code that is changing everything to survival beyond building one when they leave is affecting the code for building two when you enter.

What happens is the game mode is constantly changed indefinitely between survival and adventure mode.

The code I am using for the command blocks are:

/gamemode 2 @a[r=60,m=0]
/gamemode 0 @a[rm=60,m=2]

Bother buildings use the same code except the numbers are different due to the radius I am covering so building two has a radius of 30.

So what I'm asking is, how can I make it so I can enter and leave both buildings and have the game mode changed to adventure on entry and survival went vacated without the code of both buildings conflicting with each other?

Just to clarify that the command blocks reside below each building.

I'd be greatful if anyone could solve this for me.

Best Answer

Well the radius is mesured from the comand block. So if you put both command blocks in the same area it changes them constantly. What you can do is try to summon a invisible armor stand in the center of the area with /summon ArmorStand ~ ~ ~ {Invisible:1, CustomName:ArmorGuy,CustomNameVisible:0} then do /execute @e[name=ArmorGuy] ~ ~ ~ your gamemode command. I'm not sure will it work cause I'm sitting on my bed and typing with tablet.