I'm not 100% sure whether this is a bug or a feature.
Expectation:
Typing /difficulty <0|1|2|3> into the command line with the allowCommands NBT tag set to 1 or having spawned a world with cheats enabled to change the default difficulty for the save, not just the runtime difficulty
Occurrence:
With the NBT tag allowCommands set to 1, or after spawning a world with cheats enabled, typing /difficulty <0|1|2|3> into the chatbox (command line) does not change the difficulty set by the setting in the ESC menu. The environment correctly reflects the change (mobs despawning when set to 0), but after changing the difficulty and reloading the world the difficulty set by the ESC menu takes precedence over that previously set.
Linked issues
is duplicated by 13
relates to 2
Comments 12
Yeah, that only works as a server command. The /difficulty command doesn't affect your menu difficulty.
When playing on single player, go into the Options screen and set your difficulty to "Peaceful". Next, change difficulty via game commands to "hard" (type /difficulty h or command block). Game will be set to hard and spawn a hostile mob for example. However, if you simply view the Options screen again, the game will auto update difficulty. Hostile mobs disappear.
This is a huge issue with Custom Maps for 2 reasons. If the player simply views the Options screen to go into video settings or something, their difficulty gets updated and can either remove all hostile mobs, or if the command difficulty is has been to peaceful, and the player has difficulty preset to Easy/Normal/Hard, hunger is now an issue.
I'm not asking to update the menu with commands, I'm asking to only change difficulty if the player actually physically presses the Difficulty button.
you can use a clock that keeps setting the difficulty to the one you want. That way it isn't a problem anymore on peaceful, on easy/normal/hard however it is still an issue. If you have a boss mob that spawns only once and you set the gamemode to peaceful accidentally it's gone. Maybe add an NBT tag to mobs that prevents them from despawning in peaceful. Or use persistence required
Are trying this on Multi-player or Single-player?