From f643ce07008ea327e1e7a730bd4c4e9e7612755a Mon Sep 17 00:00:00 2001 From: evrooije Date: Sun, 15 Jul 2018 23:42:46 +0200 Subject: [PATCH] Further tweaking of the skyrock and bedrock layers, fixes in lighting and another refactoring with a first cut of a multi_map class and API --- init.lua | 27 +++++++++++++++++++++++++++ mapgen.lua | 17 +++++++++++------ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index 0844e42..61178c3 100644 --- a/init.lua +++ b/init.lua @@ -1,11 +1,38 @@ +multi_map = {} + +multi_map.number_of_layers = 32 +multi_map.day_light = 15 +multi_map.night_light = 0 +multi_map.bedrock = "multi_map:bedrock" +multi_map.skyrock = "multi_map:skyrock" +multi_map.water_height = 0 +multi_map.seed = 835726 + +multi_map.layer_height = 65535 / multi_map.number_of_layers +multi_map.half_layer_height = multi_map.layer_height / 2 + +function multi_map.get_current_layer(y) + for l = (multi_map.number_of_layers / -2), (multi_map.number_of_layers / 2) do + if y >= (l * layer_height) - half_layer_height and y < (l * layer_height) + half_layer_height then + return l + end + end +end + +function multi_map.get_offset_y(y) + return y - (multi_map.get_current_layer(y) * multi_map.layer_height) +end + minetest.register_node("multi_map:skyrock", { description = "Multi Map Impenetrable Skyblock", drawtype = "airlike", is_ground_content = false, + sunlight_propagates = true, walkable = true, pointable = false, diggable = false, climbable = false, + paramtype = "light", }) minetest.register_node("multi_map:bedrock", { diff --git a/mapgen.lua b/mapgen.lua index 77ebc58..6a8b65e 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -202,6 +202,7 @@ minetest.register_on_generated(function(minp, maxp) local nixz = 1 local worm_started = false + local supress_shadow = false for z = minp.z, maxp.z do local niz @@ -216,10 +217,11 @@ minetest.register_on_generated(function(minp, maxp) height = height + layers[current_layer].mountain_peak_2dmap[nixz] end - if (layer_height * current_layer) - half_layer_height <= y and y <= (layer_height * current_layer) - half_layer_height + (sidelen / 2) then + if (layer_height * current_layer) + half_layer_height < y and y <= (layer_height * current_layer) + half_layer_height + sidelen then vm_data[vi] = c_bedrock - elseif (layer_height * current_layer) + half_layer_height - (sidelen * 5) <= y and y <= (layer_height * current_layer) + half_layer_height then + elseif (layer_height * current_layer) + half_layer_height - (sidelen * 2) <= y and y <= (layer_height * current_layer) + half_layer_height then vm_data[vi] = c_skyrock + supress_shadow = true elseif y <= height + (layer_height * current_layer) then -- if math.abs(cave_3dmap[nixyz]) < 10 then -- + (y / 400) then vm_data[vi] = c_stone @@ -244,10 +246,13 @@ minetest.register_on_generated(function(minp, maxp) nixz = nixz + sidelen end - vm:set_data(vm_data) - vm:set_lighting({day=settings.day_light, night=settings.night_light}) vm:update_liquids() - vm:calc_lighting(false) - vm:write_to_map() + if supress_shadow then + vm:calc_lighting(false) + vm:write_to_map(false) + else + vm:calc_lighting() + vm:write_to_map() + end end)