Game rules, difficulty and game mode on your Minecraft server
Use /gamerule (for example keep_inventory on 1.21.11+, keepInventory on older versions), /difficulty and /gamemode. Set the defaults for new players in Properties.
- Difficulty:
- Beginner
- Time:
- 6 minutes
On this page
Game rules, difficulty and game mode are changed with commands. Type them in the panel Console without a /, or in game with a / if you are an op. Changes apply instantly and are saved with the world, so they survive restarts.
Game rules (Java Edition)
The command is gamerule <rule> <value>. Type gamerule <rule> with no value to see the current setting.
The names changed in Minecraft 1.21.11. All game rules were renamed from camelCase (keepInventory) to snake_case (keep_inventory), and some got completely new names. Use the column that matches your server version (shown in the Versions tab as Installed Minecraft Version). In game, press Tab after /gamerule to see the names your version uses.
What it does | 1.21.11 and newer (incl. 26.x) | 1.21.10 and older |
|---|---|---|
Keep items and XP when you die |
|
|
Stop day/night (time freezes) |
|
|
Stop weather changing |
|
|
Only one player needs to sleep |
|
|
Stop creepers and endermen breaking blocks |
|
|
Stop all mobs spawning naturally |
|
|
No phantoms |
|
|
Respawn instantly (no death screen) |
|
|
Hide advancement messages in chat |
|
|
Turn PvP off |
| 1.21.9–1.21.10: |
For the sleeping rule, 0 or 1 lets any single player skip the night; 50 means half the players online must sleep. The default is 100 (everyone).
On Paper, Purpur and Spigot, game rules are set per world. A rule typed in the console applies to the main overworld; run it in game while standing in the Nether or End, or use a plugin, to change those worlds too.
Difficulty
difficulty peaceful
difficulty easy
difficulty normal
difficulty hardA Java server applies the difficulty value from Properties every time it starts, so set it there too or your change will be undone at the next restart. Hardcore servers are always on hard. See server.properties explained.
Game mode
gamemode creative Steve
gamemode survival Steve
gamemode adventure @a
gamemode spectator SteveIn game you can leave out the name to change your own mode:
/gamemode creative. In the console you must give a name.defaultgamemode survivalsets the mode for players joining for the first time. You can also setgamemodein Properties.Turn on
force-gamemodein Properties to put everyone back into the default mode every time they join.
Bedrock Edition differences
Game rule names are all lowercase and use the older names:
gamerule keepinventory true,gamerule dodaylightcycle false,gamerule playerssleepingpercentage 0,gamerule mobgriefing false,gamerule pvp false.Bedrock has some rules Java doesn't, such as
gamerule showcoordinates true.Game mode and difficulty accept short forms:
gamemode c Steve,gamemode s Steve,difficulty h.On a Bedrock server, players need operator permission, and the world must allow cheats (
allow-cheats=trueinserver.properties) for most of these commands to work in game. The server console can always run them.
Frequently asked questions
"Incorrect argument for command" when I type keepInventory
Your server is on 1.21.11 or newer, which uses the new names. Type gamerule keep_inventory true instead.
How do I see all game rules?
In game, type /gamerule (with a space) and press Tab to scroll through every rule your version supports.
"Unknown or incomplete command" in game
You are not an op. Run op YourName in the console first. See Whitelist, op and ban players.
Was this article helpful?
Related articles
Pick the right plan for your player count, plugins and modpacks — with a plan comparison table and chart.
Stop the server, delete or rename the world folder(s), set a new level-seed in Properties if you want, and start the server to generate a fresh world.
Put a direct download link in resource-pack (plus its SHA-1) in Properties to send a resource pack. Put datapack zips in world/datapacks and reload or restart.
Type commands into the Console without a leading slash, learn when to use Start, Restart, Stop or Kill, and fix a console that won't load.
