Table of Contents

Class WorldSeed

Namespace
McServerLauncher.Services
Assembly
McServerLauncher.dll

Finds the seed of a server's world.

public static class WorldSeed
Inheritance
WorldSeed
Inherited Members

Remarks

level-seed in server.properties is not that seed. It is read once, when the world is generated. Empty means a random one was picked, and text means Java's String.hashCode of it was used. After that, only the world knows its seed.

The world has kept it in three places over the years, and all three are tried:

  • data/minecraft/world_gen_settings.dat → data.seed, from 26.1.
  • level.dat → Data.WorldGenSettings.seed, from 1.16.
  • level.dat → Data.RandomSeed, before 1.16.

The newest came to light because a 26.2 world had no seed in level.dat at all. That could happen again, which is why the answer to the seed command is also remembered.

Methods

EscapeForProperties(string)

A seed as it has to be written in server.properties, which is a Java properties file.

public static string EscapeForProperties(string seed)

Parameters

seed string

Returns

string

Remarks

A backslash is that format's escape character, so one typed into a seed has to be doubled or the server would read a different seed. Anything outside ASCII is written as \uXXXX, which every version reads the same way whatever encoding it expects. Line breaks are dropped, so a pasted seed can never add a key of its own.

FromConsoleLine(string)

The seed in the server's answer to the seed command, Seed: [-123]; null otherwise.

public static long? FromConsoleLine(string line)

Parameters

line string

Returns

long?

Read(string, long?)

The seed of the world in serverFolder, and where it came from.

public static SeedInfo Read(string serverFolder, long? lastKnown = null)

Parameters

serverFolder string

The server's folder.

lastKnown long?

The seed the server last printed for seed, if any.

Returns

SeedInfo

ToNumeric(string?)

The number Minecraft turns a typed seed into: the number itself, or else Java's String.hashCode of the text. Null for nothing typed, which means "random".

public static long? ToNumeric(string? text)

Parameters

text string

Returns

long?