生成的biome.png为纯黑色。
日志输出:
[INFO] [:147 @ init_block_color_palette_from_file]:Load json success: D:\code\c++\bedrock-level-cc84ceb0f5abd21402076ab7350d709b6ce23e24\data\colors\block_color.json
[INFO] [:215 @ init_block_color_palette_from_file]:Water blocks:
[INFO] [:217 @ init_block_color_palette_from_file]: - minecraft:water
[INFO] [:217 @ init_block_color_palette_from_file]: - minecraft:flowing_water
[INFO] [:219 @ init_block_color_palette_from_file]:Leaves blocks:
[INFO] [:221 @ init_block_color_palette_from_file]: - minecraft:mangrove_leaves
[INFO] [:221 @ init_block_color_palette_from_file]: - minecraft:leaves
[INFO] [:221 @ init_block_color_palette_from_file]: - minecraft:leaves2
[INFO] [:221 @ init_block_color_palette_from_file]: - minecraft:vine
[INFO] [:223 @ init_block_color_palette_from_file]:Grass blocks:
[INFO] [:225 @ init_block_color_palette_from_file]: - minecraft:grass
代码:
#include <iostream>
#include <vector>
#include "bedrock_level.h"
#include "color.h"
int main() {
// bl::init_biome_color_palette_from_file(
// R"(D:\code\c++\bedrock-level-cc84ceb0f5abd21402076ab7350d709b6ce23e24\data\colors\biome_color.json)");
bl::init_block_color_palette_from_file(
R"(D:\code\c++\bedrock-level-cc84ceb0f5abd21402076ab7350d709b6ce23e24\data\colors\block_color.json)");
const std::string path =
R"(C:\Users\65288\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang\minecraftWorlds\FMNVOWr2L1A=)";
bl::bedrock_level level;
if (!level.open(path)) {
fprintf(stderr, "Can not open level %s", path.c_str());
return -1;
}
// auto spawn_pos = level.dat().spawn_position();
auto center_chunk_pos = bl::chunk_pos{0, 0, 0};
const int DIM = 0;
const int R = 0;
auto minP = bl::chunk_pos{center_chunk_pos.x - R, center_chunk_pos.z - R, DIM};
auto maxP = bl::chunk_pos{center_chunk_pos.x + R, center_chunk_pos.z + R, DIM};
const int W = maxP.x - minP.x + 1;
const int H = maxP.z - minP.z + 1;
std::vector<std::vector<bl::color>> cm(H * 16, std::vector<bl::color>(W * 16, bl::color()));
for (int x = minP.x; x <= maxP.x; x++) {
for (int z = minP.z; z <= maxP.z; z++) {
auto *chunk = level.get_chunk({x, z, DIM});
if (chunk) {
auto sx = (x - minP.x) * 16;
auto sz = (z - minP.z) * 16;
for (int xx = 0; xx < 16; xx++) {
for (int zz = 0; zz < 16; zz++) {
int y = chunk->get_height(xx, zz);
auto name = chunk->get_block(xx, y, zz);
cm[sz + zz][sx + xx] = chunk->get_block_color(xx, y, zz);
}
}
}
}
}
bl::export_image(cm, 1, "biome.png");
return 0;
}
生成的
biome.png为纯黑色。日志输出:
代码: