diff --git a/nalc_flowers/depends.txt b/nalc_flowers/depends.txt index 4ad96d5..5ca1f17 100644 --- a/nalc_flowers/depends.txt +++ b/nalc_flowers/depends.txt @@ -1 +1,2 @@ default +biome_lib? diff --git a/nalc_flowers/init.lua b/nalc_flowers/init.lua index f154fff..3b314d7 100644 --- a/nalc_flowers/init.lua +++ b/nalc_flowers/init.lua @@ -62,27 +62,69 @@ lilypad_waving_def.groups.not_in_creative_inventory = 1 minetest.register_node("nalc_flowers:lily_pad", lilypad_def) minetest.register_node("nalc_flowers:lily_pad_waving", lilypad_waving_def) -minetest.register_decoration({ - name = "nalc_flowers:lily_pad", - deco_type = "simple", - place_on = {"default:dirt"}, - sidelen = 16, - noise_params = { - offset = -0.12, - scale = 0.3, - spread = {x=200, y=200, z=200}, - seed = 34, - octaves = 3, - persist = 0.7 - }, - biomes = {"rainforest_swamp", "savanna_shore", "deciduous_forest_shore"}, - y_min = 0, - y_max = 0, - decoration = "nalc_flowers:lily_pad_waving", - param2 = 0, - param2_max = 3, - place_offset_y = 1, -}) +if biome_lib then + local grow_lily_pad = function(pos) + minetest.swap_node( + {x=pos.x, y=pos.y+1, z=pos.z}, + { + name="nalc_flowers:lily_pad_waving", + param2=math.random(0,3) + } + ) + end + + biome_lib:register_generate_plant({ + surface = {"default:water_source"}, + max_count = 320, + rarity = 33, + min_elevation = 1, + max_elevation = 40, + near_nodes = {"default:dirt_with_grass", "default:dry_dirt_with_dry_grass", "default:jungletree"}, + near_nodes_size = 4, + near_nodes_vertical = 1, + near_nodes_count = 1, + plantlife_limit = -0.9, + temp_max = -0.22, + temp_min = 0.22, + }, + grow_lily_pad + ) + -- spawn ABM registration + biome_lib:spawn_on_surfaces({ + spawn_delay = 500, + spawn_plants = {"nalc_flowers:lily_pad_waving"}, + avoid_radius = 2.5, + spawn_chance = 800, + spawn_surfaces = {"default:water_source"}, + avoid_nodes = {"group:flower", "group:flora"}, + seed_diff = 330, + light_min = 9, + depth_max = 2, + random_facedir = {0,3}, + }) +else + minetest.register_decoration({ + name = "nalc_flowers:lily_pad", + deco_type = "simple", + place_on = {"default:dirt"}, + sidelen = 16, + noise_params = { + offset = -0.12, + scale = 0.3, + spread = {x=200, y=200, z=200}, + seed = 34, + octaves = 3, + persist = 0.7 + }, + biomes = {"rainforest_swamp", "savanna_shore", "deciduous_forest_shore"}, + y_min = 0, + y_max = 0, + decoration = "nalc_flowers:lily_pad_waving", + param2 = 0, + param2_max = 3, + place_offset_y = 1, + }) +end minetest.register_alias("flowers:lily_pad", "nalc_flowers:lily_pad") minetest.register_alias("nalc:lily_pad", "nalc_flowers:lily_pad")