local REALM_START = vector.new(-500, -500, -500) local REALM_END = vector.new(500, 500, 500) local function intersection(min, max, b, c) return min.x < c.x and max.x > b.x and min.y < c.y and max.y > b.y and min.z < c.z and max.z > b.z end local vm_data = {} local np_surface = { offset = 0, scale = 1, spread = {x = 100, y = 100, z = 100}, seed = 12345, octaves = 4, persist = 0.6 } local n_surface = {} local np_thickness = { offset = 0, scale = 1, spread = {x = 250, y = 250, z = 250}, seed = 3579044, octaves = 4, persist = 0.6 } local n_thickness = {} local c_chest = minetest.get_content_id("chest_with_everything:chest") local c_air = minetest.get_content_id("air") local c_stone = minetest.get_content_id("stone") minetest.register_on_generated(function(vm, min, max) -- AABB intersection, to determine whether this block should be considered for this mapgen. if not intersection(min, max, REALM_START, REALM_END) then return end local va = VoxelArea(vm:get_emerged_area()) local sides2d = {x = max.x - min.x + 1, y = max.z - min.z + 1} local surface = minetest.get_perlin_map(np_surface, sides2d) surface:get_2d_map_flat({x = min.x, y = min.z}, n_surface) local thickness = minetest.get_perlin_map(np_thickness, sides2d) thickness:get_2d_map_flat({x = min.x, y = min.z}, n_thickness) vm:get_data(vm_data) local ni = 1 for z = min.z, max.z do for x = min.x, max.x do local r = math.sqrt(x *x + z *z) local bottom = -(3 +n_thickness[ni] *5 +((1 -(r /100))^0.5 *50)) local top = (n_surface[ni] +1) *8 *(1 -(math.max(0, r -90) /10))^0.5 for y = min.y, max.y do if y > bottom and y < top then local vi = va:index(x, y, z) vm_data[vi] = c_stone end if x == 0 and z == 0 and y == math.round(top) then local vi = va:index(x, y, z) vm_data[vi] = c_chest end end ni = ni +1 end end vm:set_data(vm_data) end)