forked from VoxeLibre/VoxeLibre
Implement proper bone meal behaviour for saplings
This commit is contained in:
parent
2f0dbb03ff
commit
01200e9214
|
@ -434,6 +434,33 @@ local sapling_grow_action = function(trunknode, leafnode, tree_id, soil_needed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Attempts to grow the sapling at the specified position
|
||||||
|
-- pos: Position
|
||||||
|
-- node: Node table of the node at this position, from minetest.get_node
|
||||||
|
-- Returns true on success and false on failure
|
||||||
|
mcl_core.grow_sapling = function(pos, node)
|
||||||
|
local grow
|
||||||
|
if node.name == "mcl_core:sapling" then
|
||||||
|
grow = sapling_grow_action("mcl_core:tree", "mcl_core:leaves", 1, 1)
|
||||||
|
elseif node.name == "mcl_core:darksapling" then
|
||||||
|
grow = sapling_grow_action("mcl_core:darktree", "mcl_core:darkleaves", 1, 2)
|
||||||
|
elseif node.name == "mcl_core:junglesapling" then
|
||||||
|
grow = sapling_grow_action("mcl_core:jungletree", "mcl_core:jungleleaves", 1, 2)
|
||||||
|
elseif node.name == "mcl_core:acaciasapling" then
|
||||||
|
grow = sapling_grow_action("mcl_core:acaciatree", "mcl_core:acacialeaves", 1, 2)
|
||||||
|
elseif node.name == "mcl_core:sprucesapling" then
|
||||||
|
grow = sapling_grow_action("mcl_core:sprucetree", "mcl_core:spruceleaves", 1, 1)
|
||||||
|
elseif node.name == "mcl_core:birchsapling" then
|
||||||
|
grow = sapling_grow_action("mcl_core:birchtree", "mcl_core:birchleaves", 1, 1)
|
||||||
|
end
|
||||||
|
if grow then
|
||||||
|
grow(pos)
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- TODO: Use better tree models for everything
|
-- TODO: Use better tree models for everything
|
||||||
-- TODO: Support 2×2 saplings
|
-- TODO: Support 2×2 saplings
|
||||||
|
|
||||||
|
|
|
@ -128,10 +128,11 @@ mcl_dye.apply_bone_meal = function(pointed_thing)
|
||||||
n = minetest.get_node(pos)
|
n = minetest.get_node(pos)
|
||||||
if n.name == "" then return false end
|
if n.name == "" then return false end
|
||||||
local stage = ""
|
local stage = ""
|
||||||
if n.name == "mcl_core:sapling" then
|
if minetest.get_item_group(n.name, "sapling") >= 1 then
|
||||||
minetest.add_node(pos, {name="air"})
|
-- 45% chance to advance growth stage of sapling
|
||||||
mcl_core.generate_tree(pos, "mcl_core:tree", "mcl_core:leaves", 1)
|
if math.random(1,100) <= 45 then
|
||||||
return true
|
return mcl_core.grow_sapling(pos, n)
|
||||||
|
end
|
||||||
elseif string.find(n.name, "mcl_farming:wheat_") ~= nil then
|
elseif string.find(n.name, "mcl_farming:wheat_") ~= nil then
|
||||||
stage = string.sub(n.name, -1)
|
stage = string.sub(n.name, -1)
|
||||||
if stage == "3" then
|
if stage == "3" then
|
||||||
|
|
Loading…
Reference in New Issue