Type a number into Minecraft's world creation screen and you get the same world every time. That determinism comes from a very old, very simple random number generator. Here is how it works, with a small Python re-implementation.
Text seeds become numbers
If you type text instead of a number, Java Edition uses String.hashCode():
def java_string_hash(s: str) -> int:
h = 0
for ch in s:
h = (31 * h + ord(ch)) & 0xFFFFFFFF
return h - (1 << 32) if h >= (1 << 31) else h
print(java_string_hash("glacier"))
That is why text seeds only cover 2^32 possible worlds, while numeric seeds cover 2^64.
java.util.Random is a linear congruential generator
MULT = 0x5DEECE66D
ADD = 0xB
MASK = (1 << 48) - 1
class JavaRandom:
def __init__(self, seed: int):
self.state = (seed ^ MULT) & MASK
def next(self, bits: int) -> int:
self.state = (self.state * MULT + ADD) & MASK
r = self.state >> (48 - bits)
return r - (1 << bits) if r >= (1 << (bits - 1)) else r
def next_int(self, bound: int) -> int:
r = self.next(31) & 0x7FFFFFFF
m = bound - 1
if bound & m == 0:
return (bound * r) >> 31
u = r
while u - (r := u % bound) + m < 0:
u = self.next(31) & 0x7FFFFFFF
return r
Only 48 bits of state are used, which is why seed-cracking tools can recover seeds from a handful of observations.
How structures use it
Structure placement seeds a fresh generator per region by mixing the world seed with region coordinates and a per-structure salt. The game then rolls a position inside the region. Because every input is deterministic, anyone with the seed can compute every village, temple and stronghold position without loading the world.
Seeing it in practice
Writing a full structure locator means re-implementing per-version placement rules, biome checks and salts, which change between releases. If you just want to see the result, an online Minecraft seed map renders biomes and structures for a given seed and version in the browser.
Takeaways
- Text seeds go through
hashCode()and are 32-bit. - World generation leans on a 48-bit LCG plus newer noise-based generators since 1.18.
- Determinism is a feature: it makes seed sharing, mapping and speedrun research possible.
Top comments (0)