Skip to content

Commit

Permalink
Fixed generation for MC 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Cubitect committed Jul 23, 2021
1 parent e61f4f1 commit b94c12e
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 48 deletions.
106 changes: 74 additions & 32 deletions generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ static void setupScale(Layer *l, int scale)

void setupGeneratorLargeBiomes(LayerStack *g, int mc, int largeBiomes)
{
if (mc < MC_1_3)
largeBiomes = 0;

memset(g, 0, sizeof(LayerStack));
Layer *p;

Expand All @@ -60,8 +63,7 @@ void setupGeneratorLargeBiomes(LayerStack *g, int mc, int largeBiomes)
p = setupLayer(g, L_LAND_1024_A, mapLand, mc, 1, 2, 2, p, 0);

if (mc <= MC_1_6)
{
// G L M V Z E S P1 P2
{ // G L M V Z E S P1 P2
p = setupLayer(g, L_SNOW_1024, mapSnow16, mc, 1, 2, 2, p, 0);
p = setupLayer(g, L_ZOOM_512, mapZoom, mc, 2, 3, 2002, p, 0);
p = setupLayer(g, L_LAND_512, mapLand16, mc, 1, 2, 3, p, 0);
Expand All @@ -71,13 +73,74 @@ void setupGeneratorLargeBiomes(LayerStack *g, int mc, int largeBiomes)
p = setupLayer(g, L_BIOME_256, mapBiome, mc, 1, 0, 200, p, 0);
p = setupLayer(g, L_ZOOM_128, mapZoom, mc, 2, 3, 1000, p, 0);
p = setupLayer(g, L_ZOOM_64, mapZoom, mc, 2, 3, 1001, p, 0);

// river noise layer chain, also used to determine where hills generate
p = setupLayer(g, L_NOISE_256, mapNoise, mc, 1, 0, 100,
g->layers+L_MUSHROOM_256, 0);
g->layers+L_MUSHROOM_256, 0);
}
else
{ // G L M V Z E S P1 P2
p = setupLayer(g, L_LAND_1024_B, mapLand, mc, 1, 2, 50, p, 0);
p = setupLayer(g, L_LAND_1024_C, mapLand, mc, 1, 2, 70, p, 0);
p = setupLayer(g, L_ISLAND_1024, mapIsland, mc, 1, 2, 2, p, 0);
p = setupLayer(g, L_SNOW_1024, mapSnow, mc, 1, 2, 2, p, 0);
p = setupLayer(g, L_LAND_1024_D, mapLand, mc, 1, 2, 3, p, 0);
p = setupLayer(g, L_COOL_1024, mapCool, mc, 1, 2, 2, p, 0);
p = setupLayer(g, L_HEAT_1024, mapHeat, mc, 1, 2, 2, p, 0);
p = setupLayer(g, L_SPECIAL_1024, mapSpecial, mc, 1, 2, 3, p, 0);
p = setupLayer(g, L_ZOOM_512, mapZoom, mc, 2, 3, 2002, p, 0);
p = setupLayer(g, L_ZOOM_256, mapZoom, mc, 2, 3, 2003, p, 0);
p = setupLayer(g, L_LAND_256, mapLand, mc, 1, 2, 4, p, 0);
p = setupLayer(g, L_MUSHROOM_256, mapMushroom, mc, 1, 2, 5, p, 0);
p = setupLayer(g, L_DEEP_OCEAN_256, mapDeepOcean, mc, 1, 2, 4, p, 0);
p = setupLayer(g, L_BIOME_256, mapBiome, mc, 1, 0, 200, p, 0);
if (mc >= MC_1_14)
p = setupLayer(g, L_BAMBOO_256, mapBamboo, mc, 1, 0, 1001, p, 0);
p = setupLayer(g, L_ZOOM_128, mapZoom, mc, 2, 3, 1000, p, 0);
p = setupLayer(g, L_ZOOM_64, mapZoom, mc, 2, 3, 1001, p, 0);
p = setupLayer(g, L_BIOME_EDGE_64, mapBiomeEdge, mc, 1, 2, 1000, p, 0);
// river noise layer chain, also used to determine where hills generate
p = setupLayer(g, L_RIVER_INIT_256, mapNoise, mc, 1, 0, 100,
g->layers+L_DEEP_OCEAN_256, 0);
}

if (mc <= MC_1_12)
{
p = setupLayer(g, L_ZOOM_128_HILLS, mapZoom, mc, 2, 3, 0, p, 0);
p = setupLayer(g, L_ZOOM_64_HILLS, mapZoom, mc, 2, 3, 0, p, 0);
}
else if (mc >= MC_1_1)
{
p = setupLayer(g, L_ZOOM_128_HILLS, mapZoom, mc, 2, 3, 1000, p, 0);
p = setupLayer(g, L_ZOOM_64_HILLS, mapZoom, mc, 2, 3, 1001, p, 0);
}

if (mc <= MC_1_0)
{ // G L M V Z E S P1 P2
p = setupLayer(g, L_ZOOM_32, mapZoom, mc, 2, 3, 1000,
g->layers+L_ZOOM_64, 0);
p = setupLayer(g, L_LAND_32, mapLand16, mc, 1, 2, 3, p, 0);
// NOTE: reusing slot for shore:16, but scale is 1:32
p = setupLayer(g, L_SHORE_16, mapShore, mc, 1, 2, 1000, p, 0);
p = setupLayer(g, L_ZOOM_16, mapZoom, mc, 2, 3, 1001, p, 0);
p = setupLayer(g, L_ZOOM_8, mapZoom, mc, 2, 3, 1002, p, 0);
p = setupLayer(g, L_ZOOM_4, mapZoom, mc, 2, 3, 1003, p, 0);

p = setupLayer(g, L_SMOOTH_4, mapSmooth, mc, 1, 2, 1000, p, 0);

// river layer chain
p = setupLayer(g, L_ZOOM_128_RIVER, mapZoom, mc, 2, 3, 1000,
g->layers+L_NOISE_256, 0);
p = setupLayer(g, L_ZOOM_64_RIVER, mapZoom, mc, 2, 3, 1001, p, 0);
p = setupLayer(g, L_ZOOM_32_RIVER, mapZoom, mc, 2, 3, 1002, p, 0);
p = setupLayer(g, L_ZOOM_16_RIVER, mapZoom, mc, 2, 3, 1003, p, 0);
p = setupLayer(g, L_ZOOM_8_RIVER, mapZoom, mc, 2, 3, 1004, p, 0);
p = setupLayer(g, L_ZOOM_4_RIVER, mapZoom, mc, 2, 3, 1005, p, 0);

p = setupLayer(g, L_RIVER_4, mapRiver, mc, 1, 2, 1, p, 0);
p = setupLayer(g, L_SMOOTH_4_RIVER, mapSmooth, mc, 1, 2, 1000, p, 0);
}
else if (mc <= MC_1_6)
{
p = setupLayer(g, L_HILLS_64, mapHills, mc, 1, 2, 1000,
g->layers+L_ZOOM_64, g->layers+L_ZOOM_64_HILLS);

Expand Down Expand Up @@ -117,33 +180,6 @@ void setupGeneratorLargeBiomes(LayerStack *g, int mc, int largeBiomes)
}
else
{
// G L M V Z E S P1 P2
p = setupLayer(g, L_LAND_1024_B, mapLand, mc, 1, 2, 50, p, 0);
p = setupLayer(g, L_LAND_1024_C, mapLand, mc, 1, 2, 70, p, 0);
p = setupLayer(g, L_ISLAND_1024, mapIsland, mc, 1, 2, 2, p, 0);
p = setupLayer(g, L_SNOW_1024, mapSnow, mc, 1, 2, 2, p, 0);
p = setupLayer(g, L_LAND_1024_D, mapLand, mc, 1, 2, 3, p, 0);
p = setupLayer(g, L_COOL_1024, mapCool, mc, 1, 2, 2, p, 0);
p = setupLayer(g, L_HEAT_1024, mapHeat, mc, 1, 2, 2, p, 0);
p = setupLayer(g, L_SPECIAL_1024, mapSpecial, mc, 1, 2, 3, p, 0);
p = setupLayer(g, L_ZOOM_512, mapZoom, mc, 2, 3, 2002, p, 0);
p = setupLayer(g, L_ZOOM_256, mapZoom, mc, 2, 3, 2003, p, 0);
p = setupLayer(g, L_LAND_256, mapLand, mc, 1, 2, 4, p, 0);
p = setupLayer(g, L_MUSHROOM_256, mapMushroom, mc, 1, 2, 5, p, 0);
p = setupLayer(g, L_DEEP_OCEAN_256, mapDeepOcean, mc, 1, 2, 4, p, 0);
p = setupLayer(g, L_BIOME_256, mapBiome, mc, 1, 0, 200, p, 0);
if (mc > MC_1_13)
p = setupLayer(g, L_BAMBOO_256, mapBamboo, mc, 1, 0, 1001, p, 0);
p = setupLayer(g, L_ZOOM_128, mapZoom, mc, 2, 3, 1000, p, 0);
p = setupLayer(g, L_ZOOM_64, mapZoom, mc, 2, 3, 1001, p, 0);
p = setupLayer(g, L_BIOME_EDGE_64, mapBiomeEdge, mc, 1, 2, 1000, p, 0);

// river noise layer chain, also used to determine where hills generate
p = setupLayer(g, L_RIVER_INIT_256, mapNoise, mc, 1, 0, 100,
g->layers+L_DEEP_OCEAN_256, 0);
p = setupLayer(g, L_ZOOM_128_HILLS, mapZoom, mc, 2, 3, mc < MC_1_13 ? 0 : 1000, p, 0);
p = setupLayer(g, L_ZOOM_64_HILLS, mapZoom, mc, 2, 3, mc < MC_1_13 ? 0 : 1001, p, 0);

p = setupLayer(g, L_HILLS_64, mapHills, mc, 1, 2, 1000,
g->layers+L_BIOME_EDGE_64, g->layers+L_ZOOM_64_HILLS);

Expand Down Expand Up @@ -218,12 +254,18 @@ void setupGeneratorLargeBiomes(LayerStack *g, int mc, int largeBiomes)
g->entry_64 = g->layers + (mc <= MC_1_6 ? L_SWAMP_RIVER_16 : L_SHORE_16);
g->entry_256 = g->layers + (mc <= MC_1_7 ? L_HILLS_64 : L_SUNFLOWER_64);
}
else
else if (mc >= MC_1_1)
{
g->entry_16 = g->layers + (mc <= MC_1_6 ? L_SWAMP_RIVER_16 : L_SHORE_16);
g->entry_64 = g->layers + (mc <= MC_1_7 ? L_HILLS_64 : L_SUNFLOWER_64);
g->entry_256 = g->layers + (mc <= MC_1_14 ? L_BIOME_256 : L_BAMBOO_256);
}
else
{
g->entry_16 = g->layers + L_ZOOM_16;
g->entry_64 = g->layers + L_ZOOM_64;
g->entry_256 = g->layers + L_BIOME_256;
}
setupScale(g->entry_1, 1);
}

Expand Down
2 changes: 1 addition & 1 deletion generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ enum
L_ZOOM_32,
L_LAND_32, L_ADD_ISLAND_32 = L_LAND_32,
L_ZOOM_16,
L_SHORE_16,
L_SHORE_16, // NOTE: in 1.0 this slot is scale 1:32
L_SWAMP_RIVER_16, // 1.6-
L_ZOOM_8,
L_ZOOM_4,
Expand Down
5 changes: 5 additions & 0 deletions layers.c
Original file line number Diff line number Diff line change
Expand Up @@ -2410,6 +2410,11 @@ int mapShore(const Layer * l, int * out, int x, int z, int w, int h)
out[i + j*w] = v11;
continue;
}
if (mc <= MC_1_0)
{
out[i + j*w] = v11;
continue;
}

if (mc <= MC_1_6)
{
Expand Down
7 changes: 4 additions & 3 deletions layers.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
/* Minecraft versions */
enum MCversion
{
MC_1_0, MC_1_1, MC_1_2, MC_1_3, MC_1_4, MC_1_5, MC_1_6, //<1.7 Experimental!
MC_1_7, MC_1_8, MC_1_9, MC_1_10, MC_1_11, MC_1_12, MC_1_13, MC_1_14,
MC_1_15, MC_1_16, MC_1_17,
MC_1_0, // <=1.0 Experimental!
MC_1_1, MC_1_2, MC_1_3, MC_1_4, MC_1_5, MC_1_6,
MC_1_7, MC_1_8, MC_1_9, MC_1_10, MC_1_11, MC_1_12,
MC_1_13, MC_1_14, MC_1_15, MC_1_16, MC_1_17,
MC_NEWEST = MC_1_17,
};

Expand Down
27 changes: 15 additions & 12 deletions tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,43 +111,46 @@ int testBiomeGen1x1(const int *mc, const uint32_t *expect, int bits, int cnt)

for (test = 0; test < cnt; test++)
{
printf(" [%d/%d] MC 1.%-2d: expecting %08x ... ",
test+1, cnt, mc[test], expect[test]);
printf(" [%*d/%*d] MC 1.%-2d: expecting %08x ... ",
1+(cnt>9), test+1, 1+(cnt>9),cnt, mc[test], expect[test]);
fflush(stdout);

double t = -now();
h = getRef(mc[test], bits, NULL);
printf("got %08x %s\e[0m\n",
h, h == expect[test] ? "\e[1;92mOK" : "\e[1;91mFAILED");
t += now();
printf("got %08x %s\e[0m (%ld msec)\n",
h, h == expect[test] ? "\e[1;92mOK" : "\e[1;91mFAILED",
(long)(t*1e3));
ok &= (h == expect[test]);
}

return ok;
}

int testOverworldBiomes()
int testOverworldBiomes(int thorough)
{
const int mc_vers[] = {
MC_1_16, MC_1_15, MC_1_13, MC_1_12, MC_1_9, MC_1_7,
MC_1_6,
MC_1_6, MC_1_2, MC_1_1, MC_1_0,
};
const uint32_t b6_hashes[] = {
0xde9a6574, 0x3a568a6d, 0x96c97323, 0xbc75e996, 0xe27a45a2, 0xbc75e996,
0x15b47206,
0x15b47206, 0x2d7e0fed, 0x5cbf4709, 0xbd794adb,
};
const uint32_t b10_hashes[] = {
0xfdede71d, 0xca8005d7, 0x399f7cc8, 0xb3363967, 0x17e5592f, 0xb3363967,
0xa52e377c,
0xa52e377c, 0xdb1df71d, 0x58e86947, 0xe1e89cc3,
};
const int testcnt = sizeof(mc_vers) / sizeof(int);

printf("Testing 1x1 biome generation (quick):\n");
if (!testBiomeGen1x1(mc_vers, b6_hashes, 6, testcnt))
return -1;

if (!thorough)
return 0;
printf("Testing 1x1 biome generation (thorough):\n");
if (!testBiomeGen1x1(mc_vers, b10_hashes, 10, testcnt))
return -1;

return 0;
}

Expand Down Expand Up @@ -206,8 +209,8 @@ int testPerformance()

int main()
{
//testOverworldBiomes();
testPerformance();
testOverworldBiomes(0);
//testPerformance();
return 0;
}

Expand Down
12 changes: 12 additions & 0 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ const char* mc2str(int mc)
{
switch (mc)
{
case MC_1_0: return "1.0"; break;
case MC_1_1: return "1.1"; break;
case MC_1_2: return "1.2"; break;
case MC_1_3: return "1.3"; break;
case MC_1_4: return "1.4"; break;
case MC_1_5: return "1.5"; break;
case MC_1_6: return "1.6"; break;
case MC_1_7: return "1.7"; break;
case MC_1_8: return "1.8"; break;
Expand Down Expand Up @@ -39,6 +45,12 @@ int str2mc(const char *s)
if (!strcmp(s, "1.8")) return MC_1_8;
if (!strcmp(s, "1.7")) return MC_1_7;
if (!strcmp(s, "1.6")) return MC_1_6;
if (!strcmp(s, "1.5")) return MC_1_5;
if (!strcmp(s, "1.4")) return MC_1_4;
if (!strcmp(s, "1.3")) return MC_1_3;
if (!strcmp(s, "1.2")) return MC_1_2;
if (!strcmp(s, "1.1")) return MC_1_1;
if (!strcmp(s, "1.0")) return MC_1_0;
return -1;
}

Expand Down

0 comments on commit b94c12e

Please sign in to comment.