Gameplay Commands
Commands for changing difficulty, game rules, and default game modes.
/defaultgamemodeSets the default game mode for new players joining the server. Players already online only switch when force-gamemode is on or the world is open to LAN.
/difficultySets or queries the game difficulty. Affects mob spawning, damage, hunger mechanics, and other gameplay aspects.
/gameruleSets or queries a game rule. Game rules control various world behaviors like mob griefing, fire spread, keep inventory, and many more.
Difficulty
Run /difficulty on its own to see the current setting, or add peaceful, easy, normal or hard to change it. Java has wanted the full word since 1.13; the numbers 0 to 3 and single letters only work on Bedrock.
Two things catch server owners out. The change only lasts until the next restart, because the server reads the difficulty from server.properties when it starts, so set it there as well if you mean it. And on a Hardcore world the command reports success while the difficulty stays exactly where it was.
Game rules have new names since 1.21.11
Java 1.21.11 gave every game rule a snake_case name. If a guide tells you to type keepInventory, it was written for an older version. These are the rules people look up most, the way /gamerule expects them now:
keep_inventory- Players keep their items and experience when they die. Off by default. Used to be keepInventory.
advance_time- Day, night and the moon phases keep moving. On by default. Used to be doDaylightCycle.
advance_weather- The weather changes by itself. On by default, and /weather still works when it is off. Used to be doWeatherCycle.
mob_griefing- Creepers, endermen, ravagers, withers and other mobs can change blocks. On by default. Used to be mobGriefing.
random_tick_speed- Random ticks per chunk section per game tick, the thing behind crop growth and leaf decay. Default 3, and 0 switches random ticks off. Used to be randomTickSpeed.
players_sleeping_percentage- The share of players in the Overworld, in percent, who have to sleep to skip the night. Default 100; at 0 a single sleeper is enough. Used to be playersSleepingPercentage.
spawn_phantoms- Phantoms spawn at night. On by default. Used to be doInsomnia.
fire_spread_radius_around_player- How far from a player fire can spread. Default 128 blocks; 0 stops fire spreading and -1 removes the limit. Replaced doFireTick.
Pair advance_time and advance_weather with the time and weather commands when you want a fixed noon or a storm that never ends.
Default game mode
/defaultgamemode sets the mode a player gets on their very first join. It only touches people who are already online when force-gamemode=true in server.properties, or when the world is open to LAN, and then everyone online switches at once. To change specific players, use /gamemode.
All three commands need permission level 2.