WorldGenerator.cpp 597 B

12345678910111213141516171819
  1. #include "server/world/WorldGenerator.h"
  2. #include "common/world/HighMap.h"
  3. WorldGenerator::WorldGenerator(const BlockRegistry& blocks, World& world)
  4. : blocks(blocks), world(world) {
  5. }
  6. void WorldGenerator::generate() {
  7. const Block& stone = blocks.getBlock("stone");
  8. HighMap map(world.getSize(), world.getHeight());
  9. for(int x = 0; x < world.getSize(); x++) {
  10. for(int z = 0; z < world.getSize(); z++) {
  11. int height = map.getHeight(x, z);
  12. for(int y = 0; y < height; y++) {
  13. world.setBlock(x, y, z, stone);
  14. }
  15. }
  16. }
  17. }