From c552e79ea15e0bff76fd1664eb4d5f32f65b1b25 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Thu, 5 Mar 2020 23:59:17 +0000 Subject: [PATCH] named and commented various seeding methods (#1118) * named and commented various seeding methods * finished commenting * various changes * fixed my bad spelling * split paragraphs * Update mappings/net/minecraft/world/gen/ChunkRandom.mapping Co-Authored-By: Runemoro * Update mappings/net/minecraft/world/gen/ChunkRandom.mapping Co-Authored-By: Runemoro * Update mappings/net/minecraft/world/gen/ChunkRandom.mapping Co-Authored-By: Runemoro * Update mappings/net/minecraft/world/gen/ChunkRandom.mapping Co-Authored-By: Runemoro * changed pos to block Co-authored-by: Runemoro --- .../net/minecraft/world/biome/Biome.mapping | 2 +- .../minecraft/world/gen/ChunkRandom.mapping | 83 ++++++++++++++----- 2 files changed, 65 insertions(+), 20 deletions(-) diff --git a/mappings/net/minecraft/world/biome/Biome.mapping b/mappings/net/minecraft/world/biome/Biome.mapping index 8b773a5e3e..a2976ba2ff 100644 --- a/mappings/net/minecraft/world/biome/Biome.mapping +++ b/mappings/net/minecraft/world/biome/Biome.mapping @@ -58,7 +58,7 @@ CLASS net/minecraft/class_1959 net/minecraft/world/biome/Biome ARG 1 step ARG 2 chunkGenerator ARG 3 world - ARG 4 seed + ARG 4 populationSeed ARG 6 random ARG 7 pos METHOD method_8703 buildSurface (Ljava/util/Random;Lnet/minecraft/class_2791;IIIDLnet/minecraft/class_2680;Lnet/minecraft/class_2680;IJ)V diff --git a/mappings/net/minecraft/world/gen/ChunkRandom.mapping b/mappings/net/minecraft/world/gen/ChunkRandom.mapping index e959e17307..cfe93430dd 100644 --- a/mappings/net/minecraft/world/gen/ChunkRandom.mapping +++ b/mappings/net/minecraft/world/gen/ChunkRandom.mapping @@ -2,32 +2,77 @@ CLASS net/minecraft/class_2919 net/minecraft/world/gen/ChunkRandom FIELD field_13276 sampleCount I METHOD (J)V ARG 1 seed - METHOD method_12659 setSeed (II)J - ARG 1 x - ARG 2 z + METHOD method_12659 setTerrainSeed (II)J + COMMENT Seeds the randomizer to generate the surface terrain blocks (such as grass, sand, etc.) + COMMENT and the bedrock patterns. + COMMENT + COMMENT

Note that the terrain seed does not depend on the world seed and only gets affected by + COMMENT chunk coordinates.

+ ARG 1 chunkX + ARG 2 chunkZ METHOD method_12660 consume (I)V + COMMENT Skips the provided number of calls to the randomizer. + COMMENT + COMMENT

The skips give the effect of "scrambling" the randomizer but the output is still + COMMENT linearly dependent. Note that since multiple calls to a linear congruential generator is + COMMENT equivalent to another linear congruence, this method could be optimized to combine + COMMENT the calls into one.

ARG 1 count - METHOD method_12661 setSeed (JII)J + METHOD method_12661 setPopulationSeed (JII)J + COMMENT Seeds the randomizer to create population features such as decorators and animals. + COMMENT + COMMENT

This method takes in the world seed and the negative-most block coordinates of the + COMMENT chunk. The coordinate pair provided is equivalent to (chunkX * 16, chunkZ * 16). The + COMMENT three values are mixed together through some layers of hashing to produce the + COMMENT population seed.

+ COMMENT + COMMENT

This function has been proved to be reversible through some exploitation of the underlying + COMMENT nextLong() weaknesses. It is also important to remember that since setSeed() + COMMENT truncates the 16 upper bits of world seed, only the 48 lowest bits affect the population + COMMENT seed output.

ARG 1 worldSeed - ARG 3 x - ARG 4 z - METHOD method_12662 create (IIJJ)Ljava/util/Random; - ARG 0 x - ARG 1 z + ARG 3 blockX + ARG 4 blockZ + METHOD method_12662 getSlimeRandom (IIJJ)Ljava/util/Random; + ARG 0 chunkX + ARG 1 chunkZ ARG 2 worldSeed - ARG 4 localSeed - METHOD method_12663 setStructureSeed (JII)J - ARG 1 worldSeed - ARG 3 x - ARG 4 z - METHOD method_12664 setFeatureSeed (JII)J + ARG 4 scrambler + METHOD method_12663 setCarverSeed (JII)J + COMMENT Seeds the randomizer to generate larger features such as caves, ravines, mineshafts + COMMENT and strongholds. It is also used to initiate structure start behaviour such as rotation. + COMMENT + COMMENT

Similar to the population seed, only the 48 lowest bits of the world seed affect the + COMMENT output since it the upper 16 bits are truncated in the setSeed() call.

ARG 1 worldSeed + ARG 3 chunkX + ARG 4 chunkZ + METHOD method_12664 setDecoratorSeed (JII)J + COMMENT Seeds the randomizer to generate a given feature. + COMMENT + COMMENT The salt, in the form of {@code index + 10000 * step} assures that each feature is seeded + COMMENT differently, making the decoration feel more random. Even though it does a good job + COMMENT at doing so, many entropy issues arise from the salt being so small and result in + COMMENT weird alignments between features that have an index close apart. + ARG 1 populationSeed + COMMENT The population seed computed in setPopulationSeed(). ARG 3 index + COMMENT The index of the feature in the feature list. ARG 4 step - METHOD method_12665 setStructureSeed (JIII)J + COMMENT The generation step's ordinal for this feature. + METHOD method_12665 setRegionSeed (JIII)J + COMMENT Seeds the randomizer to determine the start position of structure features such as + COMMENT temples, monuments and buried treasures within a region. + COMMENT + COMMENT

The region coordinates pair corresponds to the coordinates of the region the seeded + COMMENT chunk lies in. For example, a swamp hut region is 32 by 32 chunks meaning that all + COMMENT chunks that lie within that region get seeded the same way.

+ COMMENT + COMMENT

Similarly, the upper 16 bits of world seed also do not affect the region seed because + COMMENT they get truncated in the setSeed() call.

ARG 1 worldSeed - ARG 3 x - ARG 4 z - ARG 5 seedModifier + ARG 3 regionX + ARG 4 regionZ + ARG 5 salt METHOD next (I)I ARG 1 bound