diff --git a/terrain.lua b/terrain.lua index 136f16c..93f9fc3 100644 --- a/terrain.lua +++ b/terrain.lua @@ -53,22 +53,22 @@ loud_walking.bevel = bevel local function connection(x, y, z) - local min_x = math_floor((x + 32) / csize.x) - local min_y = math_floor((y + 32) / csize.y) - local min_z = math_floor((z + 32) / csize.z) + local min_x = math_floor((x + 32) / csize.x) + local min_y = math_floor((y + 32) / csize.y) + local min_z = math_floor((z + 32) / csize.z) - --local seed_noise = minetest.get_perlin({offset = 0, scale = 32768, - --seed = 5202, spread = {x = 80, y = 80, z = 80}, octaves = 2, - --persist = 0.4, lacunarity = 2}) - --math.randomseed(seed_noise:get2d({x=minp.x, y=minp.z})) + --local seed_noise = minetest.get_perlin({offset = 0, scale = 32768, + --seed = 5202, spread = {x = 80, y = 80, z = 80}, octaves = 2, + --persist = 0.4, lacunarity = 2}) + --math.randomseed(seed_noise:get2d({x=minp.x, y=minp.z})) - local ct = min_x % 2 + min_y % 2 + min_z % 2 - local r = min_x % 2 + 2 * (min_y % 2) + 4 * (min_z % 2) - if ct == 1 then - return r - end + local ct = min_x % 2 + min_y % 2 + min_z % 2 + local r = min_x % 2 + 2 * (min_y % 2) + 4 * (min_z % 2) + if ct == 1 then + return r + end - return nil + return nil end @@ -91,10 +91,10 @@ end local cave_stones = { 'default:stone', - --"loud_walking:stone_with_moss", - --"loud_walking:stone_with_lichen", - --"loud_walking:stone_with_algae", - --"loud_walking:stone_with_salt", + --"loud_walking:stone_with_moss", + --"loud_walking:stone_with_lichen", + --"loud_walking:stone_with_algae", + --"loud_walking:stone_with_salt", } local mushroom_stones = { @@ -102,51 +102,51 @@ local mushroom_stones = { local function get_biome(x, y, z) - local px = math_floor(x / fcsize.x) - local pz = math_floor(z / fcsize.z) + local px = math_floor(x / fcsize.x) + local pz = math_floor(z / fcsize.z) - if px % 10 == 6 and pz % 10 == 6 then - return "control" - else - local hash = px * 1000 + pz - if not biome_look[hash] then - -- use the same seed (based on perlin noise). - local seed_noise = minetest.get_perlin({offset = 0, scale = 32768, seed = 5202, spread = {x = 80, y = 80, z = 80}, octaves = 2, persist = 0.4, lacunarity = 2}) - math.randomseed(seed_noise:get2d({x=px, y=pz})) + if px % 10 == 6 and pz % 10 == 6 then + return "control" + else + local hash = px * 1000 + pz + if not biome_look[hash] then + -- use the same seed (based on perlin noise). + local seed_noise = minetest.get_perlin({offset = 0, scale = 32768, seed = 5202, spread = {x = 80, y = 80, z = 80}, octaves = 2, persist = 0.4, lacunarity = 2}) + math.randomseed(seed_noise:get2d({x=px, y=pz})) - local rarity = "common" - if math.random(5) == 1 then - rarity = "uncommon" - end - biome_look[hash] = biome_names[rarity][math.random(#loud_walking.biome_names[rarity])] + local rarity = "common" + if math.random(5) == 1 then + rarity = "uncommon" + end + biome_look[hash] = biome_names[rarity][math.random(#loud_walking.biome_names[rarity])] - local cave_lining - if math.random(3) ~= 1 then - cave_lining = cave_stones[math.random(#cave_stones)] - end - cave_look[hash] = cave_lining + local cave_lining + if math.random(3) ~= 1 then + cave_lining = cave_stones[math.random(#cave_stones)] + end + cave_look[hash] = cave_lining - local sr = math.random(100) - if sr == 1 then - ore_look[hash] = 'default:stone_with_mese' - elseif sr <= 3 then - ore_look[hash] = 'default:stone_with_diamond' - elseif sr <= 7 then - ore_look[hash] = 'default:stone_with_gold' - elseif sr <= 15 then - ore_look[hash] = 'default:stone_with_copper' - elseif sr <= 31 then - ore_look[hash] = 'default:stone_with_iron' - elseif sr <= 63 then - ore_look[hash] = 'default:stone_with_coal' - else - ore_look[hash] = 'default:stone' - end - end + local sr = math.random(100) + if sr == 1 then + ore_look[hash] = 'default:stone_with_mese' + elseif sr <= 3 then + ore_look[hash] = 'default:stone_with_diamond' + elseif sr <= 7 then + ore_look[hash] = 'default:stone_with_gold' + elseif sr <= 15 then + ore_look[hash] = 'default:stone_with_copper' + elseif sr <= 31 then + ore_look[hash] = 'default:stone_with_iron' + elseif sr <= 63 then + ore_look[hash] = 'default:stone_with_coal' + else + ore_look[hash] = 'default:stone' + end + end - --return 'deciduous_forest', cave_look[hash], ore_look[hash] - return biome_look[hash], cave_look[hash], ore_look[hash] - end + --return 'deciduous_forest', cave_look[hash], ore_look[hash] + return biome_look[hash], cave_look[hash], ore_look[hash] + end end loud_walking.get_biome = get_biome @@ -181,27 +181,27 @@ end local function get_height(fdx, fdz, index, terrain_scale, ocean) - local terr = math_floor(terrain_map[index] * (terrain_scale or 1) + 0.5) + local terr = math_floor(terrain_map[index] * (terrain_scale or 1) + 0.5) if ocean and terr > 0 then terr = math_floor(terr * (terrain_scale + 1.5) / 4 + 0.5) end - local d = - math_abs(math_abs(fdx - (half_pod.x - 0.5)) - math_abs(fdz - (half_pod.z - 0.5))) - if math_abs(fdx - half_pod.x) > math_abs(fdz - half_pod.z) then - d = d + half_pod.x - 2 - else - d = d + half_pod.z - 2 - end + local d = - math_abs(math_abs(fdx - (half_pod.x - 0.5)) - math_abs(fdz - (half_pod.z - 0.5))) + if math_abs(fdx - half_pod.x) > math_abs(fdz - half_pod.z) then + d = d + half_pod.x - 2 + else + d = d + half_pod.z - 2 + end - if math_abs(terr) > d then - if terr > 0 then - terr = math_floor(d + 0.5) - elseif not ocean then - terr = math_floor(0.5 - d) - end - end + if math_abs(terr) > d then + if terr > 0 then + terr = math_floor(d + 0.5) + elseif not ocean then + terr = math_floor(0.5 - d) + end + end - return terr + return terr end @@ -210,6 +210,12 @@ loud_walking.terrain = function(minp, maxp, data, p2data, area, baseline, height return end + local extent_bottom = loud_walking.extent_bottom + local extent_top = loud_walking.extent_top + if maxp.y < baseline + extent_bottom or minp.y > baseline + extent_top then + return + end + if not loud_walking.csize then loud_walking.csize = vector.add(vector.subtract(maxp, minp), 1) @@ -238,33 +244,33 @@ loud_walking.terrain = function(minp, maxp, data, p2data, area, baseline, height end end - local ground = half_pod.y + local ground = half_pod.y - local t1 = os.clock() + local t1 = os.clock() - local index = 0 - local index3d = 0 - local last_biome, last_px, last_py, last_pz, node_top, node_filler, node_water_top, node_water, depth_top, depth_water_top, depth_filler, node_stone, ocean, swamp, beach, dunes, height - local biome_name, cave_lining, room_type, room_type_below, ore_type, land_biome + local index = 0 + local index3d = 0 + local last_biome, last_px, last_py, last_pz, node_top, node_filler, node_water_top, node_water, depth_top, depth_water_top, depth_filler, node_stone, ocean, swamp, beach, dunes, height + local biome_name, cave_lining, room_type, room_type_below, ore_type, land_biome terrain_map = terrain_noise:get2dMap_flat({x=minp.x, y=minp.z}, terrain_map) cave_map = cave_noise:get3dMap_flat(minp, cave_map) cloud_map = cloud_noise:get2dMap_flat({x=minp.x, y=minp.z}, cloud_map) - for z = minp.z, maxp.z do - local dz = z - minp.z - local fdz = z % fcsize.z - local pz = math_floor(z / fcsize.z) - for x = minp.x, maxp.x do - index = index + 1 - local dx = x - minp.x - local fdx = x % fcsize.x - local px = math_floor(x / fcsize.x) - local in_cave = false - index3d = dz * csize.y * csize.x + dx + 1 - local ivm = area:index(x, minp.y, z) - local cave_height = 0 - last_py = nil + for z = minp.z, maxp.z do + local dz = z - minp.z + local fdz = z % fcsize.z + local pz = math_floor(z / fcsize.z) + for x = minp.x, maxp.x do + index = index + 1 + local dx = x - minp.x + local fdx = x % fcsize.x + local px = math_floor(x / fcsize.x) + local in_cave = false + index3d = dz * csize.y * csize.x + dx + 1 + local ivm = area:index(x, minp.y, z) + local cave_height = 0 + last_py = nil if px ~= last_px or pz ~= last_pz then biome_name, cave_lining, ore_type = get_biome(x, 0, z) @@ -302,9 +308,9 @@ loud_walking.terrain = function(minp, maxp, data, p2data, area, baseline, height end end - for y = minp.y, maxp.y do - local dy = y - minp.y - local fdy = y - baseline + half_pod.y + for y = minp.y, maxp.y do + local dy = y - minp.y + local fdy = y - baseline + half_pod.y local eff_biome = (y < half_pod.y) and biome_name or land_biome if biome_name == 'control' then @@ -318,96 +324,96 @@ loud_walking.terrain = function(minp, maxp, data, p2data, area, baseline, height end end - if not (data[ivm] == node['air'] or data[ivm] == node['ignore']) then - -- nop - elseif biome_name == "control" and math_abs(fdx - half_pod.x) < 3 and math_abs(fdz - half_pod.z) < 3 then - data[ivm] = node["loud_walking:air_ladder"] - elseif fdz >= pod_size.z or fdx >= pod_size.x or fdy >= pod_size.y then - if (fdy == half_pod.y and fdx == half_pod.x) or (fdy == half_pod.y and fdz == half_pod.z) then - data[ivm] = node['loud_walking:scrith'] - else - --data[ivm] = node['loud_walking:vacuum'] - end - elseif math.min(fdx, pod_size.x - fdx) + math.min(fdy, pod_size.y - fdy) + math.min(fdz, pod_size.z - fdz) < bevel then - --data[ivm] = node['loud_walking:vacuum'] - in_cave = false - elseif (fdx == 0 or fdx == pod_size.x - 1) or (fdz == 0 or fdz == pod_size.z - 1) or (fdy == 0 or fdy == pod_size.y - 1) or math.min(fdx, pod_size.x - fdx) + math.min(fdy, pod_size.y - fdy) + math.min(fdz, pod_size.z - fdz) < bevel + 1 then - if math_abs(fdy - half_pod.y - 2) < 2 and (fdz == half_pod.z or fdx == half_pod.x) then + if not (data[ivm] == node['air'] or data[ivm] == node['ignore']) then + -- nop + elseif biome_name == "control" and math_abs(fdx - half_pod.x) < 3 and math_abs(fdz - half_pod.z) < 3 then + data[ivm] = node["loud_walking:air_ladder"] + elseif fdz >= pod_size.z or fdx >= pod_size.x or fdy >= pod_size.y then + if (fdy == half_pod.y and fdx == half_pod.x) or (fdy == half_pod.y and fdz == half_pod.z) then + data[ivm] = node['loud_walking:scrith'] + else --data[ivm] = node['loud_walking:vacuum'] - else - if biome_name == "control" then - data[ivm] = node[glass[3]] - elseif fdy < half_pod.y then - data[ivm] = node["loud_walking:scrith"] - elseif biome_name == "underground" then - data[ivm] = node["loud_walking:scrith"] - elseif fdy == pod_size.y - 1 then - data[ivm] = node[glass[cloud_map[index] < cloud_i and 1 or 2]] - else - data[ivm] = node[glass[1]] - end - end - elseif fdz == 0 and fdz == pod_size.z - 1 or fdx == 0 and fdx == pod_size.x - 1 or fdy == 0 and fdy == pod_size.y - 1 then - data[ivm] = node['loud_walking:scrith'] - elseif biome_name == "control" and fdy < pod_size.y then - if (math_abs(fdx - half_pod.x) < 3 or math_abs(fdz - half_pod.z) < 3) then - -- corridor - if fdy % 5 == 0 then - data[ivm] = node["loud_walking:control_floor"] - end - elseif ((math_abs(fdx - half_pod.x) % room_size == 3) or (math_abs(fdz - half_pod.z) % room_size == 3)) then - if fdy % 5 == 0 then - data[ivm] = node["loud_walking:control_floor"] - elseif ((math_abs(fdx - half_pod.x) % room_size == 3 and (math_abs(fdz - half_pod.z) - (math_floor(room_size / 2) + 2)) % room_size > 3) or (math_abs(fdz - half_pod.z) % room_size == 3 and (math_abs(fdx - half_pod.x) - (math_floor(room_size / 2) + 2)) % room_size > 3)) then - data[ivm] = node["loud_walking:control_wall"] - end - elseif fdy % 5 == 0 then - if room_type == 1 then - if room_type_below == 1 then - data[ivm] = node["loud_walking:control_floor_alert_both"] - else - data[ivm] = node["loud_walking:control_floor_alert_up"] - end - elseif room_type_below == 1 then - data[ivm] = node["loud_walking:control_floor_alert_down"] - elseif room_type == 3 then - data[ivm] = node["loud_walking:control_floor_growth"] - else - data[ivm] = node["loud_walking:control_floor"] - end - elseif room_type == 2 and fdy < pod_size.y then - if math_abs(fdx - half_pod.x) % 4 < 3 and math_abs(fdz - half_pod.z) % 4 < 3 then - data[ivm] = node["loud_walking:air_ladder"] - end - elseif room_type == 3 then - if fdy % 5 == 1 then - local sr2 = math.random(20) - if sr2 == 1 then - data[ivm] = node["loud_walking:control_plant_1"] - elseif sr2 == 2 then - data[ivm] = node["loud_walking:control_plant_2"] - end - end - elseif room_type == 4 then - if fdy % 5 == 4 and (((math_abs(fdx - half_pod.x) % room_size == 4 or math_abs(fdx - half_pod.x) % room_size == 2) and (math_abs(fdz - half_pod.z) - (math_floor(room_size / 2) + 2)) % room_size > 3) or ((math_abs(fdz - half_pod.z) % room_size == 4 or math_abs(fdz - half_pod.z) % room_size == 2) and (math_abs(fdx - half_pod.x) - (math_floor(room_size / 2) + 2)) % room_size > 3)) then - data[ivm] = node["loud_walking:controls"] - end - else - -- nop - end - elseif (((fdx == (half_pod.x - control_off) or fdx == (half_pod.x + control_off)) and fdz >= (half_pod.z - control_off) and fdz <= (half_pod.z + control_off)) or ((fdz == (half_pod.z - control_off) or fdz == (half_pod.z + control_off)) and fdx >= (half_pod.x - control_off) and fdx <= (half_pod.x + control_off))) and fdx ~= half_pod.x and fdz ~= half_pod.z and fdy == pod_size.y - 2 then - data[ivm] = node["loud_walking:controls"] - elseif (((fdx == (half_pod.x - control_off) or fdx == (half_pod.x + control_off)) and fdz >= (half_pod.z - control_off) and fdz <= (half_pod.z + control_off)) or ((fdz == (half_pod.z - control_off) or fdz == (half_pod.z + control_off)) and fdx >= (half_pod.x - control_off) and fdx <= (half_pod.x + control_off))) and fdx ~= half_pod.x and fdz ~= half_pod.z and fdy > pod_size.y - control_off then - data[ivm] = node[glass[3]] - elseif fdz >= (half_pod.z - control_off) and fdz <= (half_pod.z + control_off) and fdx >= (half_pod.x - control_off) and fdx <= (half_pod.x + control_off) and fdy == pod_size.y - control_off then - data[ivm] = node[glass[3]] - elseif not in_cave and (ocean or swamp or beach) and fdy > height + ground and fdy <= half_pod.y and fdy == height + ground + 1 then - -- ** water decorations ** - --local deco = get_decoration(biome_name) - --if deco then - -- data[ivm] = node[deco] - --end - elseif not in_cave and fdy == height + ground + 1 then + end + elseif math.min(fdx, pod_size.x - fdx) + math.min(fdy, pod_size.y - fdy) + math.min(fdz, pod_size.z - fdz) < bevel then + --data[ivm] = node['loud_walking:vacuum'] + in_cave = false + elseif (fdx == 0 or fdx == pod_size.x - 1) or (fdz == 0 or fdz == pod_size.z - 1) or (fdy == 0 or fdy == pod_size.y - 1) or math.min(fdx, pod_size.x - fdx) + math.min(fdy, pod_size.y - fdy) + math.min(fdz, pod_size.z - fdz) < bevel + 1 then + if math_abs(fdy - half_pod.y - 2) < 2 and (fdz == half_pod.z or fdx == half_pod.x) then + --data[ivm] = node['loud_walking:vacuum'] + else + if biome_name == "control" then + data[ivm] = node[glass[3]] + elseif fdy < half_pod.y then + data[ivm] = node["loud_walking:scrith"] + elseif biome_name == "underground" then + data[ivm] = node["loud_walking:scrith"] + elseif fdy == pod_size.y - 1 then + data[ivm] = node[glass[cloud_map[index] < cloud_i and 1 or 2]] + else + data[ivm] = node[glass[1]] + end + end + elseif fdz == 0 and fdz == pod_size.z - 1 or fdx == 0 and fdx == pod_size.x - 1 or fdy == 0 and fdy == pod_size.y - 1 then + data[ivm] = node['loud_walking:scrith'] + elseif biome_name == "control" and fdy < pod_size.y then + if (math_abs(fdx - half_pod.x) < 3 or math_abs(fdz - half_pod.z) < 3) then + -- corridor + if fdy % 5 == 0 then + data[ivm] = node["loud_walking:control_floor"] + end + elseif ((math_abs(fdx - half_pod.x) % room_size == 3) or (math_abs(fdz - half_pod.z) % room_size == 3)) then + if fdy % 5 == 0 then + data[ivm] = node["loud_walking:control_floor"] + elseif ((math_abs(fdx - half_pod.x) % room_size == 3 and (math_abs(fdz - half_pod.z) - (math_floor(room_size / 2) + 2)) % room_size > 3) or (math_abs(fdz - half_pod.z) % room_size == 3 and (math_abs(fdx - half_pod.x) - (math_floor(room_size / 2) + 2)) % room_size > 3)) then + data[ivm] = node["loud_walking:control_wall"] + end + elseif fdy % 5 == 0 then + if room_type == 1 then + if room_type_below == 1 then + data[ivm] = node["loud_walking:control_floor_alert_both"] + else + data[ivm] = node["loud_walking:control_floor_alert_up"] + end + elseif room_type_below == 1 then + data[ivm] = node["loud_walking:control_floor_alert_down"] + elseif room_type == 3 then + data[ivm] = node["loud_walking:control_floor_growth"] + else + data[ivm] = node["loud_walking:control_floor"] + end + elseif room_type == 2 and fdy < pod_size.y then + if math_abs(fdx - half_pod.x) % 4 < 3 and math_abs(fdz - half_pod.z) % 4 < 3 then + data[ivm] = node["loud_walking:air_ladder"] + end + elseif room_type == 3 then + if fdy % 5 == 1 then + local sr2 = math.random(20) + if sr2 == 1 then + data[ivm] = node["loud_walking:control_plant_1"] + elseif sr2 == 2 then + data[ivm] = node["loud_walking:control_plant_2"] + end + end + elseif room_type == 4 then + if fdy % 5 == 4 and (((math_abs(fdx - half_pod.x) % room_size == 4 or math_abs(fdx - half_pod.x) % room_size == 2) and (math_abs(fdz - half_pod.z) - (math_floor(room_size / 2) + 2)) % room_size > 3) or ((math_abs(fdz - half_pod.z) % room_size == 4 or math_abs(fdz - half_pod.z) % room_size == 2) and (math_abs(fdx - half_pod.x) - (math_floor(room_size / 2) + 2)) % room_size > 3)) then + data[ivm] = node["loud_walking:controls"] + end + else + -- nop + end + elseif (((fdx == (half_pod.x - control_off) or fdx == (half_pod.x + control_off)) and fdz >= (half_pod.z - control_off) and fdz <= (half_pod.z + control_off)) or ((fdz == (half_pod.z - control_off) or fdz == (half_pod.z + control_off)) and fdx >= (half_pod.x - control_off) and fdx <= (half_pod.x + control_off))) and fdx ~= half_pod.x and fdz ~= half_pod.z and fdy == pod_size.y - 2 then + data[ivm] = node["loud_walking:controls"] + elseif (((fdx == (half_pod.x - control_off) or fdx == (half_pod.x + control_off)) and fdz >= (half_pod.z - control_off) and fdz <= (half_pod.z + control_off)) or ((fdz == (half_pod.z - control_off) or fdz == (half_pod.z + control_off)) and fdx >= (half_pod.x - control_off) and fdx <= (half_pod.x + control_off))) and fdx ~= half_pod.x and fdz ~= half_pod.z and fdy > pod_size.y - control_off then + data[ivm] = node[glass[3]] + elseif fdz >= (half_pod.z - control_off) and fdz <= (half_pod.z + control_off) and fdx >= (half_pod.x - control_off) and fdx <= (half_pod.x + control_off) and fdy == pod_size.y - control_off then + data[ivm] = node[glass[3]] + elseif not in_cave and (ocean or swamp or beach) and fdy > height + ground and fdy <= half_pod.y and fdy == height + ground + 1 then + -- ** water decorations ** + --local deco = get_decoration(biome_name) + --if deco then + -- data[ivm] = node[deco] + --end + elseif not in_cave and fdy == height + ground + 1 then if biomes[eff_biome].special_trees and loud_walking.tree_map[ x .. ',' .. z ] and (eff_biome ~= 'savanna' or math.random(20) == 1) then local i = 1 for j = 1, 100 do @@ -425,105 +431,105 @@ loud_walking.terrain = function(minp, maxp, data, p2data, area, baseline, height data[ivm] = node[deco] end end - elseif (ocean or swamp or beach) and fdy > height + ground and fdy <= half_pod.y and fdy >= half_pod.y - (biomes[biome_name].depth_water_top or 1) then - data[ivm] = node[biomes[biome_name].node_water_top or biomes[biome_name].node_water or "default:water_source"] - in_cave = false - elseif (ocean or swamp or beach) and fdy > height + ground and fdy <= half_pod.y then - data[ivm] = node[biomes[biome_name].node_water or "default:water_source"] - in_cave = false - elseif fdy > height + ground then - --data[ivm] = node["air"] - in_cave = false - elseif cave_map[index3d] ^ 2 > (biome_name == "underground" and 0.5 or 1.3 - math.sin(fdy / (half_pod.y * 0.2))) then - cave_height = cave_height + 1 - if height + ground >= fdy and not in_cave and fdy > height + ground - 10 then - data[ivm] = node[biomes[eff_biome].node_top or "default:dirt_with_grass"] - elseif fdy == 1 then - if not cave_lining and not ocean and not swamp and not beach and biome_name ~= "glacier" and math.random(6) == 1 then - data[ivm] = node["default:lava_source"] - elseif ocean or swamp or beach then - data[ivm] = node[biomes[eff_biome].node_filler or "default:dirt"] - end - elseif (ocean or swamp or beach) and not in_cave and (biomes[eff_biome].node_stone or "default:stone") == "default:stone" and fdy < half_pod.y and math.random(20) == 1 then - data[ivm] = node["loud_walking:glowing_fungal_stone"] - elseif (ocean or swamp or beach) and fdy < half_pod.y then - data[ivm] = node[biomes[biome_name].node_water or "default:water_source"] - elseif cave_height == 3 and (biomes[eff_biome].node_filler or "default:dirt") == "default:dirt" and mushroom_stones[data[ivm - 3 * area.ystride]] and math.random(40) == 1 then - data[ivm] = node["loud_walking:giant_mushroom_cap"] - data[ivm - area.ystride] = node["loud_walking:giant_mushroom_stem"] - data[ivm - 2 * area.ystride] = node["loud_walking:giant_mushroom_stem"] - data[ivm - 3 * area.ystride] = node[biomes[eff_biome].node_filler or "default:dirt"] - elseif cave_height == 2 and (biomes[eff_biome].node_filler or "default:dirt") == "default:dirt" and mushroom_stones[data[ivm - 2 * area.ystride]] and math.random(20) == 1 then - data[ivm] = node["loud_walking:huge_mushroom_cap"] - data[ivm - area.ystride] = node["loud_walking:giant_mushroom_stem"] - data[ivm - 2 * area.ystride] = node[biomes[eff_biome].node_filler or "default:dirt"] - elseif not in_cave and (biomes[eff_biome].node_stone or "default:stone") == "default:stone" and not cave_lining and math.random(10) == 1 then - data[ivm] = node["loud_walking:stalagmite"] - elseif not in_cave and (biomes[eff_biome].node_stone or "default:stone") == "default:ice" and math.random(10) == 1 then - data[ivm] = node["loud_walking:icicle_up"] - else - --data[ivm] = node["air"] - end - in_cave = true - elseif cave_lining and cave_map[index3d] ^ 2 > (biome_name == "underground" and 0.4 or 1.2 - math.sin(fdy / (half_pod.y * 0.2))) then - data[ivm] = node[cave_lining] - elseif fdy > height + ground - (biomes[eff_biome].depth_top or 1) then - data[ivm] = node[biomes[eff_biome].node_top or "default:dirt_with_grass"] - in_cave = false - elseif fdy > height + ground - (biomes[eff_biome].depth_filler or 1) - (biomes[eff_biome].depth_top or 1) then - data[ivm] = node[biomes[eff_biome].node_filler or "default:dirt"] - in_cave = false - else - data[ivm] = node[biomes[eff_biome].node_stone or "default:stone"] - if math.random(100) == 1 then - data[ivm] = node[ore_type] - end + elseif (ocean or swamp or beach) and fdy > height + ground and fdy <= half_pod.y and fdy >= half_pod.y - (biomes[biome_name].depth_water_top or 1) then + data[ivm] = node[biomes[biome_name].node_water_top or biomes[biome_name].node_water or "default:water_source"] + in_cave = false + elseif (ocean or swamp or beach) and fdy > height + ground and fdy <= half_pod.y then + data[ivm] = node[biomes[biome_name].node_water or "default:water_source"] + in_cave = false + elseif fdy > height + ground then + --data[ivm] = node["air"] + in_cave = false + elseif cave_map[index3d] ^ 2 > (biome_name == "underground" and 0.5 or 1.3 - math.sin(fdy / (half_pod.y * 0.2))) then + cave_height = cave_height + 1 + if height + ground >= fdy and not in_cave and fdy > height + ground - 10 then + data[ivm] = node[biomes[eff_biome].node_top or "default:dirt_with_grass"] + elseif fdy == 1 then + if not cave_lining and not ocean and not swamp and not beach and biome_name ~= "glacier" and math.random(6) == 1 then + data[ivm] = node["default:lava_source"] + elseif ocean or swamp or beach then + data[ivm] = node[biomes[eff_biome].node_filler or "default:dirt"] + end + elseif (ocean or swamp or beach) and not in_cave and (biomes[eff_biome].node_stone or "default:stone") == "default:stone" and fdy < half_pod.y and math.random(20) == 1 then + data[ivm] = node["loud_walking:glowing_fungal_stone"] + elseif (ocean or swamp or beach) and fdy < half_pod.y then + data[ivm] = node[biomes[biome_name].node_water or "default:water_source"] + elseif cave_height == 3 and (biomes[eff_biome].node_filler or "default:dirt") == "default:dirt" and mushroom_stones[data[ivm - 3 * area.ystride]] and math.random(40) == 1 then + data[ivm] = node["loud_walking:giant_mushroom_cap"] + data[ivm - area.ystride] = node["loud_walking:giant_mushroom_stem"] + data[ivm - 2 * area.ystride] = node["loud_walking:giant_mushroom_stem"] + data[ivm - 3 * area.ystride] = node[biomes[eff_biome].node_filler or "default:dirt"] + elseif cave_height == 2 and (biomes[eff_biome].node_filler or "default:dirt") == "default:dirt" and mushroom_stones[data[ivm - 2 * area.ystride]] and math.random(20) == 1 then + data[ivm] = node["loud_walking:huge_mushroom_cap"] + data[ivm - area.ystride] = node["loud_walking:giant_mushroom_stem"] + data[ivm - 2 * area.ystride] = node[biomes[eff_biome].node_filler or "default:dirt"] + elseif not in_cave and (biomes[eff_biome].node_stone or "default:stone") == "default:stone" and not cave_lining and math.random(10) == 1 then + data[ivm] = node["loud_walking:stalagmite"] + elseif not in_cave and (biomes[eff_biome].node_stone or "default:stone") == "default:ice" and math.random(10) == 1 then + data[ivm] = node["loud_walking:icicle_up"] + else + --data[ivm] = node["air"] + end + in_cave = true + elseif cave_lining and cave_map[index3d] ^ 2 > (biome_name == "underground" and 0.4 or 1.2 - math.sin(fdy / (half_pod.y * 0.2))) then + data[ivm] = node[cave_lining] + elseif fdy > height + ground - (biomes[eff_biome].depth_top or 1) then + data[ivm] = node[biomes[eff_biome].node_top or "default:dirt_with_grass"] + in_cave = false + elseif fdy > height + ground - (biomes[eff_biome].depth_filler or 1) - (biomes[eff_biome].depth_top or 1) then + data[ivm] = node[biomes[eff_biome].node_filler or "default:dirt"] + in_cave = false + else + data[ivm] = node[biomes[eff_biome].node_stone or "default:stone"] + if math.random(100) == 1 then + data[ivm] = node[ore_type] + end - if in_cave and (biomes[eff_biome].node_stone or "default:stone") == "default:stone" and math.random(20) == 1 then - data[ivm] = node["loud_walking:glowing_fungal_stone"] - elseif in_cave and not (ocean or swamp or beach) and (biomes[eff_biome].node_stone or "default:stone") == "default:stone" and not cave_lining and math.random(10) == 1 then - data[ivm - area.ystride] = node["loud_walking:stalactite"] - elseif in_cave and not (ocean or swamp or beach) and (biomes[eff_biome].node_stone or "default:stone") == "default:ice" and math.random(10) == 1 then - data[ivm - area.ystride] = node["loud_walking:icicle_down"] - end - in_cave = false - end + if in_cave and (biomes[eff_biome].node_stone or "default:stone") == "default:stone" and math.random(20) == 1 then + data[ivm] = node["loud_walking:glowing_fungal_stone"] + elseif in_cave and not (ocean or swamp or beach) and (biomes[eff_biome].node_stone or "default:stone") == "default:stone" and not cave_lining and math.random(10) == 1 then + data[ivm - area.ystride] = node["loud_walking:stalactite"] + elseif in_cave and not (ocean or swamp or beach) and (biomes[eff_biome].node_stone or "default:stone") == "default:ice" and math.random(10) == 1 then + data[ivm - area.ystride] = node["loud_walking:icicle_down"] + end + in_cave = false + end - if not in_cave then - cave_height = 0 - end + if not in_cave then + cave_height = 0 + end - last_biome = biome_name + last_biome = biome_name - ivm = ivm + area.ystride - index3d = index3d + csize.x - end - last_px = px - end - last_pz = pz - end + ivm = ivm + area.ystride + index3d = index3d + csize.x + end + last_px = px + end + last_pz = pz + end - local t2 = os.clock() + local t2 = os.clock() --last_px = nil --last_pz = nil - --for z = minp.z, maxp.z do - -- local fdz = z % fcsize.z - -- local pz = math_floor(z / fcsize.z) - -- for x = minp.x, maxp.x do - -- local fdx = x % fcsize.x - -- local px = math_floor(x / fcsize.x) - -- last_py = nil - -- for y = minp.y, maxp.y do - -- if fdz % tree_space == 0 and fdx % tree_space == 0 then - -- local fdy = y - baseline + half_pod.y - -- local pod = fdz < pod_size.z and fdx < pod_size.x and fdy > 0 and fdy < pod_size.y - -- if px ~= last_px or pz ~= last_pz then - -- biome_name, cave_lining = get_biome(x, y, z) - -- ocean = string.find(biome_name, "ocean") and true or false - -- swamp = string.find(biome_name, "swamp") and true or false - -- node_top = biomes[biome_name].node_top or "default:dirt_with_grass" - -- end + --for z = minp.z, maxp.z do + -- local fdz = z % fcsize.z + -- local pz = math_floor(z / fcsize.z) + -- for x = minp.x, maxp.x do + -- local fdx = x % fcsize.x + -- local px = math_floor(x / fcsize.x) + -- last_py = nil + -- for y = minp.y, maxp.y do + -- if fdz % tree_space == 0 and fdx % tree_space == 0 then + -- local fdy = y - baseline + half_pod.y + -- local pod = fdz < pod_size.z and fdx < pod_size.x and fdy > 0 and fdy < pod_size.y + -- if px ~= last_px or pz ~= last_pz then + -- biome_name, cave_lining = get_biome(x, y, z) + -- ocean = string.find(biome_name, "ocean") and true or false + -- swamp = string.find(biome_name, "swamp") and true or false + -- node_top = biomes[biome_name].node_top or "default:dirt_with_grass" + -- end -- local rx = x + math.random(tree_space) - 1 -- local rz = z + math.random(tree_space) - 1 @@ -545,9 +551,9 @@ loud_walking.terrain = function(minp, maxp, data, p2data, area, baseline, height -- end -- end -- end - -- end - -- end - -- end - -- end - --end + -- end + -- end + -- end + -- end + --end end