12345678910111213141516171819 |
- #include "server/world/WorldGenerator.h"
- #include "common/world/HighMap.h"
- WorldGenerator::WorldGenerator(const BlockRegistry& blocks, World& world)
- : blocks(blocks), world(world) {
- }
- void WorldGenerator::generate() {
- const Block& stone = blocks.getBlock("stone");
- HighMap map(world.getSize(), world.getHeight());
- for(int x = 0; x < world.getSize(); x++) {
- for(int z = 0; z < world.getSize(); z++) {
- int height = map.getHeight(x, z);
- for(int y = 0; y < height; y++) {
- world.setBlock(x, y, z, stone);
- }
- }
- }
- }
|