1 local stone = BlockSystem:get_def("game:stone")
2 local dirt = BlockSystem:get_def("game:dirt")
3 local grass = BlockSystem:get_def("game:grass")
4 local leaves = BlockSystem:get_def("game:leaves")
5 local tree = BlockSystem:get_def("game:tree")
7 local grass_layer_start, grass_layer_end = 0, 30
8 local grass_layer_height = grass_layer_end - grass_layer_start
10 function MapGen.generate(minp, maxp)
12 local minx, miny, minz, maxx, maxy, maxz = minp.x, minp.y, minp.z, maxp.x - 1, maxp.y - 1, maxp.z - 1
15 local grass_layer = math.floor(grass_layer_start + grass_layer_height * perlin:noise(x / grass_layer_height, z / grass_layer_height))
17 local pos = glm.vec3(x - minx, y - miny, z - minz)
19 if y <= grass_layer - 5 then
21 elseif y <= grass_layer - 1 then
23 elseif y <= grass_layer then
27 data[WorldSystem.Chunk.get_pos_hash(pos)] = WorldSystem.Block(pos, block)
67 function MapGen:add_tree(chunk, tree_pos)
68 for i, p in ipairs(tree_blocks) do
73 local pos = tree_pos + p
74 if chunk:get_pos_hash(pos) then
75 chunk:add_block(pos, block)