Random sequence format
This feature is exclusive to Java Edition.
Random sequences are random number sequence generators used by loot tables and the /random (roll|value) ... command.
NBT structure
Current random sequences in a world and the random sequence settings of the world are stored in the /data/random_sequences.dat, which is a GZip-ed NBT file.
- [NBT Compound / JSON Object]: The root tag.
- [NBT Compound / JSON Object] data: Random sequence data.
- [Boolean] include_sequence_id: Whether the hash of the namespaced IDs of random sequences affects their seeds. Defaults to
true. Can be changed with/random reset * ...command. - [Boolean] include_world_seed: Whether the world seed affects seeds of random sequences. Defaults to
true. Can be changed with/random reset * ...command. - [Int] salt: The salt used when creating a random sequence. Defaults to
0. Can be changed with/random reset * ...command. - [NBT Compound / JSON Object] sequences: Current random sequences in the world.
- [NBT Compound / JSON Object] <resource location>: A random sequence.
- [Long Array] source: The seed of this random sequence.
- [Long]: The lower 64 bits.
- [Long]: The higher 64 bits.
- [Long Array] source: The seed of this random sequence.
- [NBT Compound / JSON Object] <resource location>: A random sequence.
- [Boolean] include_sequence_id: Whether the hash of the namespaced IDs of random sequences affects their seeds. Defaults to
- [Int] DataVersion: The data version.
- [NBT Compound / JSON Object] data: Random sequence data.
Usage
Random sequences are used by a loot table when its seed is not specified. Loot tables in containers from the world generation are not affected by random sequences (but are directly affected by the world seed).
Random sequences use the Xoroshiro128++ random number generator.
When a random sequence is called for the first time, it is created with the seed:
- From the [Int] salt value.
- If [Boolean] include_world_seed is
true, XOR the [Int] salt with the world seed. - Expands it to 128 bits. The lower 64 bits are the XOR between the value and
0x6a09e667f3bcc909; The higher 64 bits is the sum of the lower 64 bits and0x9e3779b97f4a7c15. - If [Boolean] include_sequence_id is
true, XOR it with the MD5 of the namespaced ID of the creating random sequence. - The two long numbers calculated from the lower 64 bits and the higher 64 bits respectively as follows are the seed of the random sequence.
public static long mixStafford13(long v) {
v = (v ^ v >>> 30) * 0xbf58476d1ce4e5b9L;
v = (v ^ v >>> 27) * 0x94d049bb133111ebL;
return v ^ v >>> 31;
}
History
| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 1.20 | pre1 | Added random sequences. | |||||
| 1.20.2 | 23w31a | Added the three random sequence settings of the world. | |||||
| Changed the way to generating the seed when creating a random sequence. | |||||||
| |||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||