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
|
||||
|
||||
-- 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: Support 2×2 saplings
|
||||
|
||||
|
|
|
@ -128,10 +128,11 @@ mcl_dye.apply_bone_meal = function(pointed_thing)
|
|||
n = minetest.get_node(pos)
|
||||
if n.name == "" then return false end
|
||||
local stage = ""
|
||||
if n.name == "mcl_core:sapling" then
|
||||
minetest.add_node(pos, {name="air"})
|
||||
mcl_core.generate_tree(pos, "mcl_core:tree", "mcl_core:leaves", 1)
|
||||
return true
|
||||
if minetest.get_item_group(n.name, "sapling") >= 1 then
|
||||
-- 45% chance to advance growth stage of sapling
|
||||
if math.random(1,100) <= 45 then
|
||||
return mcl_core.grow_sapling(pos, n)
|
||||
end
|
||||
elseif string.find(n.name, "mcl_farming:wheat_") ~= nil then
|
||||
stage = string.sub(n.name, -1)
|
||||
if stage == "3" then
|
||||
|
|
Loading…
Reference in New Issue