1
0
mirror of https://github.com/Splizard/minetest-mod-snow.git synced 2024-12-28 23:40:17 +01:00

update mapgen_v6, e.g. replace plantlike plants to dry shrub and reduce snow height to make it smooth

This commit is contained in:
HybridDog 2015-06-13 15:53:10 +02:00
parent de80a0910e
commit 9cd39dc111

View File

@ -31,6 +31,7 @@ local function biome_to_string(num,num2)
return biome return biome
end end
local function do_ws_func(a, x) local function do_ws_func(a, x)
local n = x/(16000) local n = x/(16000)
local y = 0 local y = 0
@ -56,6 +57,28 @@ local function get_ws_list(a,x)
return v return v
end end
local plantlike_ids = {}
local function is_plantlike(id)
if plantlike_ids[id] ~= nil then
return plantlike_ids[id]
end
local node = minetest.registered_nodes[minetest.get_name_from_content_id(id)]
if not node then
plantlike_ids[id] = false
return false
end
local drawtype = node.drawtype
if not drawtype
or drawtype ~= "plantlike" then
plantlike_ids[id] = false
return false
end
plantlike_ids[id] = true
return true
end
-- On generated function -- On generated function
minetest.register_on_generated(function(minp, maxp, seed) minetest.register_on_generated(function(minp, maxp, seed)
@ -183,12 +206,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
if ground_y then if ground_y then
local node = area:index(x, ground_y, z) local node = area:index(x, ground_y, z)
local c_ground = data[node] local c_ground = data[node]
local abovenode = area:index(x, ground_y+1, z)
if c_ground == c_dirt_with_grass then if c_ground == c_dirt_with_grass then
if alpine if alpine
and test > 0.53 then and test > 0.53 then
snow_tab[num] = {abovenode, z, x, test} snow_tab[num] = {ground_y, z, x, test}
num = num+1 num = num+1
-- generate stone ground -- generate stone ground
for y = ground_y, math.max(-6, minp.y-6), -1 do for y = ground_y, math.max(-6, minp.y-6), -1 do
@ -201,57 +223,16 @@ minetest.register_on_generated(function(minp, maxp, seed)
elseif shrubs elseif shrubs
and pr:next(1,28) == 1 then and pr:next(1,28) == 1 then
data[node] = c_dirt_with_snow data[node] = c_dirt_with_snow
data[abovenode] = c_dry_shrub data[area:index(x, ground_y+1, z)] = c_dry_shrub
elseif pines elseif pines
and pr:next(1,36) == 1 then and pr:next(1,36) == 1 then
data[node] = c_dirt_with_snow data[node] = c_dirt_with_snow
spawn_pine({x=x, y=ground_y+1, z=z}, area, data) spawn_pine({x=x, y=ground_y+1, z=z}, area, data)
else else
data[node] = c_dirt_with_snow data[node] = c_dirt_with_snow
snow_tab[num] = {abovenode, z, x, test} snow_tab[num] = {ground_y, z, x, test}
num = num+1 num = num+1
end end
elseif c_ground == c_sand then
if icy then
data[node] = c_ice
end
snow_tab[num] = {abovenode, z, x, test}
num = num+1
elseif c_ground == c_leaves
or c_ground == c_jungleleaves
or c_ground == c_apple then
if alpine then
snow_tab[num] = {abovenode, z, x, test}
num = num+1
-- make stone pillars out of trees
for y = ground_y, math.max(-6, minp.y-6), -1 do
local stone = area:index(x, y, z)
if data[stone] == c_stone then
break
end
data[stone] = c_stone
end
else
-- put snow onto leaves
snow_tab[num] = {abovenode, z, x, test}
num = num+1
end
elseif c_ground == c_junglegrass then
data[node] = c_dry_shrub
elseif c_ground == c_papyrus then
snow_tab[num] = {abovenode, z, x, test}
num = num+1
-- replace papyrus plants with snowblocks
local y = ground_y
for _ = 1,7 do
local vi = area:index(x, y, z)
if data[vi] == c_papyrus then
data[vi] = c_snow_block
y = y-1
else
break
end
end
elseif c_ground == c_water then elseif c_ground == c_water then
if not icesheet if not icesheet
and not icecave and not icecave
@ -308,10 +289,56 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
if icesheet then if icesheet then
-- put snow onto icesheets -- put snow onto icesheets
snow_tab[num] = {abovenode, z, x, test} snow_tab[num] = {ground_y, z, x, test}
num = num+1 num = num+1
end end
end end
elseif c_ground == c_leaves
or c_ground == c_jungleleaves
or c_ground == c_apple then
if alpine then
snow_tab[num] = {ground_y, z, x, test}
num = num+1
-- make stone pillars out of trees
for y = ground_y, math.max(-6, minp.y-6), -1 do
local stone = area:index(x, y, z)
if data[stone] == c_stone then
break
end
data[stone] = c_stone
end
else
-- put snow onto leaves
snow_tab[num] = {ground_y, z, x, test}
num = num+1
end
elseif c_ground == c_sand then
if icy then
data[node] = c_ice
end
snow_tab[num] = {ground_y, z, x, test}
num = num+1
elseif c_ground == c_papyrus then
snow_tab[num] = {ground_y, z, x, test}
num = num+1
-- replace papyrus plants with snowblocks
local y = ground_y
for _ = 1,7 do
local vi = area:index(x, y, z)
if data[vi] == c_papyrus then
data[vi] = c_snow_block
y = y-1
else
break
end
end
elseif is_plantlike(c_ground) then
local vi = area:index(x, ground_y-1, z)
if data[vi] == c_dirt_with_grass then
-- replace other plants with dry shrubs
data[vi] = c_dirt_with_snow
data[node] = c_dry_shrub
end
end end
end end
end end
@ -321,11 +348,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
local param2s local param2s
if num ~= 1 then if num ~= 1 then
for _,i in pairs(snow_tab) do
-- set snow
data[area:index(i[3], i[1]+1, i[2])] = c_snow
end
local wsz, wsx local wsz, wsx
for _,i in pairs(snow_tab) do for _,i in pairs(snow_tab) do
local p,z,x,test = unpack(i) local y,z,x,test = unpack(i)
-- snow is set
data[p] = c_snow
test = (test-0.73)/0.27 -- /(1-0.73) test = (test-0.73)/0.27 -- /(1-0.73)
if test > 0 then if test > 0 then
local maxh = math.floor(test*10)%10+1 local maxh = math.floor(test*10)%10+1
@ -336,20 +365,35 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
local h = math.floor(wsx[x]+wsz[z]*5)%10+1 local h = math.floor(wsx[x]+wsz[z]*5)%10+1
if h ~= 1 then if h ~= 1 then
if h == 10 then -- search for nearby snow
-- make snowdrifts walkable y = y+1
h = 5 for i = -1,1,2 do
end for _,cord in pairs({{x+i,z}, {x,z+i}}) do
h = math.min(maxh, h) local nd = data[area:index(cord[1], y, cord[2])]
if h == 9 then if nd == c_air
-- replace the snow with a snowblock because its a full node or nd == c_dry_shrub then
data[p] = c_snow_block h = h/2
else end
-- set a specific snow height end
if not param2s then end
param2s = vm:get_param2_data() h = math.floor(h+0.5)
if h > 1 then
-- make snowdrifts walkable
if h == 10 then
h = 5
end
h = math.min(maxh, h)
local vi = area:index(x, y, z)
if h == 9 then
-- replace the snow with a snowblock because its a full node
data[vi] = c_snow_block
else
-- set a specific snow height
if not param2s then
param2s = vm:get_param2_data()
end
param2s[vi] = h*7
end end
param2s[p] = h*7
end end
end end
end end