Added a function for 'accurate' biomes of a chunk section.

This commit is contained in:
Cubitect 2021-11-29 22:10:34 +01:00
parent e2f7f80503
commit 38be869d8d
2 changed files with 34 additions and 0 deletions

View File

@ -1398,6 +1398,28 @@ int sampleBiomeNoise(const BiomeNoise *bn, int64_t *np, int x, int y, int z,
return id;
}
void genBiomeNoiseChunkSection(const BiomeNoise *bn, int out[4][4][4],
int cx, int cy, int cz, uint64_t *dat)
{
uint64_t buf = 0;
int i, j, k;
int x4 = cx << 2, y4 = cy << 2, z4 = cz << 2;
if (dat == NULL)
dat = &buf;
if (*dat == 0)
{ // try to determine the ending point of the last chunk section
sampleBiomeNoise(bn, NULL, x4+3, y4-1, z4+3, dat, 0);
}
// iteration order is important
for (i = 0; i < 4; ++i) {
for (j = 0; j < 4; ++j) {
for (k = 0; k < 4; ++k) {
out[i][j][k] = sampleBiomeNoise(bn, NULL, x4+i, y4+j, z4+k, dat, 0);
}
}
}
}
static void genBiomeNoise3D(const BiomeNoise *bn, int *out, Range r, int opt)
{

View File

@ -445,6 +445,18 @@ void initBiomeNoise(BiomeNoise *bn, int mc);
void setBiomeSeed(BiomeNoise *bn, uint64_t seed, int large);
int sampleBiomeNoise(const BiomeNoise *bn, int64_t *np, int x, int y, int z,
uint64_t *dat, uint32_t flags);
/**
* Currently, in 1.18, we have to generate biomes a chunk at a time to get an
* accurate mapping of the biomes in the level storage, as there is no longer a
* unique mapping from noise points to biomes (MC-241546). Note that the results
* from this are not suitable for chunk population/structure generation.
* The output is in the form out[x][y][z] for the 64 biome points in the chunk
* section. The coordinates {cx,cy,cz} are all at scale 1:16 and the 'dat'
* argument should be the previous noise sampling and can be left NULL.
*/
void genBiomeNoiseChunkSection(const BiomeNoise *bn, int out[4][4][4],
int cx, int cy, int cz, uint64_t *dat);
/**
* The scaled biome noise generation applies for the Overworld version 1.18.
* The 'sha' hash of the seed is only required for voronoi at scale 1:1.