Add top snow on v6-generated snowy grass blocks

This commit is contained in:
Wuzzy 2017-04-01 17:01:15 +02:00
parent 8e3015a208
commit e9e588a104
1 changed files with 40 additions and 16 deletions

View File

@ -799,6 +799,17 @@ local function register_mgv6_decorations()
end end
-- Apply mapgen-specific mapgen code
local mg_name = minetest.get_mapgen_setting("mg_name")
if mg_name == "v6" then
register_mgv6_decorations()
end
if mg_name == "flat" then
minetest.set_mapgen_setting("mg_flags", "nocaves,nodungeons,nodecorations,light", true)
else
minetest.set_mapgen_setting("mg_flags", "caves,nodungeons,decorations,light", true)
end
minetest.register_on_generated(function(minp, maxp, seed) minetest.register_on_generated(function(minp, maxp, seed)
if maxp.y >= 2 and minp.y <= 0 then if maxp.y >= 2 and minp.y <= 0 then
-- Generate clay -- Generate clay
@ -924,15 +935,28 @@ local BEDROCK_MAX = mcl_vars.mg_bedrock_overworld_max
-- Below the bedrock, generate air/void -- Below the bedrock, generate air/void
minetest.register_on_generated(function(minp, maxp) minetest.register_on_generated(function(minp, maxp)
-- Generate bedrock layers
if minp.y <= BEDROCK_MAX then
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local data = vm:get_data() local data = vm:get_data()
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax}) local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
-- Generate bedrock layers
if minp.y <= BEDROCK_MAX or mg_name == "v6" then
lvm = true
local c_bedrock = minetest.get_content_id("mcl_core:bedrock") local c_bedrock = minetest.get_content_id("mcl_core:bedrock")
local c_void = minetest.get_content_id("mcl_core:void") local c_void = minetest.get_content_id("mcl_core:void")
for y = minp.y, math.min(maxp.y, BEDROCK_MAX) do local max_y
if mg_name == "v6" then
local c_grass_block_snow = minetest.get_content_id("mcl_core:dirt_with_grass_snow")
local c_grass_block = minetest.get_content_id("mcl_core:dirt_with_grass")
local c_snow = minetest.get_content_id("mcl_core:snow")
local c_air = minetest.get_content_id("air")
max_y = maxp.y
else
max_y = math.min(maxp.y, BEDROCK_MAX)
end
for y = minp.y, max_y do
for x = minp.x, maxp.x do for x = minp.x, maxp.x do
for z = minp.z, maxp.z do for z = minp.z, maxp.z do
local p_pos = area:index(x, y, z) local p_pos = area:index(x, y, z)
@ -966,13 +990,22 @@ minetest.register_on_generated(function(minp, maxp)
setdata = c_void setdata = c_void
end end
end end
if setdata then if setdata then
data[p_pos] = setdata data[p_pos] = setdata
end end
end
end
end
-- Add top snow on exposed snowy grass blocks generated by the v6 mapgen
-- FIXME: Does this work on chunk borders?
if mg_name == "v6" then
local p_pos_above = area:index(x, y+1, z)
if p_pos_above and data[p_pos] == c_grass_block_snow and data[p_pos_above] == c_air then
data[p_pos_above] = c_snow
end
end
end
end
end
vm:set_data(data) vm:set_data(data)
vm:calc_lighting() vm:calc_lighting()
vm:update_liquids() vm:update_liquids()
@ -1001,13 +1034,4 @@ minetest.register_on_generated(function(minp, maxp)
end end
end) end)
-- Apply mapgen-specific mapgen code
local mg_name = minetest.get_mapgen_setting("mg_name")
if mg_name == "v6" then
register_mgv6_decorations()
end
if mg_name == "flat" then
minetest.set_mapgen_setting("mg_flags", "nocaves,nodungeons,nodecorations,light", true)
else
minetest.set_mapgen_setting("mg_flags", "caves,nodungeons,decorations,light", true)
end