Commands/gamemode

From Minecraft Wiki
Jump to: navigation, search
gamemode
Restrictions

Operator

First introduced

1.3.1 (12w16a)
PE Alpha 0.16.0 (PE Alpha 0.16.0 build 1)

Sets a player's game mode.

Syntax
  • Java Edition
gamemode <mode> [player]
  • Pocket Edition
gamemode <gameMode: string> [player: target]
An alternate syntax allows player to enter game mode by its number:
gamemode <gameMode: int> [player: target]
Arguments
mode (PE: gameMode: string or gameMode: int)
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[Java Edition only]
"hardcore" is not a valid option for the mode argument, as it is technically not a game mode.
player (PE: player: target) (optional)
If specified, must be either a player's username or a target selector. If unspecified, defaults to the player using the command. When used in a command block, player is not optional.
Result
Fails if the arguments are not specified correctly, or if player fails to resolve to one or more online players.
If successful, changes the game mode of the default or specified players.
Examples
To put yourself into creative mode: gamemode creative, gamemode c, or gamemode 1
To put all players into survival mode: gamemode 0 @a
See also
defaultgamemode – sets the initial game mode for players joining the world