-
Notifications
You must be signed in to change notification settings - Fork 8
/
basic_test.cpp
166 lines (138 loc) · 5.11 KB
/
basic_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#include <MinecraftWorld.h>
#include <parse_bedrock.h>
#include <EntityJSON.h>
#include <BlockEntityJSON.h>
#include <VillageJSON.h>
#include <BiomeVectors.h>
#include <ElevationVectors.h>
#include <CaveVectors.h>
#include <ResourceVectors.h>
#include <fstream>
#include <iomanip>
#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>
#define UNUSED(x) (void)(x)
int main(int argc, char** argv) {
std::string dbpath;
boost::program_options::options_description cmdline_options("Allowed options");
cmdline_options.add_options()
("help", "produce this help message")
("db_path",
boost::program_options::value<std::string>(&dbpath),
"input db path")
;
boost::program_options::variables_map vm;
try {
boost::program_options::store(boost::program_options::command_line_parser(argc, argv)
.options(cmdline_options)
.run(),
vm);
boost::program_options::notify(vm);
} catch (std::exception &e) {
std::cout << e.what() << "\n";
std::cout << cmdline_options << "\n";
return 1;
}
if (dbpath.empty()) {
std::cout << "please give the path to your db directory.\n";
std::cout << cmdline_options << "\n";
return 1;
}
MinecraftWorld world;
//std::string dbpath = "/bubba/electronicsDS/minecraft/sampledata/2019.11.26.04.00.53/worlds/Bedrock level/db";
//std::string dbpath = "/bubba/electronicsDS/minecraft/sampledata/2020.02.04.04.00.53/worlds/Bedrock level/db";
// http://www.trulybedrock.com/downloads/
//std::string dbpath = "/bubba/electronicsDS/minecraft/sampledata/TBSeason0/db";
//std::string dbpath = "/bubba/electronicsDS/minecraft/sampledata/myserver_feb_13/Bedrock level/db";
parse_bedrock(dbpath, world);
BlockType::print_block_types();
# if 0
std::cout << "iterating locations\n";
int diamond = BlockType::get_block_type_id_by_name("minecraft:diamond_ore ()");
std::cout << "filtering by " << diamond << "\n";
for (auto scix : world.theworld) {
int chunkx = scix.first;
UNUSED(chunkx);
for (auto sciy : scix.second) {
int chunky = sciy.first;
UNUSED(chunky);
for (auto sciz : sciy.second) {
int chunkz = sciz.first;
UNUSED(chunkz);
auto sc = sciz.second;
for (auto iter=sc.begin(diamond); iter!=sc.end(); ++iter) {
//for (auto loc : sc) {
auto loc = *iter;
BlockType bt = BlockType::get_block_type_by_id(loc.type);
std::cout << "at " << loc.x << ", " << loc.y << ", " << loc.z << ":" << bt.get_name() << "\n";
}
}
}
}
#endif
{
ResourceVectors resourcevectors(world);
resourcevectors.write("map/resources.json");
}
{
CaveVectors cavevectors(world);
cavevectors.write("map/caves.json");
}
boost::filesystem::create_directory("map");
world.write_world_json("map/world.json");
write_biome_properties("map/biomeproperties.json");
{
BiomeVectors bvectors;
for(auto it1 : world.chunk_biomes) {
int chunkx = it1.first;
for(auto it2 : it1.second) {
int chunkz = it2.first;
bvectors.add_chunk(chunkx, chunkz, it2.second);
}
}
bvectors.write("map/biomes.json");
}
// elevation stuff generates really large files. 100MB+ for a not that large world.
if (0) {
ElevationVectors evectors(world);
for(auto it1 : world.chunk_elevation) {
int chunkx = it1.first;
//if (chunkx%2) { continue; }
for(auto it2 : it1.second) {
int chunkz = it2.first;
//if (chunkz%2) { continue; }
evectors.add_chunk(chunkx, chunkz, it2.second);
#if 0
std::cout << "elevations for " << chunkx << ", " << chunkz << "\n";
for(int z=0; z<16; z++) {
for(int x=0; x<16; x++) {
std::cout << std::setw(4) << it2.second[x][z] << " ";
}
std::cout << "\n";
}
std::cout << "\n";
#endif
}
}
evectors.write("map/elevations.json");
}
if (1) {
std::cout << "computing elevations\n";
ElevationVectors evectors(world);
for(auto it1 : world.top_earthly) {
int chunkx = it1.first;
//if (chunkx%2) { continue; }
for(auto it2 : it1.second) {
int chunkz = it2.first;
//if (chunkz%2) { continue; }
evectors.add_chunk(chunkx, chunkz, it2.second);
}
}
evectors.write("map/elevations.json");
}
world.populate_entity_table();
GenerateVillageJSON(world, "map/villages.json");
GenerateEntityJSON(world, "map/entities.json");
GenerateBlockEntityJSON(world, "map/block_entities.json");
return 0;
}