From 89a467698a7637b8a81e46a63aa10308e5585bb1 Mon Sep 17 00:00:00 2001 From: Treer Date: Tue, 2 Feb 2021 17:15:22 +1100 Subject: [PATCH 1/2] minor fixes Fixes issue #34 (get_node_group deprecated), and removes nether:lava_source from creative_inventory --- nodes.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nodes.lua b/nodes.lua index afb6fb4..eadac0e 100644 --- a/nodes.lua +++ b/nodes.lua @@ -308,6 +308,8 @@ lavasea_source.tiles = { }, }, } +lavasea_source.groups = { not_in_creative_inventory = 1 } -- Avoid having two lava source blocks in the inv. +for key, value in pairs(lava_source.groups) do lavasea_source.groups[key] = value end lavasea_source.liquid_alternative_source = "nether:lava_source" lavasea_source.inventory_image = minetest.inventorycube( "nether_lava_source_animated.png^[sheet:2x16:0,0", @@ -327,7 +329,7 @@ nether.cool_lava = function(pos, node) -- Evaporate water sitting above lava, if it's in the Nether. -- (we don't want Nether mod to affect overworld lava mechanics) - if minetest.get_node_group(node_above.name, "water") > 0 and + if minetest.get_item_group(node_above.name, "water") > 0 and pos.y < nether.DEPTH_CEILING and pos.y > nether.DEPTH_FLOOR then -- cools_lava might be a better group to check for, but perhaps there's -- something in that group that isn't a liquid and shouldn't be evaporated? From 00099f2aa2b68fb15409effe27b27e239b5af764 Mon Sep 17 00:00:00 2001 From: Treer Date: Wed, 3 Feb 2021 22:41:52 +1100 Subject: [PATCH 2/2] Fix #36 - better handling of biome definition tables Add support for min_pos and max_pos in biome definition tables, and follow the same interpretation logic as Minetest, same defaults/fallbacks etc. --- mapgen.lua | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/mapgen.lua b/mapgen.lua index c82a7db..12b50ba 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -108,7 +108,7 @@ local function override_underground_biomes() end for old_ore_key, old_ore_def in pairs(minetest.registered_ores) do registered_ores_copy[old_ore_key] = old_ore_def - end + end -- clear biomes, decorations, and ores minetest.clear_registered_decorations() @@ -117,23 +117,36 @@ local function override_underground_biomes() -- Restore biomes, adjusted to not overlap the Nether for biome_key, new_biome_def in pairs(registered_biomes_copy) do - local biome_y_max, biome_y_min = tonumber(new_biome_def.y_max), tonumber(new_biome_def.y_min) + -- follow similar min_pos/max_pos processing logic as read_biome_def() in l_mapgen.cpp + local biome_y_max, biome_y_min = 31000, -31000 + if type(new_biome_def.min_pos) == 'table' and type(new_biome_def.min_pos.y) == 'number' then biome_y_min = new_biome_def.min_pos.y end + if type(new_biome_def.max_pos) == 'table' and type(new_biome_def.max_pos.y) == 'number' then biome_y_max = new_biome_def.max_pos.y end + if type(new_biome_def.y_min) == 'number' then biome_y_min = new_biome_def.y_min end + if type(new_biome_def.y_max) == 'number' then biome_y_max = new_biome_def.y_max end if biome_y_max > NETHER_FLOOR and biome_y_min < NETHER_CEILING then -- This biome occupies some or all of the depth of the Nether, shift/crop it. + local new_y_min, new_y_max local spaceOccupiedAbove = biome_y_max - NETHER_CEILING local spaceOccupiedBelow = NETHER_FLOOR - biome_y_min if spaceOccupiedAbove >= spaceOccupiedBelow or biome_y_min <= -30000 then -- place the biome above the Nether -- We also shift biomes which extend to the bottom of the map above the Nether, since they -- likely only extend that deep as a catch-all, and probably have a role nearer the surface. - new_biome_def.y_min = NETHER_CEILING + 1 - new_biome_def.y_max = math_max(biome_y_max, NETHER_CEILING + 2) + new_y_min = NETHER_CEILING + 1 + new_y_max = math_max(biome_y_max, NETHER_CEILING + 2) else -- shift the biome to below the Nether - new_biome_def.y_max = NETHER_FLOOR - 1 - new_biome_def.y_min = math_min(biome_y_min, NETHER_CEILING - 2) + new_y_max = NETHER_FLOOR - 1 + new_y_min = math_min(biome_y_min, NETHER_CEILING - 2) end + + debugf("Moving biome \"%s\" from %s..%s to %s..%s", new_biome_def.name, new_biome_def.y_min, new_biome_def.y_max, new_y_min, new_y_max) + + if type(new_biome_def.min_pos) == 'table' and type(new_biome_def.min_pos.y) == 'number' then new_biome_def.min_pos.y = new_y_min end + if type(new_biome_def.max_pos) == 'table' and type(new_biome_def.max_pos.y) == 'number' then new_biome_def.max_pos.y = new_y_max end + new_biome_def.y_min = new_y_min -- Ensure the new heights are saved, even if original biome never specified one + new_biome_def.y_max = new_y_max end minetest.register_biome(new_biome_def) end