How to change a players game mode when crossing a threshold [duplicate]
I am running a vanilla Minecraft server on my Azure account and have an idea for it that I'm not sure is possible or not. Essentially I want to set up an area, something like 8x8 chunks that is designated as a creative area.
In order to achieve this I'm thinking that I will need at least one command block running constantly checking for players entering or exiting the area and adjusting their game mode accordingly. The problem I'm having is that I can't think of or find a way to reliably detect the threshold crossing, specifically for any height.
One potential solution I've come up with is to surround the creative chunks with barrier blocks to limit the ways in which the player can leave the area, but this is not ideal.
Bonus #1: If the player attempts to fly out of the creative zone it would be nice to also teleport them to the ground so they don't die when the game mode is switched.
Bonus #2: Can I have another set of command blocks that will store/restore a players inventory when crossing the threshold.
Best Answer
| | | command block-/gamemode 2 @a[r=2] | --------[Threshold]----------
command block-/gamemode x @a[r=2]
This way it changes back and forth if you go past the threshold either way.
*x=other game mode which they were in before they passed the threshold
to view the format and image you need to click edit to see the diagram I made of the command blocks.
Pictures about "How to change a players game mode when crossing a threshold [duplicate]"
![How to change a players game mode when crossing a threshold [duplicate] - Man in Black and Red Nike Basketball Jersey Playing Basketball How to change a players game mode when crossing a threshold [duplicate] - Man in Black and Red Nike Basketball Jersey Playing Basketball](/assets/images/how_to_change_a_players_game_mode_when_crossing_a_threshold_duplicate_1.jpeg)
![How to change a players game mode when crossing a threshold [duplicate] - Man in Black Tank Top Playing Basketball How to change a players game mode when crossing a threshold [duplicate] - Man in Black Tank Top Playing Basketball](/assets/images/how_to_change_a_players_game_mode_when_crossing_a_threshold_duplicate_2.jpeg)
![How to change a players game mode when crossing a threshold [duplicate] - Men Playing Basketball How to change a players game mode when crossing a threshold [duplicate] - Men Playing Basketball](/assets/images/how_to_change_a_players_game_mode_when_crossing_a_threshold_duplicate_3.jpeg)
How do you change the gamemode of another player?
Gamemode. To change the gamemode of a player, you would use the command /gamemode [creative/survival/spectator] [playername] . Simply enter which gamemode you would like, then enter the player name of whoever's gamemode you wish to change.How do you change game modes with one button?
You can use the /gamemode command to change between game modes at any time (Creative, Survival, Adventure or Spectator) for a Minecraft world.I found Minecraft's hidden gamemode.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Styves Exantus, John Omest, John Omest, John Omest
