mirror of
https://github.com/Cubitect/cubiomes.git
synced 2025-09-25 13:00:27 -04:00
Adjusted examples to reflect API changes.
This commit is contained in:
parent
6097e42ea6
commit
7dea686d31
28
README.md
28
README.md
@ -27,9 +27,10 @@ int main()
|
|||||||
// properties such as the category and temperature of each biome.
|
// properties such as the category and temperature of each biome.
|
||||||
initBiomes();
|
initBiomes();
|
||||||
|
|
||||||
// Allocate and initialize a stack of biome layers that reflects the biome
|
// Initialize a stack of biome layers that reflects the biome generation of
|
||||||
// generation of Minecraft 1.14
|
// Minecraft 1.16
|
||||||
LayerStack g = setupGenerator(MC_1_14);
|
LayerStack g;
|
||||||
|
setupGenerator(&g, MC_1_16);
|
||||||
|
|
||||||
int64_t seed;
|
int64_t seed;
|
||||||
Pos pos = {0,0}; // block position to be checked
|
Pos pos = {0,0}; // block position to be checked
|
||||||
@ -41,7 +42,7 @@ int main()
|
|||||||
applySeed(&g, seed);
|
applySeed(&g, seed);
|
||||||
|
|
||||||
// To get the biome at single block position we can use getBiomeAtPos().
|
// To get the biome at single block position we can use getBiomeAtPos().
|
||||||
int biomeID = getBiomeAtPos(g, pos);
|
int biomeID = getBiomeAtPos(&g, pos);
|
||||||
if (biomeID == jungle_edge)
|
if (biomeID == jungle_edge)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -49,9 +50,6 @@ int main()
|
|||||||
printf("Seed %" PRId64 " has a Junge Edge biome at block position "
|
printf("Seed %" PRId64 " has a Junge Edge biome at block position "
|
||||||
"(%d, %d).\n", seed, pos.x, pos.z);
|
"(%d, %d).\n", seed, pos.x, pos.z);
|
||||||
|
|
||||||
// Clean up.
|
|
||||||
freeGenerator(g);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -87,8 +85,9 @@ int main()
|
|||||||
// Initialize a colour map for biomes.
|
// Initialize a colour map for biomes.
|
||||||
initBiomeColours(biomeColours);
|
initBiomeColours(biomeColours);
|
||||||
|
|
||||||
// Allocate and initialize a stack of biome layers.
|
// Initialize a stack of biome layers.
|
||||||
LayerStack g = setupGenerator(MC_1_14);
|
LayerStack g;
|
||||||
|
setupGenerator(&g, MC_1_16);
|
||||||
// Extract the desired layer.
|
// Extract the desired layer.
|
||||||
Layer *layer = &g.layers[L_SHORE_16];
|
Layer *layer = &g.layers[L_SHORE_16];
|
||||||
|
|
||||||
@ -99,20 +98,19 @@ int main()
|
|||||||
unsigned int imgWidth = areaWidth*scale, imgHeight = areaHeight*scale;
|
unsigned int imgWidth = areaWidth*scale, imgHeight = areaHeight*scale;
|
||||||
|
|
||||||
// Allocate a sufficient buffer for the biomes and for the image pixels.
|
// Allocate a sufficient buffer for the biomes and for the image pixels.
|
||||||
int *biomes = allocCache(layer, areaWidth, areaHeight);
|
int *biomeIds = allocCache(layer, areaWidth, areaHeight);
|
||||||
unsigned char *rgb = (unsigned char *) malloc(3*imgWidth*imgHeight);
|
unsigned char *rgb = (unsigned char *) malloc(3*imgWidth*imgHeight);
|
||||||
|
|
||||||
// Apply the seed only for the required layers and generate the area.
|
// Apply the seed only for the required layers and generate the area.
|
||||||
setWorldSeed(layer, seed);
|
setWorldSeed(layer, seed);
|
||||||
genArea(layer, biomes, areaX, areaZ, areaWidth, areaHeight);
|
genArea(layer, biomeIds, areaX, areaZ, areaWidth, areaHeight);
|
||||||
|
|
||||||
// Map the biomes to a color buffer and save to an image.
|
// Map the biomes to a color buffer and save to an image.
|
||||||
biomesToImage(rgb, biomeColours, biomes, areaWidth, areaHeight, scale, 2);
|
biomesToImage(rgb, biomeColours, biomeIds, areaWidth, areaHeight, scale, 2);
|
||||||
savePPM("biomes_at_layer.ppm", rgb, imgWidth, imgHeight);
|
savePPM("biomes_at_layer.ppm", rgb, imgWidth, imgHeight);
|
||||||
|
|
||||||
// Clean up.
|
// Clean up.
|
||||||
freeGenerator(g);
|
free(biomeIds);
|
||||||
free(biomes);
|
|
||||||
free(rgb);
|
free(rgb);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -136,7 +134,7 @@ This classic type of finder uses several optimisations reguarding positioning of
|
|||||||
|
|
||||||
`./find_quadhut 0 0`
|
`./find_quadhut 0 0`
|
||||||
|
|
||||||
will start a search with a regional positioning around the origin. (Actually the huts will be positioned in regions (-1,-1) to (0,0) this way.)
|
will start a search with a regional positioning around the origin. (Actually the huts will be positioned in regions (-1,-1) to (0,0) this way.)
|
||||||
|
|
||||||
To my knowlege, as of the time of writing, this is fastest single-thread quad-hut-finder out there. However, note that the current implementation of the biome finding optimisations causes the finder to miss some seeds (< 2%) in favour for speed.
|
To my knowlege, as of the time of writing, this is fastest single-thread quad-hut-finder out there. However, note that the current implementation of the biome finding optimisations causes the finder to miss some seeds (< 2%) in favour for speed.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user