diff --git a/default.lua b/default.lua index da7da20..f5bf515 100644 --- a/default.lua +++ b/default.lua @@ -53,33 +53,18 @@ end -- Springs ----------------------------------------------------------------------------------------------------------------------- -local function deep_copy(table_in) - local table_out = {} - for index, value in pairs(table_in) do - if type(value) == "table" then - table_out[index] = deep_copy(value) - else - table_out[index] = value - end - end - return table_out -end -local duplicate_def = function (name) - local old_def = minetest.registered_nodes[name] - return deep_copy(old_def) -end -- register damp clay whether we're going to set the ABM or not, if the user disables this feature we don't want existing -- spring clay to turn into unknown nodes. -local clay_def = duplicate_def("default:clay") +local clay_def = dynamic_liquid.duplicate_def("default:clay") clay_def.description = S("Damp Clay") if not springs then clay_def.groups.not_in_creative_inventory = 1 -- take it out of creative inventory though end minetest.register_node("dynamic_liquid:clay", clay_def) -local data = {} +local data = dynamic_liquid.mapgen_data if springs then local c_clay = minetest.get_content_id("default:clay") diff --git a/init.lua b/init.lua index d31d1d5..37932c3 100644 --- a/init.lua +++ b/init.lua @@ -21,6 +21,26 @@ dynamic_liquid.config.falling_obsidian = minetest.settings:get_bool("dynamic_liq dynamic_liquid.registered_liquids = {} -- used by the flow-through node abm dynamic_liquid.registered_liquid_neighbors = {} +dynamic_liquid.mapgen_data = {} -- shared by various mapgens + + +local function deep_copy(table_in) + local table_out = {} + for index, value in pairs(table_in) do + if type(value) == "table" then + table_out[index] = deep_copy(value) + else + table_out[index] = value + end + end + return table_out +end +-- utility function used when making clay into springs +dynamic_liquid.duplicate_def = function (name) + local old_def = minetest.registered_nodes[name] + return deep_copy(old_def) +end + local modpath = minetest.get_modpath(minetest.get_current_modname()) dofile(modpath.."/cooling_lava.lua") diff --git a/mapgen_prefill.lua b/mapgen_prefill.lua index a55ad3f..f332a10 100644 --- a/mapgen_prefill.lua +++ b/mapgen_prefill.lua @@ -1,4 +1,4 @@ -local data = {} +local data = dynamic_liquid.mapgen_data dynamic_liquid.mapgen_prefill = function(def) diff --git a/mineclone.lua b/mineclone.lua index 472efa5..3cc1f35 100644 --- a/mineclone.lua +++ b/mineclone.lua @@ -6,7 +6,8 @@ local lava_probability = dynamic_liquid.config.lava_probability local water_level = dynamic_liquid.config.water_level local springs = dynamic_liquid.config.springs - +-- Since lava cooling behaviour can't be overridden in Mineclone, disabling dynamic liquid behaviour for lava +-- otherwise you get lava nodes wandering around on top of oceans covering the whole thing in stone. --if dynamic_liquid.config.lava then -- dynamic_liquid.liquid_abm("mcl_core:lava_source", "mcl_core:lava_flowing", lava_probability) --end @@ -25,7 +26,41 @@ if dynamic_liquid.config.river_water then end if dynamic_liquid.config.springs then - --TODO: mapgen clay, this is a temporary measure for testing purposes + local clay_def = dynamic_liquid.duplicate_def("mcl_core:clay") + clay_def.description = S("Damp Clay") + minetest.register_node("dynamic_liquid:clay", clay_def) + + local c_clay = minetest.get_content_id("mcl_core:clay") + local c_spring_clay = minetest.get_content_id("dynamic_liquid:clay") + + local spring_placement = function(minp, maxp, data) + if minp.y >= water_level or maxp.y <= -15 then + return false + end + local placed_spring = false + for voxelpos, voxeldata in pairs(data) do + if voxeldata == c_clay then + data[voxelpos] = c_spring_clay + placed_spring = true + end + end + return placed_spring + end + + -- mineclone 5 + if minetest.get_modpath("mcl_mapgen") and mcl_mapgen.register_on_generated then + mcl_mapgen.register_on_generated(function(vm_context) + if spring_placement(vm_context.minp, vm_context.maxp, vm_context.data) then + vm_context.write = true + end + end, 999999999+1) + end + --mineclone 2 + if minetest.get_modpath("mcl_mapgen_core") and mcl_mapgen_core.register_generator then + mcl_mapgen_core.register_generator("dynamic_liquid_damp_clay", function(vm, data, data2, emin, emax, area, minp, maxp, blockseed) + return spring_placement(minp, maxp, data) + end, nil, 999999+1) + end dynamic_liquid.spring({ nodenames = {"mcl_core:clay"}, diff --git a/mod.conf b/mod.conf index c0c1f26..09d8334 100644 --- a/mod.conf +++ b/mod.conf @@ -1,3 +1,3 @@ name = dynamic_liquid -optional_depends = default, doc, xpanes, carts, mcl_core, mclx_core +optional_depends = default, doc, xpanes, carts, mcl_core, mclx_core, mcl_mapgen_core, mcl_mapgen description = Flowing dynamic liquids and ocean-maintenance springs. \ No newline at end of file