Improve accuracy of 1.18+ temple surface check (still far from perfect though)

This commit is contained in:
Cubitect 2022-08-14 22:16:47 +02:00
parent a89d2cf9c9
commit fc4604447b
3 changed files with 17 additions and 18 deletions

View File

@ -40,7 +40,7 @@ int main()
for (seed = 0; ; seed++)
{
// Apply the seed to the generator for the Overworld dismension.
applySeed(&g, 0, seed);
applySeed(&g, DIM_OVERWORLD, seed);
// To get the biome at a single block position, we can use getBiomeAt().
int scale = 1; // scale=1: block coordinates, scale=4: biome coordinates
@ -95,7 +95,7 @@ int main()
setupGenerator(&g, MC_1_18, LARGE_BIOMES);
uint64_t seed = 123LL;
applySeed(&g, 0, seed);
applySeed(&g, DIM_OVERWORLD, seed);
Range r;
// 1:16, a.k.a. horizontal chunk scaling
@ -172,7 +172,7 @@ int main()
for (upper16 = 0; upper16 < 0x10000; upper16++)
{
uint64_t seed = lower48 | (upper16 << 48);
applySeed(&g, 0, seed);
applySeed(&g, DIM_OVERWORLD, seed);
if (isViableStructurePos(structType, &g, p.x, p.z, 0))
{
printf("Seed %" PRId64 " has a Pillager Outpost at (%d, %d).\n",
@ -248,7 +248,7 @@ int main()
for (high = 0; high < 0x10000; high++)
{
uint64_t seed = s48 | (high << 48);
applySeed(&g, 0, seed);
applySeed(&g, DIM_OVERWORLD, seed);
if (isViableStructurePos(styp, &g, pos[0].x, pos[0].z, 0) &&
isViableStructurePos(styp, &g, pos[1].x, pos[1].z, 0) &&
@ -290,7 +290,7 @@ int main()
Generator g;
setupGenerator(&g, mc, 0);
applySeed(&g, 0, seed);
applySeed(&g, DIM_OVERWORLD, seed);
pos = getSpawn(&g);
printf("Spawn: (%d, %d)\n", pos.x, pos.z);

View File

@ -2214,21 +2214,20 @@ int isViableStructureTerrain(int structType, Generator *g, int x, int z)
return 1;
}
id = getBiomeAt(g, 4, (x+sx)>>2, 15, (z)>>2);
if (isOceanic(id) || id == river || id == frozen_river)
return 0;
id = getBiomeAt(g, 4, (x)>>2, 15, (z+sz)>>2);
if (isOceanic(id) || id == river || id == frozen_river)
return 0;
id = getBiomeAt(g, 4, (x+sx)>>2, 15, (z+sz)>>2);
if (isOceanic(id) || id == river || id == frozen_river)
return 0;
return 1;
// approx surface height using depth parameter (0.5 ~ sea level)
const double thresh = 0.48;
int nptype = g->bn.nptype;
g->bn.nptype = NP_DEPTH;
int ret =
sampleClimatePara(&g->bn, (x+ 0)/4.0, (z+ 0)/4.0) < thresh ||
sampleClimatePara(&g->bn, (x+sx)/4.0, (z+sz)/4.0) < thresh ||
sampleClimatePara(&g->bn, (x+ 0)/4.0, (z+sz)/4.0) < thresh ||
sampleClimatePara(&g->bn, (x+sx)/4.0, (z+ 0)/4.0) < thresh;
g->bn.nptype = nptype;
return ret;
}
/* Given bordering noise columns and a fractional position between those,
* determine the surface block height (i.e. where the interpolated noise > 0).
* Note that the noise columns should be of size: ncolxz[ colheight+1 ]

View File

@ -466,7 +466,7 @@ int sampleBiomeNoise(const BiomeNoise *bn, int64_t *np, int x, int y, int z,
/**
* Initialize BiomeNoise for only a single climate parameter.
* If nptype == NP_DEPTH, the value is sampled at y=0. Note that this value
* changes linearly with the height (i.e. += y/32).
* changes linearly with the height (i.e. -= y/128).
*/
void setClimateParaSeed(BiomeNoise *bn, uint64_t seed, int large, int nptype);
double sampleClimatePara(const BiomeNoise *bn, double x, double z);