1.19.2 vs 1.19.3

1) add support for 1.19.2 along side 1.19.3
2) get approx stronghold positions in 1.19.3 without biome check
This commit is contained in:
Cubitect 2023-01-22 14:01:56 +01:00
parent 03895e6c22
commit bdec4f5ce8
7 changed files with 2296 additions and 25 deletions

File diff suppressed because it is too large Load Diff

View File

@ -141,7 +141,7 @@ int getStructureConfig(int structureType, int mc, StructureConfig *sconf)
return mc >= MC_1_14;
case Ancient_City:
*sconf = s_ancient_city;
return mc >= MC_1_19;
return mc >= MC_1_19_2;
case Treasure:
*sconf = s_treasure;
return mc >= MC_1_13;
@ -590,15 +590,26 @@ int nextStronghold(StrongholdIter *sh, const Generator *g)
validM |= (1ULL << i);
}
uint64_t lbr = sh->rnds;
if (sh->mc >= MC_1_19_3)
{
if (g)
{
uint64_t lbr = sh->rnds;
setSeed(&lbr, nextLong(&sh->rnds));
sh->pos = locateBiome(g, sh->nextapprox.x, 0, sh->nextapprox.z, 112,
validB, validM, &lbr, NULL);
if (sh->mc < MC_1_19_3)
sh->rnds = lbr;
}
else
{
nextLong(&sh->rnds);
sh->pos = sh->nextapprox;
}
}
else
{
sh->pos = locateBiome(g, sh->nextapprox.x, 0, sh->nextapprox.z, 112,
validB, validM, &sh->rnds, NULL);
}
sh->ringidx++;
sh->angle += 2 * PI / sh->ringmax;
@ -1131,7 +1142,7 @@ int isViableStructurePos(int structureType, Generator *g, int x, int z, uint32_t
getVariant(&sv, Bastion, g->mc, g->seed, x, z, -1);
sampleX = ((chunkX << 5) + 2*sv.x + sv.sx-1) / 2 >> 2;
sampleZ = ((chunkZ << 5) + 2*sv.z + sv.sz-1) / 2 >> 2;
if (g->mc >= MC_1_19)
if (g->mc >= MC_1_19_2)
sampleY = 33 >> 2; // nether biomes don't actually vary in Y
}
else
@ -4708,7 +4719,7 @@ const int *getBiomeParaLimits(int mc, int id)
if (mc <= MC_1_17)
return NULL;
int i, n;
if (mc >= MC_1_19)
if (mc > MC_1_18)
{
n = sizeof(g_biome_para_range_19_diff) / sizeof(g_biome_para_range_19_diff[0]);
for (i = 0; i < n; i++)

View File

@ -272,7 +272,9 @@ Pos initFirstStronghold(StrongholdIter *sh, int mc, uint64_t s48);
* location, as well as the approximate location of the next stronghold.
*
* @sh : stronghold iteration state, holding position info
* @g : generator, should be initialized for Overworld generation
* @g : generator, should be initialized for Overworld generation,
* for version 1.19.3+ the generator may be left NULL to iterate
* over the approximate locations without biome check
*
* Returns the number of further strongholds after this one.
*/

View File

@ -19,7 +19,7 @@ int biomeExists(int mc, int id)
return 1;
if (id == deep_dark || id == mangrove_swamp)
return mc >= MC_1_19;
return mc >= MC_1_19_2;
switch (id)
{

View File

@ -34,6 +34,7 @@ enum MCVersion
MC_1_16_5, MC_1_16 = MC_1_16_5,
MC_1_17_1, MC_1_17 = MC_1_17_1,
MC_1_18_2, MC_1_18 = MC_1_18_2,
MC_1_19_2,
MC_1_19_3, MC_1_19 = MC_1_19_3, MC_NEWEST = MC_1_19,
};

14
tests.c
View File

@ -111,7 +111,7 @@ int testBiomeGen1x1(const int *mc, const uint32_t *expect, int dim, int bits, in
for (test = 0; test < cnt; test++)
{
printf(" [%*d/%*d] MC %-4s dim=%-2d: expecting %08x ... ",
printf(" [%*d/%*d] MC %-6s dim=%-2d: expecting %08x ... ",
1+(cnt>9), test+1, 1+(cnt>9), cnt, mc2str(mc[test]), dim, expect[test]);
fflush(stdout);
@ -156,7 +156,7 @@ uint32_t testAreas(int mc, int dim, int scale)
free(ids);
}
t += now();
printf(" MC %-4s dim %-2d @ 1:%-3d - %08x [%ld msec]\n",
printf(" MC %-6s dim %-2d @ 1:%-3d - %08x [%ld msec]\n",
mc2str(mc), dim, scale, hash, (long)(t*1e3));
return hash;
}
@ -167,12 +167,12 @@ uint32_t testAreas(int mc, int dim, int scale)
int testGeneration()
{
const int mc_vers[] = {
// MC_1_19, MC_1_18,
MC_1_19, MC_1_19_2, MC_1_18,
MC_1_16, MC_1_15, MC_1_13, MC_1_12, MC_1_9, MC_1_7,
MC_1_6, MC_1_2, MC_1_1, MC_1_0, MC_B1_8,
};
const uint32_t b6_hashes[] = {
// 0x391c36ec, /*0xea3e8c1c, 1.19.2 */ 0xade7f891,
0x391c36ec, 0xea3e8c1c, 0xade7f891,
0xde9a6574, 0x3a568a6d, 0x96c97323, 0xbc75e996, 0xe27a45a2, 0xbc75e996,
0x15b47206, 0x2d7e0fed, 0x5cbf4709, 0xbd794adb, 0x00000000,
};
@ -199,7 +199,7 @@ int testGeneration()
//testAreas(MC_1_17, 0, 4);
const uint32_t b10_hashes[] = {
// 0x00000000, 0x00000000,
// 0x00000000, 0x00000000, 0x00000000,
0xfdede71d, 0xca8005d7, 0x399f7cc8, 0xb3363967, 0x17e5592f, 0xb3363967,
0xa52e377c, 0xdb1df71d, 0x58e86947, 0xe1e89cc3, 0x00000000,
};
@ -466,8 +466,8 @@ void findStructures(int structureType, int mc, int dim, uint64_t seed,
int main()
{
testCanBiomesGenerate();
//testGeneration();
//testCanBiomesGenerate();
testGeneration();
//findBiomeParaBounds();
return 0;
}

1
util.c
View File

@ -77,6 +77,7 @@ const char* mc2str(int mc)
int str2mc(const char *s)
{
if (!strcmp(s, "1.19")) return MC_1_19;
if (!strcmp(s, "1.19_2")) return MC_1_19_2;
if (!strcmp(s, "1.18")) return MC_1_18;
if (!strcmp(s, "1.17")) return MC_1_17;
if (!strcmp(s, "1.16.1")) return MC_1_16_1;