From cc15d6be6dec71602630fa62156f126e77d358d0 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 21 Aug 2017 16:16:30 +0200 Subject: [PATCH] Add Nether decorations Nether wart, eternal fire, mushrooms --- mods/MAPGEN/mcl_biomes/init.lua | 61 +------------------------ mods/MAPGEN/mcl_mapgen_core/init.lua | 68 ++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 64 deletions(-) diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index 5b8f4a2199..165f67c7d9 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -948,19 +948,6 @@ local function register_dimension_ores() y_max = mcl_vars.mg_nether_max, }) - -- Fire in the Nether (hacky) - -- FIXME: Remove this when fire as decoration is available - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_fire:eternal_fire", - wherein = {"mcl_nether:netherrack", "mcl_core:stone"}, - clust_scarcity =12 *22 * 12, - clust_num_ores = 5, - clust_size = 5, - y_min = mcl_vars.mg_nether_min, - y_max = mcl_vars.mg_nether_max, - }) - --[[ THE END ]] -- Generate fake End @@ -1761,53 +1748,7 @@ end -- Decorations in non-Overworld dimensions local function register_dimension_decorations() - --[[ NETHER decorations ]] - - -- Red Mushroom - minetest.register_decoration({ - deco_type = "simple", - place_on = {"mcl_nether:netherrack"}, - sidelen = 80, - fill_ratio = 0.01, - biomes = {"nether"}, - y_min = mcl_vars.mg_nether_min, - y_max = mcl_vars.mg_nether_max, - decoration = "mcl_mushrooms:mushroom_red", - }) - -- Brown Mushroom - minetest.register_decoration({ - deco_type = "simple", - place_on = {"mcl_nether:netherrack"}, - sidelen = 80, - fill_ratio = 0.01, - biomes = {"nether"}, - y_min = mcl_vars.mg_nether_min, - y_max = mcl_vars.mg_nether_max, - decoration = "mcl_mushrooms:mushroom_brown", - }) - - -- Eternal Fire - minetest.register_decoration({ - deco_type = "simple", - place_on = {"mcl_nether:netherrack"}, - sidelen = 16, - fill_ratio = 0.2, - biomes = {"nether"}, - y_min = mcl_vars.mg_nether_min, - y_max = mcl_vars.mg_nether_max, - decoration = "mcl_fire:eternal_fire", - }) - -- Nether Wart - minetest.register_decoration({ - deco_type = "simple", - place_on = {"mcl_nether:soul_sand"}, - sidelen = 80, - fill_ratio = 0.1, - biomes = {"nether"}, - y_min = mcl_vars.mg_nether_min, - y_max = mcl_vars.mg_nether_max, - decoration = "mcl_nether:nether_wart", - }) + -- TODO end -- diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index a9aa80ba62..5a91093aee 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -1147,11 +1147,14 @@ local function generate_jungle_tree_decorations(minp, maxp) end end --- Generate mushrooms in caves +local pr_shroom = PseudoRandom(os.time()-24359) +-- Generate mushrooms in caves manually. +-- Minetest's API does not support decorations in caves yet. :-( local generate_underground_mushrooms = function(minp, maxp) -- Generate rare underground mushrooms -- TODO: Make them appear in groups, use Perlin noise - if minp.y > 0 or maxp.y < -32 then + local min, max = mcl_vars.mg_lava_overworld_max + 4, 0 + if minp.y > max or maxp.y < min then return end @@ -1161,8 +1164,8 @@ local generate_underground_mushrooms = function(minp, maxp) for n = 1, #stone do bpos = {x = stone[n].x, y = stone[n].y + 1, z = stone[n].z } - if math.random(1,1000) < 4 and minetest.get_node_light(bpos, 0.5) <= 12 then - if math.random(1,2) == 1 then + if bpos.y >= min and bpos.y <= max and minetest.get_node_light(bpos, 0.5) <= 12 and pr_shroom:next(1,1000) < 4 then + if pr_shroom:next(1,2) == 1 then minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_brown"}) else minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_red"}) @@ -1171,6 +1174,62 @@ local generate_underground_mushrooms = function(minp, maxp) end end +local pr_nether = PseudoRandom(os.time()+667) +-- Generate Nether decorations manually: Eternal fire, mushrooms, nether wart +-- Minetest's API does not support decorations in caves yet. :-( +local generate_nether_decorations = function(minp, maxp) + if minp.y > mcl_vars.mg_nether_max or maxp.y < mcl_vars.mg_nether_min then + return + end + + -- TODO: Generate everything based on Perlin noise instead of PseudoRandom + + local bpos + local rack = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_nether:netherrack"}) + local magma = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_nether:magma"}) + local ssand = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_nether:soul_sand"}) + + -- Helper function to spawn “fake” decoration + local special_deco = function(nodes, spawn_func) + for n = 1, #nodes do + bpos = {x = nodes[n].x, y = nodes[n].y + 1, z = nodes[n].z } + + spawn_func(bpos) + end + + end + + special_deco(rack, function(bpos) + -- Mushrooms on netherrack + if bpos.y > mcl_vars.mg_lava_nether_max + 6 and minetest.get_node_light(bpos, 0.5) <= 12 and pr_nether:next(1,1000) <= 4 then + -- TODO: Make mushrooms appear in groups, use Perlin noise + if pr_nether:next(1,2) == 1 then + minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_brown"}) + else + minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_red"}) + end + -- Eternal fire on netherrack + elseif pr_nether:next(1,100) <= 3 then + minetest.set_node(bpos, {name = "mcl_fire:eternal_fire"}) + end + end) + + -- Eternal fire on magma cubes + special_deco(magma, function(bpos) + if pr_nether:next(1,150) == 1 then + minetest.set_node(bpos, {name = "mcl_fire:eternal_fire"}) + end + end) + + -- Nether wart on soul sand + -- TODO: Spawn in Nether fortresses + special_deco(ssand, function(bpos) + if pr_nether:next(1,170) == 1 then + minetest.set_node(bpos, {name = "mcl_nether:nether_wart"}) + end + end) + +end -- Below the bedrock, generate air/void minetest.register_on_generated(function(minp, maxp) @@ -1337,6 +1396,7 @@ minetest.register_on_generated(function(minp, maxp) generate_underground_mushrooms(minp, maxp) generate_jungle_tree_decorations(minp, maxp) + generate_nether_decorations(minp, maxp) end)