The bug
The default difficulty is 1 (Easy) when it should be 2 (Normal). This is inconsistent with single player which correctly defaults to NORMAL (2).
How to reproduce
Create dedicated server
Open server.properties
→ ❌ Difficulty is set to 1 (Easy) and not 2 (Normal)
Code analysis
Code analysis and potential fix by @unknown can be found in this comment.
Linked issues
is duplicated by 1
Comments 5
Here's a code analysis along with a potential fix regarding this issue.
Code Analysis:
The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.
net.minecraft.server.dedicated.DedicatedServerProperties.java
public class DedicatedServerProperties extends Settings<DedicatedServerProperties> {
...
public final Difficulty difficulty = this.get("difficulty", dispatchNumberOrString(Difficulty::byId, Difficulty::byName), Difficulty::getKey, Difficulty.EASY);
...If we look at the above class, we can see that by default, servers have their difficulty set to EASY.
Potential Fix:
Simply changing the appropriate line of code to set the default server difficulty to NORMAL, should resolve this problem. The correct line of code within its class should look something like the following:
net.minecraft.server.dedicated.DedicatedServerProperties.java
public class DedicatedServerProperties extends Settings<DedicatedServerProperties> {
...
public final Difficulty difficulty = this.get("difficulty", dispatchNumberOrString(Difficulty::byId, Difficulty::byName), Difficulty::getKey, Difficulty.NORMAL);
...
Can confirm that this issue is still present in 1.16.5 and 21w15a.