On A minecraft Server How Can I Make Players Adventure mode in one area and survival in the next [duplicate]
I have an area where players drop down from the lobby in the sky down to the ground on my server but I want the area where they drop down to have a thing set up so they become adventure mode, but when leave that radius go into survival mode, and when go back in the area the become adventure mode again. So like spawn protection but I want to use command blocks. I know how to use them I just need the command for it!
Best Answer
How to Set up a Radius Based Command for Setting Gamemodes
- Find the center of the area you want to affect
- The shape will be a circular pattern
- Height is also included in this radius(Sphere not cylinder)
- Hide the Command block at the Center of the area
- Depending on Minecraft Version, use either a redstone clock(Pre 1.9) or a Repeating Command Block(1.9 and forward) to power it.
- In the Command Block Paste the Following Command(I will add more details on this later)
- Adventure: /gamemode a @a[r=3]
- Survival: /gamemode s @a[r=3]
- Creative: /gamemode c @a[r=3]
- Spectator: /gamemode sp @a[r=3]
- Test. Make sure that it works before relying on it for security
The Command
note: replace {gamemode} with 0, s, survival or 1, c, creative or 2, a, Adventure or 3, sp, spectator
/gamemode {gamemode} @e[r=#]
using the @e[r=#] allows you to affect all players(@a) in a radius([r=#]) around the command block. You can use this with any command(the /gamemode command in this case) that you don't want to affect all things globally.
Extra Customization
You can Target only Players in a specific gamemode by using @a[r=#,m={gamemode}]
You can also target all players not in a specific gamemode using @a[r=#,m=!{gamemode}]
Targeting only specific gamemodes(or at least ignoring the one they are becoming) will reduce chat spam
Using @a[r=#,name=!{YourName}] will allow you to be ignored by the command block(so you can stay in creative but stop others from being in creative)
If you don't want the command block at the center of the location you can use @a[r=#,x=#,y=#,z=#] to change the location of the command execution
Tips/Tricks/Other
- Make sure two gamemode changing commands to not overlap to prevent the user from being repetitively changed back and forth
- You can avoid Overlapping radius's by ensuring the only entry/exit is through a specific path, you can then use a smaller radius and only affect those entering/exiting the location.
- Another way to prevent overlap is to have your spawn area far away from the rest of the world and use /tp command to move players between the two locations
- [rm=#] can be used to select an area outside of a radius. useful for setting up two command blocks that affect the whole world(one for inside the spawn area, and one for outside the spawn area)
- Assumptions were made that this is a vanilla server (and thus, redstone security) if not then there are several plugins that can help with setting up permissions based on location(which I believe goes beyond this question so I will leave it at that)
Sources
I received all of my information from the Minecraft Wiki.
Commands: http://minecraft.gamepedia.com/Commands
Command Blocks: http://minecraft.gamepedia.com/Command_Block
I also verified my understanding by testing in Minecraft (1.9.2)
Pictures about "On A minecraft Server How Can I Make Players Adventure mode in one area and survival in the next [duplicate]"
![On A minecraft Server How Can I Make Players Adventure mode in one area and survival in the next [duplicate] - Man on Red Watercraft On A minecraft Server How Can I Make Players Adventure mode in one area and survival in the next [duplicate] - Man on Red Watercraft](/assets/images/on_a_minecraft_server_how_can_i_make_players_adventure_mode_in_one_area_and_survival_in_the_next_duplicate_1.jpeg)
![On A minecraft Server How Can I Make Players Adventure mode in one area and survival in the next [duplicate] - Person Scooping Water Using Green Cup On A minecraft Server How Can I Make Players Adventure mode in one area and survival in the next [duplicate] - Person Scooping Water Using Green Cup](/assets/images/on_a_minecraft_server_how_can_i_make_players_adventure_mode_in_one_area_and_survival_in_the_next_duplicate_2.jpeg)
![On A minecraft Server How Can I Make Players Adventure mode in one area and survival in the next [duplicate] - Two People Making fire On A minecraft Server How Can I Make Players Adventure mode in one area and survival in the next [duplicate] - Two People Making fire](/assets/images/on_a_minecraft_server_how_can_i_make_players_adventure_mode_in_one_area_and_survival_in_the_next_duplicate_3.jpeg)
How do you set a gamemode in a certain area in Minecraft?
The ones you're interested in for selecting a specific area are:Spawn Protection / Anti-Griefing System | Minecraft Tutorial 1.15 Command
More answers regarding on A minecraft Server How Can I Make Players Adventure mode in one area and survival in the next [duplicate]
Answer 2
From the minecraft wiki:
Syntax
gamemode [mode] [player]
Must be one of: survival (can be abbreviated as s or 0) for survival mode
creative (can be abbreviated as c or 1) for creative mode
adventure (can be abbreviated as a or 2) for adventure mode
spectator (can be abbreviated as sp or 3) for spectator mode
So for yours, you would do "gamemode a [playername]"
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Pixabay, Brett Sayles, Jens Johnsson, Mike
