Skip to content

API reference / @jsprismarine/prismarine / Seed

Seed ​

Functions ​

SeedGenerator() ​

SeedGenerator(): bigint

Defined in: prismarine/src/utils/Seed.ts:42

A fresh world seed, drawn over the whole 64-bit range Java draws one over.

Two 32-bit halves rather than one Math.random, which only has 53 bits to give and would leave the top of the range unreachable.

Returns ​

bigint

A random signed 64-bit seed.


worldSeedOf() ​

worldSeedOf(configured): bigint

Defined in: prismarine/src/utils/Seed.ts:61

The seed a configured value means, by Java's rule for the text in its world creation box.

Text that parses as a long is that number; anything else is its String.hashCode. That is what lets a player paste a named Java seed and land in Java's world, and it is why the config value is read as a string: neither JSON nor YAML can hold a 19-digit seed as a number literal without rounding it, and the rounded seed generates a different world.

A number is still accepted, for configs written before the seed was a string. One above 2^53 has already lost bits by the time it is parsed, and nothing here can recover them.

Parameters ​

configured ​

string | number | undefined

The seed value from the world's config entry.

Returns ​

bigint

The seed as a signed 64-bit value, or 0 when nothing is configured.