mojira.dev
MC-136161

Server default difficulty is 1 (easy), should be 2 (normal)

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

  1. Create dedicated server

  2. 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

Comments 5

Can confirm that this issue is still present in 1.16.5 and 21w15a.

Can confirm in 1.18.1.

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 in 1.19.

Can confirm in 1.19.2.

md_5

(Unassigned)

Confirmed

Dedicated Server

Minecraft 1.13, Minecraft 1.13.1-pre1, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 19w12b, ..., 1.18.1, 1.19, 1.19.2, 1.20.4, 1.21.1

Retrieved