Generalized generator + added 1.14 bamboo jungles.

This commit is contained in:
Cubitect 2019-05-06 23:14:25 +02:00
parent 26e97f8216
commit 99d131ed8f
9 changed files with 414 additions and 435 deletions

View File

@ -19,7 +19,7 @@ static DWORD WINAPI searchCompactBiomesThread(LPVOID data)
int64_t s;
LayerStack g = setupGenerator(MC_1_13);
int *cache = allocCache(&g.layers[g.layerNum-1], info.range, info.range);
int *cache = allocCache(&g.layers[L_VORONOI_ZOOM_1], info.range, info.range);
for (s = info.seedStart; s < info.seedEnd; s++)
{

View File

@ -62,7 +62,7 @@ int main(int argc, char *argv[])
// setupGeneratorMC113() biome generation is slower and unnecessary.
// We are only interested in the biomes on land, which haven't changed
// since MC 1.7 except for some modified variants.
g = setupGeneratorMC17();
g = setupGenerator(MC_1_7);
// Use the 1.13 Hills layer to get the correct modified biomes.
g.layers[L_HILLS_64].getMap = mapHills113;
}
@ -70,7 +70,7 @@ int main(int argc, char *argv[])
{
featureConfig = FEATURE_CONFIG;
seedFileName = "./seeds/quadhutbases_1_7_Q1.txt";
g = setupGeneratorMC17();
g = setupGenerator(MC_1_7);
}
if(access(seedFileName, F_OK))

View File

@ -839,8 +839,8 @@ Pos getLargeStructureChunkInRegion(StructureConfig config, int64_t seed,
int getBiomeAtPos(const LayerStack g, const Pos pos)
{
int *map = allocCache(&g.layers[g.layerNum-1], 1, 1);
genArea(&g.layers[g.layerNum-1], map, pos.x, pos.z, 1, 1);
int *map = allocCache(&g.layers[L_VORONOI_ZOOM_1], 1, 1);
genArea(&g.layers[L_VORONOI_ZOOM_1], map, pos.x, pos.z, 1, 1);
int biomeID = map[0];
free(map);
return biomeID;
@ -1139,8 +1139,8 @@ static double getGrassProbability(int64_t seed, int biome, int x, int z)
case savannaPlateau: return 1.0;
case mesaPlateau_F: return 0.1; // height dependent
case mesaPlateau: return 0.1; // height dependent
// NOTE: in rare circumstances you can get also get grass islands that are
// completely ocean variants...
// NOTE: in rare circumstances you can get also get grassy islands that are
// completely in ocean variants...
default: return 0;
}
}
@ -1264,8 +1264,8 @@ Pos estimateSpawn(const int mcversion, LayerStack *g, int *cache, int64_t worldS
int isViableFeaturePos(const int structureType, const LayerStack g, int *cache,
const int blockX, const int blockZ)
{
int *map = cache ? cache : allocCache(&g.layers[g.layerNum-1], 1, 1);
genArea(&g.layers[g.layerNum-1], map, blockX, blockZ, 1, 1);
int *map = cache ? cache : allocCache(&g.layers[L_VORONOI_ZOOM_1], 1, 1);
genArea(&g.layers[L_VORONOI_ZOOM_1], map, blockX, blockZ, 1, 1);
int biomeID = map[0];
if (!cache) free(map);
@ -1381,8 +1381,7 @@ int isZombieVillage(const int mcversion, const int64_t worldSeed,
// jump to the random number check that determines whether this is village
// is zombie infested
int64_t rnd = chunkGenerateRnd(worldSeed, pos.x , pos.z);
// TODO: check for versions <= 1.11
skipNextN(&rnd, mcversion >= MC_1_13 ? 10 : 11);
skipNextN(&rnd, mcversion == MC_1_13 ? 10 : 11);
return nextInt(&rnd, 50) == 0;
}
@ -1582,7 +1581,7 @@ int64_t filterAllMajorBiomes(
const unsigned int sX,
const unsigned int sZ)
{
Layer *lFilterMushroom = &g->layers[L_ADD_MUSHROOM_ISLAND_256];
Layer *lFilterMushroom = &g->layers[L_ADD_MUSHROOM_256];
Layer *lFilterBiomes = &g->layers[L_BIOME_256];
int *map;
@ -1793,11 +1792,11 @@ int64_t checkForBiomes(
const int minscale)
{
Layer *lspecial = &g->layers[L_SPECIAL_1024];
Layer *lmushroom = &g->layers[L_ADD_MUSHROOM_ISLAND_256];
Layer *lmushroom = &g->layers[L_ADD_MUSHROOM_256];
Layer *lbiomes = &g->layers[L_BIOME_256];
Layer *loceantemp = NULL;
int *map = cache ? cache : allocCache(&g->layers[g->layerNum-1], width, height);
int *map = cache ? cache : allocCache(&g->layers[L_VORONOI_ZOOM_1], width, height);
uint64_t potential, required, modified;
int64_t ss, cs;
@ -2052,7 +2051,10 @@ int64_t checkForBiomes(
areaHeight4 = ((height-1) >> 2) + 2;
applySeed(g, seed);
genArea(&g->layers[g->layerNum-2], map, areaX4, areaZ4, areaWidth4, areaHeight4);
if (filter.doOceanTypeCheck)
genArea(&g->layers[L13_OCEAN_MIX_4], map, areaX4, areaZ4, areaWidth4, areaHeight4);
else
genArea(&g->layers[L_RIVER_MIX_4], map, areaX4, areaZ4, areaWidth4, areaHeight4);
potential = modified = 0;

View File

@ -55,6 +55,7 @@ static const StructureConfig SWAMP_HUT_CONFIG = { 14357620, 32, 24, 0};
static const StructureConfig OUTPOST_CONFIG = {165745296, 32, 24, 0};
static const StructureConfig VILLAGE_CONFIG = { 10387312, 32, 24, 0};
static const StructureConfig TREASURE_CONFIG = { 10387320, 16, 7, 0};
static const StructureConfig OCEAN_RUIN_CONFIG = { 14357621, 16, 8, 0};
static const StructureConfig SHIPWRECK_CONFIG = {165745295, 15, 7, 0};
static const StructureConfig MONUMENT_CONFIG = { 10387313, 32, 27, LARGE_STRUCT};
@ -64,12 +65,21 @@ static const StructureConfig MANSION_CONFIG = { 10387319, 80, 60, LARGE_S
// Biome Tables
//==============================================================================
static const int templeBiomeList[] = {desert, desertHills, jungle, jungleHills, swampland, icePlains, coldTaiga};
static const int biomesToSpawnIn[] = {forest, plains, taiga, taigaHills, forestHills, jungle, jungleHills};
static const int oceanMonumentBiomeList1[] = {ocean, deepOcean, river, frozenRiver, frozenOcean, frozenDeepOcean, coldOcean, coldDeepOcean, lukewarmOcean, lukewarmDeepOcean, warmOcean, warmDeepOcean};
static const int oceanMonumentBiomeList2[] = {frozenDeepOcean, coldDeepOcean, deepOcean, lukewarmDeepOcean, warmDeepOcean};
static const int templeBiomeList[] = {desert, desert_hills, jungle, jungle_hills, swamp, snowy_tundra, snowy_taiga};
static const int biomesToSpawnIn[] = {forest, plains, taiga, taiga_hills, wooded_hills, jungle, jungle_hills};
static const int villageBiomeList[] = {plains, desert, savanna, taiga};
static const int mansionBiomeList[] = {roofedForest, roofedForest+128};
static const int villageBiomeListBE[] = {plains, desert, savanna, taiga, snowy_tundra, snowy_taiga};
static const int mansionBiomeList[] = {dark_forest, dark_forest+128};
static const int oceanMonumentBiomeList1[] =
{
ocean, deep_ocean, river, frozen_river,
frozen_ocean, deep_frozen_ocean, cold_ocean, deep_cold_ocean,
lukewarm_ocean, deep_lukewarm_ocean, warm_ocean, deep_warm_ocean
};
static const int oceanMonumentBiomeList2[] =
{
deep_frozen_ocean, deep_cold_ocean, deep_ocean, deep_lukewarm_ocean, deep_warm_ocean
};
static const int achievementBiomes_1_7[] =
{

View File

@ -27,263 +27,112 @@ void setupMultiLayer(int scale, Layer *l, Layer *p1, Layer *p2, int s, void (*ge
}
LayerStack setupGenerator(const int mcversion)
{
if (mcversion < MCBE_1_7)
if (biomes[plains].id == 0)
{
if (mcversion <= MC_1_12)
return setupGeneratorMC17();
else
return setupGeneratorMC113();
fprintf(stderr, "Warning: The biomes have to be initialised first using initBiomes() before any generator can be used.\n");
}
LayerStack g;
g.layerCnt = L_NUM;
g.layers = (Layer *) calloc(g.layerCnt, sizeof(Layer));
Layer *l = g.layers;
// SCALE LAYER PARENT SEED LAYER_FUNCTION
setupLayer(4096, &l[L_ISLAND_4096], NULL, 1, mapIsland);
setupLayer(2048, &l[L_ZOOM_2048], &l[L_ISLAND_4096], 2000, mapZoom);
setupLayer(2048, &l[L_ADD_ISLAND_2048], &l[L_ZOOM_2048], 1, mapAddIsland);
setupLayer(1024, &l[L_ZOOM_1024], &l[L_ADD_ISLAND_2048], 2001, mapZoom);
setupLayer(1024, &l[L_ADD_ISLAND_1024A], &l[L_ZOOM_1024], 2, mapAddIsland);
setupLayer(1024, &l[L_ADD_ISLAND_1024B], &l[L_ADD_ISLAND_1024A], 50, mapAddIsland);
setupLayer(1024, &l[L_ADD_ISLAND_1024C], &l[L_ADD_ISLAND_1024B], 70, mapAddIsland);
setupLayer(1024, &l[L_REMOVE_OCEAN_1024], &l[L_ADD_ISLAND_1024C], 2, mapRemoveTooMuchOcean);
setupLayer(1024, &l[L_ADD_SNOW_1024], &l[L_REMOVE_OCEAN_1024], 2, mapAddSnow);
setupLayer(1024, &l[L_ADD_ISLAND_1024D], &l[L_ADD_SNOW_1024], 3, mapAddIsland);
setupLayer(1024, &l[L_COOL_WARM_1024], &l[L_ADD_ISLAND_1024D], 2, mapCoolWarm);
setupLayer(1024, &l[L_HEAT_ICE_1024], &l[L_COOL_WARM_1024], 2, mapHeatIce);
setupLayer(1024, &l[L_SPECIAL_1024], &l[L_HEAT_ICE_1024], 3, mapSpecial);
setupLayer(512, &l[L_ZOOM_512], &l[L_SPECIAL_1024], 2002, mapZoom);
setupLayer(256, &l[L_ZOOM_256], &l[L_ZOOM_512], 2003, mapZoom);
setupLayer(256, &l[L_ADD_ISLAND_256], &l[L_ZOOM_256], 4, mapAddIsland);
setupLayer(256, &l[L_ADD_MUSHROOM_256], &l[L_ADD_ISLAND_256], 5, mapAddMushroomIsland);
setupLayer(256, &l[L_DEEP_OCEAN_256], &l[L_ADD_MUSHROOM_256], 4, mapDeepOcean);
// biome layer chain
setupLayer(256, &l[L_BIOME_256], &l[L_DEEP_OCEAN_256], 200,
mcversion != MCBE ? mapBiome : mapBiomeBE);
if (mcversion <= MC_1_13)
setupLayer(128, &l[L_ZOOM_128], &l[L_BIOME_256], 1000, mapZoom);
else
{
setupLayer(256, &l[L14_BAMBOO_256], &l[L_BIOME_256], 1001, mapAddBamboo);
setupLayer(128, &l[L_ZOOM_128], &l[L14_BAMBOO_256], 1000, mapZoom);
}
setupLayer(64, &l[L_ZOOM_64], &l[L_ZOOM_128], 1001, mapZoom);
setupLayer(64, &l[L_BIOME_EDGE_64], &l[L_ZOOM_64], 1000, mapBiomeEdge);
// basic river layer chain, used to determine where hills generate
setupLayer(256, &l[L_RIVER_INIT_256], &l[L_DEEP_OCEAN_256], 100, mapRiverInit);
setupLayer(128, &l[L_ZOOM_128_HILLS], &l[L_RIVER_INIT_256], 1000, mapZoom);
setupLayer(64, &l[L_ZOOM_64_HILLS], &l[L_ZOOM_128_HILLS], 1001, mapZoom);
setupMultiLayer(64, &l[L_HILLS_64], &l[L_BIOME_EDGE_64], &l[L_ZOOM_64_HILLS], 1000,
(mcversion & 0xff) <= MC_1_12 ? mapHills : mapHills113);
setupLayer(64, &l[L_RARE_BIOME_64], &l[L_HILLS_64], 1001, mapRareBiome);
setupLayer(32, &l[L_ZOOM_32], &l[L_RARE_BIOME_64], 1000, mapZoom);
setupLayer(32, &l[L_ADD_ISLAND_32], &l[L_ZOOM_32], 3, mapAddIsland);
setupLayer(16, &l[L_ZOOM_16], &l[L_ADD_ISLAND_32], 1001, mapZoom);
setupLayer(16, &l[L_SHORE_16], &l[L_ZOOM_16], 1000, mapShore);
setupLayer(8, &l[L_ZOOM_8], &l[L_SHORE_16], 1002, mapZoom);
setupLayer(4, &l[L_ZOOM_4], &l[L_ZOOM_8], 1003, mapZoom);
setupLayer(4, &l[L_SMOOTH_4], &l[L_ZOOM_4], 1000, mapSmooth);
// river layer chain
setupLayer(128, &l[L_ZOOM_128_RIVER], &l[L_RIVER_INIT_256], 1000, mapZoom);
setupLayer(64, &l[L_ZOOM_64_RIVER], &l[L_ZOOM_128_RIVER], 1001, mapZoom);
setupLayer(32, &l[L_ZOOM_32_RIVER], &l[L_ZOOM_64_RIVER], 1000, mapZoom);
setupLayer(16, &l[L_ZOOM_16_RIVER], &l[L_ZOOM_32_RIVER], 1001, mapZoom);
setupLayer(8, &l[L_ZOOM_8_RIVER], &l[L_ZOOM_16_RIVER], 1002, mapZoom);
setupLayer(4, &l[L_ZOOM_4_RIVER], &l[L_ZOOM_8_RIVER], 1003, mapZoom);
setupLayer(4, &l[L_RIVER_4], &l[L_ZOOM_4_RIVER], 1, mapRiver);
setupLayer(4, &l[L_SMOOTH_4_RIVER], &l[L_RIVER_4], 1000, mapSmooth);
setupMultiLayer(4, &l[L_RIVER_MIX_4], &l[L_SMOOTH_4], &l[L_SMOOTH_4_RIVER], 100, mapRiverMix);
if (mcversion <= MC_1_12)
{
setupLayer(1, &l[L_VORONOI_ZOOM_1], &l[L_RIVER_MIX_4], 10, mapVoronoiZoom);
}
else
{
return setupGeneratorMCBE17();
// ocean variants
setupLayer(256, &l[L13_OCEAN_TEMP_256], NULL, 2, mapOceanTemp);
l[L13_OCEAN_TEMP_256].oceanRnd = (OceanRnd *) malloc(sizeof(OceanRnd));
setupLayer(128, &l[L13_ZOOM_128], &l[L13_OCEAN_TEMP_256], 2001, mapZoom);
setupLayer(64, &l[L13_ZOOM_64], &l[L13_ZOOM_128], 2002, mapZoom);
setupLayer(32, &l[L13_ZOOM_32], &l[L13_ZOOM_64], 2003, mapZoom);
setupLayer(16, &l[L13_ZOOM_16], &l[L13_ZOOM_32], 2004, mapZoom);
setupLayer(8, &l[L13_ZOOM_8], &l[L13_ZOOM_16], 2005, mapZoom);
setupLayer(4, &l[L13_ZOOM_4], &l[L13_ZOOM_8], 2006, mapZoom);
setupMultiLayer(4, &l[L13_OCEAN_MIX_4], &l[L_RIVER_MIX_4], &l[L13_ZOOM_4], 100, mapOceanMix);
setupLayer(1, &l[L_VORONOI_ZOOM_1], &l[L13_OCEAN_MIX_4], 10, mapVoronoiZoom);
}
}
LayerStack setupGeneratorMC17()
{
if (biomes[plains].id == 0)
{
fprintf(stderr, "Warning: The biomes have to be initialised first using initBiomes() before any generator can be used.\n");
}
LayerStack g;
g.layerNum = 44;
g.layers = (Layer*) malloc(sizeof(Layer)*g.layerNum);
// SCALE LAYER PARENT SEED LAYER_FUNCTION
setupLayer(4096, &g.layers[ 0], NULL, 1, mapIsland);
setupLayer(2048, &g.layers[ 1], &g.layers[ 0], 2000, mapZoom);
setupLayer(2048, &g.layers[ 2], &g.layers[ 1], 1, mapAddIsland);
setupLayer(1024, &g.layers[ 3], &g.layers[ 2], 2001, mapZoom);
setupLayer(1024, &g.layers[ 4], &g.layers[ 3], 2, mapAddIsland);
setupLayer(1024, &g.layers[ 5], &g.layers[ 4], 50, mapAddIsland);
setupLayer(1024, &g.layers[ 6], &g.layers[ 5], 70, mapAddIsland);
setupLayer(1024, &g.layers[ 7], &g.layers[ 6], 2, mapRemoveTooMuchOcean);
setupLayer(1024, &g.layers[ 8], &g.layers[ 7], 2, mapAddSnow);
setupLayer(1024, &g.layers[ 9], &g.layers[ 8], 3, mapAddIsland);
setupLayer(1024, &g.layers[10], &g.layers[ 9], 2, mapCoolWarm);
setupLayer(1024, &g.layers[11], &g.layers[10], 2, mapHeatIce);
setupLayer(1024, &g.layers[12], &g.layers[11], 3, mapSpecial);
setupLayer( 512, &g.layers[13], &g.layers[12], 2002, mapZoom);
setupLayer( 256, &g.layers[14], &g.layers[13], 2003, mapZoom);
setupLayer( 256, &g.layers[15], &g.layers[14], 4, mapAddIsland);
setupLayer( 256, &g.layers[16], &g.layers[15], 5, mapAddMushroomIsland);
setupLayer( 256, &g.layers[17], &g.layers[16], 4, mapDeepOcean);
// biome layer chain
setupLayer( 256, &g.layers[18], &g.layers[17], 200, mapBiome);
setupLayer( 128, &g.layers[19], &g.layers[18], 1000, mapZoom);
setupLayer( 64, &g.layers[20], &g.layers[19], 1001, mapZoom);
setupLayer( 64, &g.layers[21], &g.layers[20], 1000, mapBiomeEdge);
// basic river layer chain, used to determine where hills generate
setupLayer( 256, &g.layers[22], &g.layers[17], 100, mapRiverInit);
setupLayer( 128, &g.layers[23], &g.layers[22], 1000, mapZoom);
setupLayer( 64, &g.layers[24], &g.layers[23], 1001, mapZoom);
setupMultiLayer(64, &g.layers[25], &g.layers[21], &g.layers[24], 1000, mapHills);
setupLayer( 64, &g.layers[26], &g.layers[25], 1001, mapRareBiome);
setupLayer( 32, &g.layers[27], &g.layers[26], 1000, mapZoom);
setupLayer( 32, &g.layers[28], &g.layers[27], 3, mapAddIsland);
setupLayer( 16, &g.layers[29], &g.layers[28], 1001, mapZoom);
setupLayer( 16, &g.layers[30], &g.layers[29], 1000, mapShore);
setupLayer( 8, &g.layers[31], &g.layers[30], 1002, mapZoom);
setupLayer( 4, &g.layers[32], &g.layers[31], 1003, mapZoom);
setupLayer( 4, &g.layers[33], &g.layers[32], 1000, mapSmooth);
// river layer chain
setupLayer( 128, &g.layers[34], &g.layers[22], 1000, mapZoom);
setupLayer( 64, &g.layers[35], &g.layers[34], 1001, mapZoom);
setupLayer( 32, &g.layers[36], &g.layers[35], 1000, mapZoom);
setupLayer( 16, &g.layers[37], &g.layers[36], 1001, mapZoom);
setupLayer( 8, &g.layers[38], &g.layers[37], 1002, mapZoom);
setupLayer( 4, &g.layers[39], &g.layers[38], 1003, mapZoom);
setupLayer( 4, &g.layers[40], &g.layers[39], 1, mapRiver);
setupLayer( 4, &g.layers[41], &g.layers[40], 1000, mapSmooth);
setupMultiLayer(4, &g.layers[42], &g.layers[33], &g.layers[41], 100, mapRiverMix);
setupLayer( 1, &g.layers[43], &g.layers[42], 10, mapVoronoiZoom);
return g;
}
LayerStack setupGeneratorMC113()
{
if (biomes[plains].id == 0)
{
fprintf(stderr, "Warning: The biomes have to be initialised first using initBiomes() before any generator can be used.\n");
}
LayerStack g;
g.layerNum = 52;
g.layers = (Layer *) malloc(sizeof(Layer) * g.layerNum);
// SCALE LAYER PARENT SEED LAYER_FUNCTION
setupLayer(4096, &g.layers[ 0], NULL, 1, mapIsland);
setupLayer(2048, &g.layers[ 1], &g.layers[ 0], 2000, mapZoom);
setupLayer(2048, &g.layers[ 2], &g.layers[ 1], 1, mapAddIsland);
setupLayer(1024, &g.layers[ 3], &g.layers[ 2], 2001, mapZoom);
setupLayer(1024, &g.layers[ 4], &g.layers[ 3], 2, mapAddIsland);
setupLayer(1024, &g.layers[ 5], &g.layers[ 4], 50, mapAddIsland);
setupLayer(1024, &g.layers[ 6], &g.layers[ 5], 70, mapAddIsland);
setupLayer(1024, &g.layers[ 7], &g.layers[ 6], 2, mapRemoveTooMuchOcean);
setupLayer(1024, &g.layers[ 8], &g.layers[ 7], 2, mapAddSnow);
setupLayer(1024, &g.layers[ 9], &g.layers[ 8], 3, mapAddIsland);
setupLayer(1024, &g.layers[10], &g.layers[ 9], 2, mapCoolWarm);
setupLayer(1024, &g.layers[11], &g.layers[10], 2, mapHeatIce);
setupLayer(1024, &g.layers[12], &g.layers[11], 3, mapSpecial);
setupLayer( 512, &g.layers[13], &g.layers[12], 2002, mapZoom);
setupLayer( 256, &g.layers[14], &g.layers[13], 2003, mapZoom);
setupLayer( 256, &g.layers[15], &g.layers[14], 4, mapAddIsland);
setupLayer( 256, &g.layers[16], &g.layers[15], 5, mapAddMushroomIsland);
setupLayer( 256, &g.layers[17], &g.layers[16], 4, mapDeepOcean);
// biome layer chain
setupLayer( 256, &g.layers[18], &g.layers[17], 200, mapBiome);
setupLayer( 128, &g.layers[19], &g.layers[18], 1000, mapZoom);
setupLayer( 64, &g.layers[20], &g.layers[19], 1001, mapZoom);
setupLayer( 64, &g.layers[21], &g.layers[20], 1000, mapBiomeEdge);
// basic river layer chain, used to determine where hills generate
setupLayer( 256, &g.layers[22], &g.layers[17], 100, mapRiverInit);
setupLayer( 128, &g.layers[23], &g.layers[22], 1000, mapZoom);
setupLayer( 64, &g.layers[24], &g.layers[23], 1001, mapZoom);
setupMultiLayer(64, &g.layers[25], &g.layers[21], &g.layers[24], 1000, mapHills113);
setupLayer( 64, &g.layers[26], &g.layers[25], 1001, mapRareBiome);
setupLayer( 32, &g.layers[27], &g.layers[26], 1000, mapZoom);
setupLayer( 32, &g.layers[28], &g.layers[27], 3, mapAddIsland);
setupLayer( 16, &g.layers[29], &g.layers[28], 1001, mapZoom);
setupLayer( 16, &g.layers[30], &g.layers[29], 1000, mapShore);
setupLayer( 8, &g.layers[31], &g.layers[30], 1002, mapZoom);
setupLayer( 4, &g.layers[32], &g.layers[31], 1003, mapZoom);
setupLayer( 4, &g.layers[33], &g.layers[32], 1000, mapSmooth);
// river layer chain
setupLayer( 128, &g.layers[34], &g.layers[22], 1000, mapZoom);
setupLayer( 64, &g.layers[35], &g.layers[34], 1001, mapZoom);
setupLayer( 32, &g.layers[36], &g.layers[35], 1000, mapZoom);
setupLayer( 16, &g.layers[37], &g.layers[36], 1001, mapZoom);
setupLayer( 8, &g.layers[38], &g.layers[37], 1002, mapZoom);
setupLayer( 4, &g.layers[39], &g.layers[38], 1003, mapZoom);
setupLayer( 4, &g.layers[40], &g.layers[39], 1, mapRiver);
setupLayer( 4, &g.layers[41], &g.layers[40], 1000, mapSmooth);
setupMultiLayer(4, &g.layers[42], &g.layers[33], &g.layers[41], 100, mapRiverMix);
// ocean variants
setupLayer( 256, &g.layers[43], NULL, 2, mapOceanTemp);
g.layers[43].oceanRnd = (OceanRnd *) malloc(sizeof(OceanRnd));
setupLayer( 128, &g.layers[44], &g.layers[43], 2001, mapZoom);
setupLayer( 64, &g.layers[45], &g.layers[44], 2002, mapZoom);
setupLayer( 32, &g.layers[46], &g.layers[45], 2003, mapZoom);
setupLayer( 16, &g.layers[47], &g.layers[46], 2004, mapZoom);
setupLayer( 8, &g.layers[48], &g.layers[47], 2005, mapZoom);
setupLayer( 4, &g.layers[49], &g.layers[48], 2006, mapZoom);
setupMultiLayer(4, &g.layers[50], &g.layers[42], &g.layers[49], 100, mapOceanMix);
setupLayer(1, &g.layers[51], &g.layers[50], 10, mapVoronoiZoom);
return g;
}
LayerStack setupGeneratorMCBE17()
{
if (biomes[plains].id == 0)
{
fprintf(stderr, "Warning: The biomes have to be initialised first using initBiomes() before any generator can be used.\n");
}
LayerStack g;
g.layerNum = 52;
g.layers = (Layer *) malloc(sizeof(Layer) * g.layerNum);
// SCALE LAYER PARENT SEED LAYER_FUNCTION
setupLayer(4096, &g.layers[ 0], NULL, 1, mapIsland);
setupLayer(2048, &g.layers[ 1], &g.layers[ 0], 2000, mapZoom);
setupLayer(2048, &g.layers[ 2], &g.layers[ 1], 1, mapAddIsland);
setupLayer(1024, &g.layers[ 3], &g.layers[ 2], 2001, mapZoom);
setupLayer(1024, &g.layers[ 4], &g.layers[ 3], 2, mapAddIsland);
setupLayer(1024, &g.layers[ 5], &g.layers[ 4], 50, mapAddIsland);
setupLayer(1024, &g.layers[ 6], &g.layers[ 5], 70, mapAddIsland);
setupLayer(1024, &g.layers[ 7], &g.layers[ 6], 2, mapRemoveTooMuchOcean);
setupLayer(1024, &g.layers[ 8], &g.layers[ 7], 2, mapAddSnow);
setupLayer(1024, &g.layers[ 9], &g.layers[ 8], 3, mapAddIsland);
setupLayer(1024, &g.layers[10], &g.layers[ 9], 2, mapCoolWarm);
setupLayer(1024, &g.layers[11], &g.layers[10], 2, mapHeatIce);
setupLayer(1024, &g.layers[12], &g.layers[11], 3, mapSpecial);
setupLayer( 512, &g.layers[13], &g.layers[12], 2002, mapZoom);
setupLayer( 256, &g.layers[14], &g.layers[13], 2003, mapZoom);
setupLayer( 256, &g.layers[15], &g.layers[14], 4, mapAddIsland);
setupLayer( 256, &g.layers[16], &g.layers[15], 5, mapAddMushroomIsland);
setupLayer( 256, &g.layers[17], &g.layers[16], 4, mapDeepOcean);
// biome layer chain
setupLayer( 256, &g.layers[18], &g.layers[17], 200, mapBiomeBE);
setupLayer( 128, &g.layers[19], &g.layers[18], 1001, mapZoom);
setupLayer( 64, &g.layers[20], &g.layers[19], 1001, mapZoom);
setupLayer( 64, &g.layers[21], &g.layers[20], 1000, mapBiomeEdge);
// basic river layer chain, used to determine where hills generate
setupLayer( 256, &g.layers[22], &g.layers[17], 100, mapRiverInit);
setupLayer( 128, &g.layers[23], &g.layers[22], 1001, mapZoom);
setupLayer( 64, &g.layers[24], &g.layers[23], 1001, mapZoom);
setupMultiLayer(64, &g.layers[25], &g.layers[21], &g.layers[24], 1000, mapHills113);
setupLayer( 64, &g.layers[26], &g.layers[25], 1001, mapRareBiome);
setupLayer( 32, &g.layers[27], &g.layers[26], 1000, mapZoom);
setupLayer( 32, &g.layers[28], &g.layers[27], 3, mapAddIsland);
setupLayer( 16, &g.layers[29], &g.layers[28], 1001, mapZoom);
setupLayer( 16, &g.layers[30], &g.layers[29], 1000, mapShore);
setupLayer( 8, &g.layers[31], &g.layers[30], 1002, mapZoom);
setupLayer( 4, &g.layers[32], &g.layers[31], 1003, mapZoom);
setupLayer( 4, &g.layers[33], &g.layers[32], 1000, mapSmooth);
// river layer chain
setupLayer( 128, &g.layers[34], &g.layers[22], 1001, mapZoom);
setupLayer( 64, &g.layers[35], &g.layers[34], 1001, mapZoom);
setupLayer( 32, &g.layers[36], &g.layers[35], 1001, mapZoom);
setupLayer( 16, &g.layers[37], &g.layers[36], 1001, mapZoom);
setupLayer( 8, &g.layers[38], &g.layers[37], 1001, mapZoom);
setupLayer( 4, &g.layers[39], &g.layers[38], 1001, mapZoom);
setupLayer( 4, &g.layers[40], &g.layers[39], 1, mapRiver);
setupLayer( 4, &g.layers[41], &g.layers[40], 1000, mapSmooth);
setupMultiLayer(4, &g.layers[42], &g.layers[33], &g.layers[41], 100, mapRiverMix);
// ocean variants
setupLayer( 256, &g.layers[43], NULL, 2, mapOceanTemp);
g.layers[43].oceanRnd = (OceanRnd *) malloc(sizeof(OceanRnd));
setupLayer( 128, &g.layers[44], &g.layers[43], 2002, mapZoom);
setupLayer( 64, &g.layers[45], &g.layers[44], 2002, mapZoom);
setupLayer( 32, &g.layers[46], &g.layers[45], 2002, mapZoom);
setupLayer( 16, &g.layers[47], &g.layers[46], 2002, mapZoom);
setupLayer( 8, &g.layers[48], &g.layers[47], 2002, mapZoom);
setupLayer( 4, &g.layers[49], &g.layers[48], 2002, mapZoom);
setupMultiLayer(4, &g.layers[50], &g.layers[42], &g.layers[49], 100, mapOceanMix);
setupLayer(1, &g.layers[51], &g.layers[50], 10, mapVoronoiZoom);
return g;
}
void freeGenerator(LayerStack g)
{
int i;
for(i = 0; i < g.layerNum; i++)
for(i = 0; i < g.layerCnt; i++)
{
if (g.layers[i].oceanRnd != NULL)
free(g.layers[i].oceanRnd);
@ -361,7 +210,7 @@ int *allocCache(Layer *layer, int sizeX, int sizeZ)
void applySeed(LayerStack *g, int64_t seed)
{
// the seed has to be applied recursively
setWorldSeed(&g->layers[g->layerNum-1], seed);
setWorldSeed(&g->layers[L_VORONOI_ZOOM_1], seed);
}
void genArea(Layer *layer, int *out, int areaX, int areaZ, int areaWidth, int areaHeight)

View File

@ -4,10 +4,10 @@
#include "layers.h"
/* Minecraft versions */
enum
enum MCversion
{
MC_1_7, MC_1_8, MC_1_9, MC_1_10, MC_1_11, MC_1_12, MC_1_13,
MCBE_1_7 = 256
MC_1_7, MC_1_8, MC_1_9, MC_1_10, MC_1_11, MC_1_12, MC_1_13, MC_1_14,
MCBE = 256
};
/* Enumeration of the layer indices in the generator. */
@ -20,7 +20,7 @@ enum
L_ADD_ISLAND_1024A,
L_ADD_ISLAND_1024B,
L_ADD_ISLAND_1024C,
L_REMOVE_TOO_MUCH_OCEAN_1024,
L_REMOVE_OCEAN_1024,
L_ADD_SNOW_1024,
L_ADD_ISLAND_1024D,
L_COOL_WARM_1024,
@ -29,7 +29,7 @@ enum
L_ZOOM_512,
L_ZOOM_256,
L_ADD_ISLAND_256,
L_ADD_MUSHROOM_ISLAND_256, /* Good entry for: mushroom biomes */
L_ADD_MUSHROOM_256, /* Good entry for: mushroom biomes */
L_DEEP_OCEAN_256,
L_BIOME_256, /* Good entry for: major biome types */
L_ZOOM_128,
@ -58,10 +58,8 @@ enum
L_RIVER_MIX_4,
L_VORONOI_ZOOM_1,
L_NUM,
// 1.13 layers
L13_OCEAN_TEMP_256 = 43,
L13_OCEAN_TEMP_256,
L13_ZOOM_128,
L13_ZOOM_64,
L13_ZOOM_32,
@ -69,9 +67,11 @@ enum
L13_ZOOM_8,
L13_ZOOM_4,
L13_OCEAN_MIX_4,
L13_VORONOI_ZOOM_1,
L13_NUM
// 1.14 layers
L14_BAMBOO_256,
L_NUM
};
@ -185,14 +185,11 @@ static const int BIOMES_L_RIVER_MIX_4[] =
STRUCT(LayerStack)
{
Layer *layers;
int layerNum;
int layerCnt;
};
/* Initialise an instance of a generator. */
LayerStack setupGenerator(const int mcversion);
LayerStack setupGeneratorMC17();
LayerStack setupGeneratorMC113();
LayerStack setupGeneratorMCBE17();
/* Cleans up and frees the generator layers */
void freeGenerator(LayerStack g);

310
layers.c
View File

@ -36,78 +36,82 @@ void initBiomes()
initAddBiome(ocean, Oceanic, Ocean, 0.5, hOceans);
initAddBiome(plains, Lush, Plains, 0.8, hDefault);
initAddBiome(desert, Warm, Desert, 2.0, hLowPlains);
initAddBiome(extremeHills, Lush, Hills, 0.2, hMidHills);
initAddBiome(mountains, Lush, Hills, 0.2, hMidHills);
initAddBiome(forest, Lush, Forest, 0.7, hDefault);
initAddBiome(taiga, Lush, Taiga, 0.25, hMidPlains);
initAddBiome(swampland, Lush, Swamp, 0.8, hPartiallySubmerged);
initAddBiome(swamp, Lush, Swamp, 0.8, hPartiallySubmerged);
initAddBiome(river, Lush, River, 0.5, hShallowWaters);
initAddBiome(hell, Warm, Hell, 2.0, hDefault);
initAddBiome(sky, Lush, Sky, 0.5, hDefault);
initAddBiome(frozenOcean, Oceanic, Ocean, 0.0, hOceans);
initAddBiome(frozenRiver, Cold, River, 0.0, hShallowWaters);
initAddBiome(icePlains, Cold, Snow, 0.0, hLowPlains);
initAddBiome(iceMountains, Cold, Snow, 0.0, hLowHills);
initAddBiome(mushroomIsland, Lush, MushroomIsland, 0.9, hLowIslands);
initAddBiome(mushroomIslandShore, Lush, MushroomIsland, 0.9, hShores);
initAddBiome(nether, Warm, Hell, 2.0, hDefault);
initAddBiome(the_end, Lush, Sky, 0.5, hDefault);
initAddBiome(frozen_ocean, Oceanic, Ocean, 0.0, hOceans);
initAddBiome(frozen_river, Cold, River, 0.0, hShallowWaters);
initAddBiome(snowy_tundra, Cold, Snow, 0.0, hLowPlains);
initAddBiome(snowy_mountains, Cold, Snow, 0.0, hLowHills);
initAddBiome(mushroom_fields, Lush, MushroomIsland, 0.9, hLowIslands);
initAddBiome(mushroom_field_shore, Lush, MushroomIsland, 0.9, hShores);
initAddBiome(beach, Lush, Beach, 0.8, hShores);
initAddBiome(desertHills, Warm, Desert, 2.0, hLowHills);
initAddBiome(forestHills, Lush, Forest, 0.7, hLowHills);
initAddBiome(taigaHills, Lush, Taiga, 0.25, hLowHills);
initAddBiome(extremeHillsEdge, Lush, Hills, 0.2, hMidHills);
initAddBiome(desert_hills, Warm, Desert, 2.0, hLowHills);
initAddBiome(wooded_hills, Lush, Forest, 0.7, hLowHills);
initAddBiome(taiga_hills, Lush, Taiga, 0.25, hLowHills);
initAddBiome(mountain_edge, Lush, Hills, 0.2, hMidHills);
initAddBiome(jungle, Lush, Jungle, 0.95, hDefault);
initAddBiome(jungleHills, Lush, Jungle, 0.95, hLowHills);
initAddBiome(jungleEdge, Lush, Jungle, 0.95, hDefault);
initAddBiome(deepOcean, Oceanic, Ocean, 0.5, hDeepOceans);
initAddBiome(stoneBeach, Lush, StoneBeach, 0.2, hRockyWaters);
initAddBiome(coldBeach, Cold, Beach, 0.05, hShores);
initAddBiome(birchForest, Lush, Forest, 0.6, hDefault);
initAddBiome(birchForestHills, Lush, Forest, 0.6, hLowHills);
initAddBiome(roofedForest, Lush, Forest, 0.7, hDefault);
initAddBiome(coldTaiga, Cold, Taiga, -0.5, hMidPlains);
initAddBiome(coldTaigaHills, Cold, Taiga, -0.5, hLowHills);
initAddBiome(megaTaiga, Lush, Taiga, 0.3, hMidPlains);
initAddBiome(megaTaigaHills, Lush, Taiga, 0.3, hLowHills);
initAddBiome(extremeHillsPlus, Lush, Hills, 0.2, hMidHills);
initAddBiome(jungle_hills, Lush, Jungle, 0.95, hLowHills);
initAddBiome(jungle_edge, Lush, Jungle, 0.95, hDefault);
initAddBiome(deep_ocean, Oceanic, Ocean, 0.5, hDeepOceans);
initAddBiome(stone_shore, Lush, StoneBeach, 0.2, hRockyWaters);
initAddBiome(snowy_beach, Cold, Beach, 0.05, hShores);
initAddBiome(birch_forest, Lush, Forest, 0.6, hDefault);
initAddBiome(birch_forest_hills, Lush, Forest, 0.6, hLowHills);
initAddBiome(dark_forest, Lush, Forest, 0.7, hDefault);
initAddBiome(snowy_taiga, Cold, Taiga, -0.5, hMidPlains);
initAddBiome(snowy_taiga_hills, Cold, Taiga, -0.5, hLowHills);
initAddBiome(giant_tree_taiga, Lush, Taiga, 0.3, hMidPlains);
initAddBiome(giant_tree_taiga_hills, Lush, Taiga, 0.3, hLowHills);
initAddBiome(wooded_mountains, Lush, Hills, 0.2, hMidHills);
initAddBiome(savanna, Warm, Savanna, 1.2, hLowPlains);
initAddBiome(savannaPlateau, Warm, Savanna, 1.0, hHighPlateaus);
initAddBiome(mesa, Warm, Mesa, 2.0, hDefault);
initAddBiome(mesaPlateau_F, Warm, Mesa, 2.0, hHighPlateaus);
initAddBiome(mesaPlateau, Warm, Mesa, 2.0, hHighPlateaus);
initAddBiome(savanna_plateau, Warm, Savanna, 1.0, hHighPlateaus);
initAddBiome(badlands, Warm, Mesa, 2.0, hDefault);
initAddBiome(wooded_badlands_plateau, Warm, Mesa, 2.0, hHighPlateaus);
initAddBiome(badlands_plateau, Warm, Mesa, 2.0, hHighPlateaus);
// TODO: determine the 1.13 biome properties
initAddBiome(skyIslandLow, Lush, Sky, 0, 0);
initAddBiome(skyIslandMedium, Lush, Sky, 0, 0);
initAddBiome(skyIslandHigh, Lush, Sky, 0, 0);
initAddBiome(skyIslandBarren, Lush, Sky, 0, 0);
initAddBiome(warmOcean, Oceanic, Ocean, 0, 0);
initAddBiome(lukewarmOcean, Oceanic, Ocean, 0, 0);
initAddBiome(coldOcean, Oceanic, Ocean, 0, 0);
initAddBiome(warmDeepOcean, Oceanic, Ocean, 0, 0);
initAddBiome(lukewarmDeepOcean, Oceanic, Ocean, 0, 0);
initAddBiome(coldDeepOcean, Oceanic, Ocean, 0, 0);
initAddBiome(frozenDeepOcean, Oceanic, Ocean, 0, 0);
initAddBiome(small_end_islands, Lush, Sky, 0.5, hDefault);
initAddBiome(end_midlands, Lush, Sky, 0.5, hDefault);
initAddBiome(end_highlands, Lush, Sky, 0.5, hDefault);
initAddBiome(end_barrens, Lush, Sky, 0.5, hDefault);
initAddBiome(warm_ocean, Oceanic, Ocean, 0.5, hOceans);
initAddBiome(lukewarm_ocean, Oceanic, Ocean, 0.5, hOceans);
initAddBiome(cold_ocean, Oceanic, Ocean, 0.5, hOceans);
initAddBiome(deep_warm_ocean, Oceanic, Ocean, 0.5, hDeepOceans);
initAddBiome(deep_lukewarm_ocean, Oceanic, Ocean, 0.5, hDeepOceans);
initAddBiome(deep_cold_ocean, Oceanic, Ocean, 0.5, hDeepOceans);
initAddBiome(deep_frozen_ocean, Oceanic, Ocean, 0.5, hDeepOceans);
initAddBiome(the_void, Void, Void, 0.5, 0);
createMutation(plains);
createMutation(desert);
createMutation(extremeHills);
createMutation(mountains);
createMutation(forest);
createMutation(taiga);
createMutation(swampland);
createMutation(icePlains);
createMutation(swamp);
createMutation(snowy_tundra);
createMutation(jungle);
createMutation(jungleEdge);
createMutation(birchForest);
createMutation(birchForestHills);
createMutation(roofedForest);
createMutation(coldTaiga);
createMutation(megaTaiga);
createMutation(megaTaigaHills);
createMutation(extremeHillsPlus);
createMutation(jungle_edge);
createMutation(birch_forest);
createMutation(birch_forest_hills);
createMutation(dark_forest);
createMutation(snowy_taiga);
createMutation(giant_tree_taiga);
createMutation(giant_tree_taiga_hills);
createMutation(wooded_mountains);
createMutation(savanna);
createMutation(savannaPlateau);
createMutation(mesa);
createMutation(mesaPlateau_F);
createMutation(mesaPlateau);
createMutation(savanna_plateau);
createMutation(badlands);
createMutation(wooded_badlands_plateau);
createMutation(badlands_plateau);
initAddBiome(bamboo_jungle, Lush, Jungle, 0.95, hDefault);
initAddBiome(bamboo_jungle_hills, Lush, Jungle, 0.95, hLowHills);
}
@ -705,7 +709,7 @@ void mapAddMushroomIsland(Layer *l, int * __restrict out, int areaX, int areaZ,
{
setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
if (mcNextInt(l, 100) == 0) {
out[x + z*areaWidth] = mushroomIsland;
out[x + z*areaWidth] = mushroom_fields;
continue;
}
}
@ -743,18 +747,26 @@ void mapDeepOcean(Layer *l, int * __restrict out, int areaX, int areaZ, int area
if (oceans > 3)
{
if (v11 == warmOcean)
v11 = warmDeepOcean;
else if (v11 == lukewarmOcean)
v11 = lukewarmDeepOcean;
else if (v11 == ocean)
v11 = deepOcean;
else if (v11 == coldOcean)
v11 = coldDeepOcean;
else if (v11 == frozenOcean)
v11 = frozenDeepOcean;
else
v11 = deepOcean;
switch (v11)
{
case warm_ocean:
v11 = deep_warm_ocean;
break;
case lukewarm_ocean:
v11 = deep_lukewarm_ocean;
break;
case ocean:
v11 = deep_ocean;
break;
case cold_ocean:
v11 = deep_cold_ocean;
break;
case frozen_ocean:
v11 = deep_frozen_ocean;
break;
default:
v11 = deep_ocean;
}
}
}
@ -765,9 +777,9 @@ void mapDeepOcean(Layer *l, int * __restrict out, int areaX, int areaZ, int area
const int warmBiomes[] = {desert, desert, desert, savanna, savanna, plains};
const int lushBiomes[] = {forest, roofedForest, extremeHills, plains, birchForest, swampland};
const int coldBiomes[] = {forest, extremeHills, taiga, plains};
const int snowBiomes[] = {icePlains, icePlains, icePlains, coldTaiga};
const int lushBiomes[] = {forest, roofedForest, mountains, plains, birchForest, swamp};
const int coldBiomes[] = {forest, mountains, taiga, plains};
const int snowBiomes[] = {snowy_tundra, snowy_tundra, snowy_tundra, coldTaiga};
void mapBiome(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidth, int areaHeight)
{
@ -783,7 +795,7 @@ void mapBiome(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidt
int hasHighBit = (id & 0xf00) >> 8;
id &= -0xf01;
if (getBiomeType(id) == Ocean || id == mushroomIsland)
if (getBiomeType(id) == Ocean || id == mushroom_fields)
{
out[idx] = id;
continue;
@ -808,14 +820,14 @@ void mapBiome(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidt
out[idx] = snowBiomes[mcNextInt(l, 4)];
break;
default:
out[idx] = mushroomIsland;
out[idx] = mushroom_fields;
}
}
}
}
const int lushBiomesBE[] = {forest, roofedForest, extremeHills, plains, plains, plains, birchForest, swampland};
const int lushBiomesBE[] = {forest, roofedForest, mountains, plains, plains, plains, birchForest, swamp};
void mapBiomeBE(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidth, int areaHeight)
{
@ -831,7 +843,7 @@ void mapBiomeBE(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWi
int hasHighBit = (id & 0xf00) >> 8;
id &= -0xf01;
if (getBiomeType(id) == Ocean || id == mushroomIsland)
if (getBiomeType(id) == Ocean || id == mushroom_fields)
{
out[idx] = id;
continue;
@ -856,7 +868,7 @@ void mapBiomeBE(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWi
out[idx] = snowBiomes[mcNextInt(l, 4)];
break;
default:
out[idx] = mushroomIsland;
out[idx] = mushroom_fields;
}
}
}
@ -886,6 +898,28 @@ void mapRiverInit(Layer *l, int * __restrict out, int areaX, int areaZ, int area
}
void mapAddBamboo(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidth, int areaHeight)
{
l->p->getMap(l->p, out, areaX, areaZ, areaWidth, areaHeight);
int x, z;
for (z = 0; z < areaHeight; z++)
{
for (x = 0; x < areaWidth; x++)
{
int idx = x + z*areaWidth;
if (out[idx] != jungle) continue;
setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
if (mcNextInt(l, 10) == 0)
{
out[idx] = bamboo_jungle;
}
}
}
}
// replaceEdgeIfNecessary() always returns 0 in the only place it is used in
// Minecraft, making it redundant.
/*
@ -935,14 +969,14 @@ void mapBiomeEdge(Layer *l, int * __restrict out, int areaX, int areaZ, int area
int v01 = out[x+0 + (z+1)*pWidth];
int v12 = out[x+1 + (z+2)*pWidth];
if (/*!replaceEdgeIfNecessary(out, x + z*areaWidth, v10, v21, v01, v12, v11, extremeHills, extremeHillsEdge) &&*/
if (/*!replaceEdgeIfNecessary(out, x + z*areaWidth, v10, v21, v01, v12, v11, mountains, mountain_edge) &&*/
!replaceEdge(out, x + z*areaWidth, v10, v21, v01, v12, v11, mesaPlateau_F, mesa) &&
!replaceEdge(out, x + z*areaWidth, v10, v21, v01, v12, v11, mesaPlateau, mesa) &&
!replaceEdge(out, x + z*areaWidth, v10, v21, v01, v12, v11, megaTaiga, taiga))
{
if (v11 == desert)
{
if (v10 != icePlains && v21 != icePlains && v01 != icePlains && v12 != icePlains)
if (v10 != snowy_tundra && v21 != snowy_tundra && v01 != snowy_tundra && v12 != snowy_tundra)
{
out[x + z*areaWidth] = v11;
}
@ -951,13 +985,15 @@ void mapBiomeEdge(Layer *l, int * __restrict out, int areaX, int areaZ, int area
out[x + z*areaWidth] = extremeHillsPlus;
}
}
else if (v11 == swampland)
else if (v11 == swamp)
{
if (v10 != desert && v21 != desert && v01 != desert && v12 != desert &&
v10 != coldTaiga && v21 != coldTaiga && v01 != coldTaiga && v12 != coldTaiga &&
v10 != icePlains && v21 != icePlains && v01 != icePlains && v12 != icePlains)
v10 != coldTaiga && v21 != coldTaiga && v01 != coldTaiga && v12 != coldTaiga &&
v10 != snowy_tundra && v21 != snowy_tundra && v01 != snowy_tundra && v12 != snowy_tundra)
{
if (v10 != jungle && v12 != jungle && v21 != jungle && v01 != jungle)
if (v10 != jungle && v12 != jungle && v21 != jungle && v01 != jungle &&
v10 != bamboo_jungle && v12 != bamboo_jungle &&
v21 != bamboo_jungle && v01 != bamboo_jungle)
out[x + z*areaWidth] = v11;
else
out[x + z*areaWidth] = jungleEdge;
@ -1022,30 +1058,31 @@ void mapHills(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidt
{
int hillID = a11;
switch(a11){
switch(a11)
{
case desert:
hillID = desertHills; break;
hillID = desert_hills; break;
case forest:
hillID = forestHills; break;
hillID = wooded_hills; break;
case birchForest:
hillID = birchForestHills; break;
case roofedForest:
hillID = plains; break;
case taiga:
hillID = taigaHills; break;
hillID = taiga_hills; break;
case megaTaiga:
hillID = megaTaigaHills; break;
case coldTaiga:
hillID = coldTaigaHills; break;
case plains:
hillID = (mcNextInt(l, 3) == 0) ? forestHills : forest; break;
case icePlains:
hillID = iceMountains; break;
hillID = (mcNextInt(l, 3) == 0) ? wooded_hills : forest; break;
case snowy_tundra:
hillID = snowy_mountains; break;
case jungle:
hillID = jungleHills; break;
case ocean:
hillID = deepOcean; break;
case extremeHills:
case mountains:
hillID = extremeHillsPlus; break;
case savanna:
hillID = savannaPlateau; break;
@ -1136,39 +1173,41 @@ void mapHills113(Layer *l, int * __restrict out, int areaX, int areaZ, int areaW
{
int hillID = a11;
switch(a11){
switch(a11)
{
case desert:
hillID = desertHills; break;
hillID = desert_hills; break;
case forest:
hillID = forestHills; break;
hillID = wooded_hills; break;
case birchForest:
hillID = birchForestHills; break;
case roofedForest:
hillID = plains; break;
case taiga:
hillID = taigaHills; break;
hillID = taiga_hills; break;
case megaTaiga:
hillID = megaTaigaHills; break;
case coldTaiga:
hillID = coldTaigaHills; break;
case plains:
hillID = (mcNextInt(l, 3) == 0) ? forestHills : forest; break;
case icePlains:
hillID = iceMountains; break;
hillID = (mcNextInt(l, 3) == 0) ? wooded_hills : forest; break;
case snowy_tundra:
hillID = snowy_mountains; break;
case jungle:
hillID = jungleHills; break;
case bamboo_jungle:
hillID = bamboo_jungle_hills; break;
case ocean:
hillID = deepOcean; break;
case extremeHills:
case mountains:
hillID = extremeHillsPlus; break;
case savanna:
hillID = savannaPlateau; break;
default:
if (equalOrPlateau(a11, mesaPlateau_F))
hillID = mesa;
else if ((a11 == deepOcean || a11 == lukewarmDeepOcean ||
a11 == coldDeepOcean || a11 == frozenDeepOcean) &&
mcNextInt(l, 3) == 0)
else if ((a11 == deep_ocean || a11 == deep_lukewarm_ocean || a11 == deep_cold_ocean || a11 == deep_frozen_ocean) &&
mcNextInt(l, 3) == 0)
hillID = (mcNextInt(l, 2) == 0) ? plains : forest;
break;
}
@ -1365,12 +1404,12 @@ void mapShore(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidt
int biome = biomeExists(v11) ? v11 : 0;
if (v11 == mushroomIsland)
if (v11 == mushroom_fields)
{
if (v10 != ocean && v21 != ocean && v01 != ocean && v12 != ocean)
out[x + z*areaWidth] = v11;
else
out[x + z*areaWidth] = mushroomIslandShore;
out[x + z*areaWidth] = mushroom_field_shore;
}
else if (/*biome < 128 &&*/ getBiomeType(biome) == Jungle)
{
@ -1386,7 +1425,7 @@ void mapShore(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidt
out[x + z*areaWidth] = jungleEdge;
}
}
else if (v11 != extremeHills && v11 != extremeHillsPlus && v11 != extremeHillsEdge)
else if (v11 != mountains && v11 != extremeHillsPlus && v11 != mountain_edge)
{
if (isBiomeSnowy(biome))
{
@ -1394,7 +1433,7 @@ void mapShore(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidt
}
else if (v11 != mesa && v11 != mesaPlateau_F)
{
if (v11 != ocean && v11 != deepOcean && v11 != river && v11 != swampland)
if (v11 != ocean && v11 != deepOcean && v11 != river && v11 != swamp)
{
if (!isOceanic(v10) && !isOceanic(v21) && !isOceanic(v01) && !isOceanic(v12))
out[x + z*areaWidth] = v11;
@ -1460,10 +1499,10 @@ void mapRiverMix(Layer *l, int * __restrict out, int areaX, int areaZ, int areaW
{
if (out[idx] == river)
{
if (buf[idx] == icePlains)
out[idx] = frozenRiver;
else if (buf[idx] == mushroomIsland || buf[idx] == mushroomIslandShore)
out[idx] = mushroomIslandShore;
if (buf[idx] == snowy_tundra)
out[idx] = frozen_river;
else if (buf[idx] == mushroom_fields || buf[idx] == mushroom_field_shore)
out[idx] = mushroom_field_shore;
else
out[idx] = out[idx] & 255;
}
@ -1580,13 +1619,13 @@ void mapOceanTemp(Layer *l, int * __restrict out, int areaX, int areaZ, int area
double tmp = getOceanTemp(rnd, (x + areaX) / 8.0, (z + areaZ) / 8.0, 0);
if (tmp > 0.4)
out[x + z*areaWidth] = warmOcean;
out[x + z*areaWidth] = warm_ocean;
else if (tmp > 0.2)
out[x + z*areaWidth] = lukewarmOcean;
out[x + z*areaWidth] = lukewarm_ocean;
else if (tmp < -0.4)
out[x + z*areaWidth] = frozenOcean;
out[x + z*areaWidth] = frozen_ocean;
else if (tmp < -0.2)
out[x + z*areaWidth] = coldOcean;
out[x + z*areaWidth] = cold_ocean;
else
out[x + z*areaWidth] = ocean;
}
@ -1638,15 +1677,15 @@ void mapOceanMix(Layer *l, int * __restrict out, int areaX, int areaZ, int areaW
if (isOceanic(nearbyID)) continue;
if (oceanID == warmOcean)
if (oceanID == warm_ocean)
{
out[x + z*areaWidth] = lukewarmOcean;
out[x + z*areaWidth] = lukewarm_ocean;
goto loop_x;
}
if (oceanID == frozenOcean)
if (oceanID == frozen_ocean)
{
out[x + z*areaWidth] = coldOcean;
out[x + z*areaWidth] = cold_ocean;
goto loop_x;
}
}
@ -1654,25 +1693,20 @@ void mapOceanMix(Layer *l, int * __restrict out, int areaX, int areaZ, int areaW
if (landID == deepOcean)
{
if (oceanID == lukewarmOcean)
switch (oceanID)
{
out[x + z*areaWidth] = lukewarmDeepOcean;
continue;
}
if (oceanID == ocean)
{
out[x + z*areaWidth] = deepOcean;
continue;
}
if (oceanID == coldOcean)
{
out[x + z*areaWidth] = coldDeepOcean;
continue;
}
if (oceanID == frozenOcean)
{
out[x + z*areaWidth] = frozenDeepOcean;
continue;
case lukewarm_ocean:
oceanID = deep_lukewarm_ocean;
break;
case ocean:
oceanID = deep_ocean;
break;
case cold_ocean:
oceanID = deep_cold_ocean;
break;
case frozen_ocean:
oceanID = deep_frozen_ocean;
break;
}
}

124
layers.h
View File

@ -7,6 +7,9 @@
#include <stdint.h>
#include <inttypes.h>
#ifndef NULL
#define NULL ((void*)0)
#endif
#if defined USE_SIMD && __AVX2__
#include <emmintrin.h>
@ -29,19 +32,99 @@
enum BiomeID
{
none = -1,
ocean = 0, plains, desert, extremeHills, forest, taiga, swampland, river, hell, sky, // 0-9
frozenOcean, frozenRiver, icePlains, iceMountains, mushroomIsland, mushroomIslandShore, beach, desertHills, forestHills, taigaHills, // 10-19
extremeHillsEdge, jungle, jungleHills, jungleEdge, deepOcean, stoneBeach, coldBeach, birchForest, birchForestHills, roofedForest, // 20-29
coldTaiga, coldTaigaHills, megaTaiga, megaTaigaHills, extremeHillsPlus, savanna, savannaPlateau, mesa, mesaPlateau_F, mesaPlateau, // 30-39
// 1.13
skyIslandLow, skyIslandMedium, skyIslandHigh, skyIslandBarren, warmOcean, lukewarmOcean, coldOcean, warmDeepOcean, lukewarmDeepOcean, coldDeepOcean, // 40-49
frozenDeepOcean,
BIOME_NUM
// 0
ocean = 0,
plains,
desert,
mountains, extremeHills = mountains,
forest,
taiga,
swamp, swampland = swamp,
river,
nether, hell = nether,
the_end, sky = the_end,
// 10
frozen_ocean, frozenOcean = frozen_ocean,
frozen_river, frozenRiver = frozen_river,
snowy_tundra, icePlains = snowy_tundra,
snowy_mountains, iceMountains = snowy_mountains,
mushroom_fields, mushroomIsland = mushroom_fields,
mushroom_field_shore, mushroomIslandShore = mushroom_field_shore,
beach,
desert_hills, desertHills = desert_hills,
wooded_hills, forestHills = wooded_hills,
taiga_hills, taigaHills = taiga_hills,
// 20
mountain_edge, extremeHillsEdge = mountain_edge,
jungle,
jungle_hills, jungleHills = jungle_hills,
jungle_edge, jungleEdge = jungle_edge,
deep_ocean, deepOcean = deep_ocean,
stone_shore, stoneBeach = stone_shore,
snowy_beach, coldBeach = snowy_beach,
birch_forest, birchForest = birch_forest,
birch_forest_hills, birchForestHills = birch_forest_hills,
dark_forest, roofedForest = dark_forest,
// 30
snowy_taiga, coldTaiga = snowy_taiga,
snowy_taiga_hills, coldTaigaHills = snowy_taiga_hills,
giant_tree_taiga, megaTaiga = giant_tree_taiga,
giant_tree_taiga_hills, megaTaigaHills = giant_tree_taiga_hills,
wooded_mountains, extremeHillsPlus = wooded_mountains,
savanna,
savanna_plateau, savannaPlateau = savanna_plateau,
badlands, mesa = badlands,
wooded_badlands_plateau, mesaPlateau_F = wooded_badlands_plateau,
badlands_plateau, mesaPlateau = badlands_plateau,
// 40 -- 1.13
small_end_islands,
end_midlands,
end_highlands,
end_barrens,
warm_ocean, warmOcean = warm_ocean,
lukewarm_ocean, lukewarmOcean = lukewarm_ocean,
cold_ocean, coldOcean = cold_ocean,
deep_warm_ocean, warmDeepOcean = deep_warm_ocean,
deep_lukewarm_ocean, lukewarmDeepOcean = deep_lukewarm_ocean,
deep_cold_ocean, coldDeepOcean = deep_cold_ocean,
// 50
deep_frozen_ocean, frozenDeepOcean = deep_frozen_ocean,
BIOME_NUM,
the_void = 127,
// mutated variants
sunflower_plains = plains+128,
desert_lakes = desert+128,
gravelly_mountains = mountains+128,
flower_forest = forest+128,
taiga_mountains = taiga+128,
swamp_hills = swamp+128,
ice_spikes = snowy_tundra+128,
modified_jungle = jungle+128,
modified_jungle_edge = jungle_edge+128,
tall_birch_forest = birch_forest+128,
tall_birch_hills = birch_forest_hills+128,
dark_forest_hills = dark_forest+128,
snowy_taiga_mountains = snowy_taiga+128,
giant_spruce_taiga = giant_tree_taiga+128,
giant_spruce_taiga_hills = giant_tree_taiga_hills+128,
modified_gravelly_mountains = wooded_mountains+128,
shattered_savanna = savanna+128,
shattered_savanna_plateau = savanna_plateau+128,
eroded_badlands = badlands+128,
modified_wooded_badlands_plateau = wooded_badlands_plateau+128,
modified_badlands_plateau = badlands_plateau+128,
// 1.14
bamboo_jungle = 168,
bamboo_jungle_hills = 169
};
enum BiomeType
{
Ocean, Plains, Desert, Hills, Forest, Taiga, Swamp, River, Hell, Sky, Snow, MushroomIsland, Beach, Jungle, StoneBeach, Savanna, Mesa, BTYPE_NUM
Void = -1,
Ocean, Plains, Desert, Hills, Forest, Taiga, Swamp, River, Hell, Sky, Snow, MushroomIsland, Beach, Jungle, StoneBeach, Savanna, Mesa,
BTYPE_NUM
};
enum BiomeTempCategory
@ -141,8 +224,8 @@ static inline int canBeNeighbors(int id1, int id2)
static inline int isShallowOcean(int id)
{
return id == ocean || id == frozenOcean ||
id == warmOcean || id == lukewarmOcean || id == coldOcean;
return id == ocean || id == frozen_ocean ||
id == warm_ocean || id == lukewarm_ocean || id == cold_ocean;
}
static inline int isOceanic(int id)
@ -150,15 +233,15 @@ static inline int isOceanic(int id)
switch(id)
{
case ocean:
case deepOcean:
case warmOcean:
case warmDeepOcean:
case lukewarmOcean:
case lukewarmDeepOcean:
case coldOcean:
case coldDeepOcean:
case frozenOcean:
case frozenDeepOcean:
case deep_ocean:
case warm_ocean:
case deep_warm_ocean:
case lukewarm_ocean:
case deep_lukewarm_ocean:
case cold_ocean:
case deep_cold_ocean:
case frozen_ocean:
case deep_frozen_ocean:
return 1;
default:
return 0;
@ -455,6 +538,7 @@ void mapAddMushroomIsland(Layer *l, int * __restrict out, int x, int z, int w, i
void mapDeepOcean(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapBiome(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapBiomeBE(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapAddBamboo(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapRiverInit(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapBiomeEdge(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapHills(Layer *l, int * __restrict out, int x, int z, int w, int h);

View File

@ -111,6 +111,9 @@ void initBiomeColours(unsigned char biomeColours[256][3])
setBiomeColour(biomeColours, mesa+128, 217, 69, 21);
setBiomeColour(biomeColours, mesaPlateau_F+128, 176, 151, 101);
setBiomeColour(biomeColours, mesaPlateau+128, 202, 140, 101);
setBiomeColour(biomeColours, bamboo_jungle, 118, 142, 20);
setBiomeColour(biomeColours, bamboo_jungle_hills, 59, 71, 10);
}
void initBiomeTypeColours(unsigned char biomeColours[256][3])