From de5f3d5618d95bdc734ce943cd5f2312815d1923 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 12 Jan 2017 07:07:30 +0100 Subject: [PATCH] Add soil_sapling group --- API.md | 2 ++ mods/default/functions.lua | 16 ++++++++++------ mods/default/nodes.lua | 6 +++--- mods/farming/soil.lua | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/API.md b/API.md index 8c6e5382d..4335a1cac 100644 --- a/API.md +++ b/API.md @@ -12,6 +12,8 @@ This section explains all the used groups in this subgame. * `cultivatable=1`: Block will be turned into Dirt by using a hoe on it * `flammable`: Block helps spreading fire and gets destroyed by nearby fire (rating doesn't matter) * `soil=1`: Saplings and other small plants can grow on it +* `soil_sapling=2`: Soil for saplings. Intended to be natural soil. All saplings will grow on this +* `soil_sapling=1`: Artificial soil (such as farmland) for saplings. Some saplings will not grow on this * `soil_sugarcane=1`: Sugar canes will grow on this near water ### Groups (mostly) used for crafting recipes diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 210e8eda3..bfce01efd 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -609,14 +609,16 @@ minetest.register_abm({ -- Normal tree minetest.register_abm({ nodenames = {"default:sapling"}, - neighbors = {"default:dirt", "default:dirt_with_grass"}, + neighbors = {"group:soil_sapling"}, interval = 30, chance = 15, action = function(pos) local light = minetest.get_node_light(pos) - if light or light > 10 then - minetest.add_node(pos, {name="air"}) - generate_tree(pos, "default:tree", "default:leaves", 1) + local soilnode = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}) + local soiltype = mietest.get_item_group(soilnode.name, "soil_sapling") + if soiltype >= 1 and light and light >= 9 then + minetest.add_node(pos, {name="air"}) + generate_tree(pos, "default:tree", "default:leaves", 1) end end, }) @@ -624,12 +626,14 @@ minetest.register_abm({ -- Jungle Tree minetest.register_abm({ nodenames = {"default:junglesapling"}, - neighbors = {"default:dirt", "default:dirt_with_grass"}, + neighbors = {"group:soil_sapling"}, interval = 30, chance = 15, action = function(pos) local light = minetest.get_node_light(pos) - if light or light > 10 then + local soilnode = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}) + local soiltype = mietest.get_item_group(soilnode.name, "soil_sapling") + if soiltype == 2 and light and light >= 9 then minetest.add_node(pos, {name="air"}) generate_tree(pos, "default:jungletree", "default:jungleleaves", 2) end diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index 0d52b3302..547222700 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -257,7 +257,7 @@ minetest.register_node("default:dirt_with_grass", { tiles = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"}, is_ground_content = true, stack_max = 64, - groups = {crumbly=3, soil=1, soil_sugarcane=1, cultivatable=2}, + groups = {crumbly=3, soil=1, soil_sapling=2, soil_sugarcane=1, cultivatable=2}, drop = 'default:dirt', sounds = default.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.4}, @@ -282,7 +282,7 @@ minetest.register_node("default:podzol", { tiles = {"default_dirt_podzol_top.png", "default_dirt.png", "default_dirt_podzol_side.png"}, is_ground_content = true, stack_max = 64, - groups = {crumbly=3, soil=1, soil_sugarcane=1}, + groups = {crumbly=3, soil=1, soil_sapling=2, soil_sugarcane=1}, drop = 'default:dirt', sounds = default.node_sound_dirt_defaults(), }) @@ -292,7 +292,7 @@ minetest.register_node("default:dirt", { tiles = {"default_dirt.png"}, is_ground_content = true, stack_max = 64, - groups = {crumbly=3, soil=1, soil_sugarcane=1, cultivatable=2}, + groups = {crumbly=3, soil=1, soil_sapling=2, soil_sugarcane=1, cultivatable=2}, sounds = default.node_sound_dirt_defaults(), }) diff --git a/mods/farming/soil.lua b/mods/farming/soil.lua index e80508209..45a859a22 100644 --- a/mods/farming/soil.lua +++ b/mods/farming/soil.lua @@ -11,7 +11,7 @@ minetest.register_node("farming:soil", { {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5}, } }, - groups = {crumbly=3, not_in_creative_inventory=1,soil=2}, + groups = { crumbly=3, not_in_creative_inventory=1, soil=2, soil_sapling=1 }, sounds = default.node_sound_dirt_defaults(), }) @@ -27,7 +27,7 @@ minetest.register_node("farming:soil_wet", { {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5}, } }, - groups = {crumbly=3, not_in_creative_inventory=1,soil=3}, + groups = { crumbly=3, not_in_creative_inventory=1, soil=3, soil_sapling=1 }, sounds = default.node_sound_dirt_defaults(), })