Add plumtree and farming_plus support + fix groups

This commit is contained in:
philipmi 2022-01-02 18:05:08 +01:00
parent 2da1d8d925
commit ccb9a27827
3 changed files with 22 additions and 8 deletions

View file

@ -6,7 +6,7 @@ Info
This mod causes fruits on trees from other mods to regrow like apples in the 5.0 release of Minetest Game. If you placed the fruits by hand or removed the tree leaves, the fruits don't regrow. This mod causes fruits on trees from other mods to regrow like apples in the 5.0 release of Minetest Game. If you placed the fruits by hand or removed the tree leaves, the fruits don't regrow.
Cool_trees modpack, ethereal and moretrees are supported, but maybe there are other mods with this problem that I don't know about. Please tell me in the Minetest Forum topic! Cool_trees modpack, ethereal, farming_plus and moretrees are supported, but maybe there are other mods with this problem that I don't know about. Please tell me in the Minetest Forum topic!
There is also the possibility to enable regrowing apples in Minetest Settings. Notice that this is only necessary for older versions than MT 5.0. There is also the possibility to enable regrowing apples in Minetest Settings. Notice that this is only necessary for older versions than MT 5.0.

View file

@ -10,3 +10,4 @@ palm?
plumtree? plumtree?
pomegranate? pomegranate?
moretrees? moretrees?
farming_plus?

View file

@ -7,17 +7,24 @@ local add_fruit_regrowable = function(fruit, node, leaves)
return return
end end
local groups = node.groups
if minetest.get_item_group(node, "attached_node") == 1 then
groups = {fleshy=3, dig_immediate=3, flammable=2, leafdecay = 1, leafdecay_drop = 1}
end
-- override fruit -- override fruit
minetest.override_item(node, { minetest.override_item(node, {
groups = {dig_immediate=3}, -- make sure (moretrees) fruits don't fall on dig groups = groups, -- make sure (moretrees) fruits don't fall on dig
after_place_node = function(pos, placer) after_place_node = function(pos, placer) -- make sure (moretrees and plumtree) fruits aren't placed by player
if placer:is_player() then if placer:is_player() and node == "plumtree:plum" then
minetest.set_node(pos, {name = node, param2 = 0})
elseif placer:is_player() then
minetest.set_node(pos, {name = node, param2 = 1}) minetest.set_node(pos, {name = node, param2 = 1})
end end
end, -- make sure (moretrees) fruits aren't placed by player end,
on_dig = minetest.node_dig, -- override on_dig functions causing regrowth not to work on_dig = minetest.node_dig, -- override on_dig functions causing regrowth not to work
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
if oldnode.param2 == 0 then if oldnode.param2 == 0 and oldnode.name ~= "plumtree:plum" or oldnode.name == "plumtree:plum" and oldnode.param2 == 1 then
minetest.set_node(pos, {name = "regrowing_fruits:"..fruit.."_mark"}) minetest.set_node(pos, {name = "regrowing_fruits:"..fruit.."_mark"})
minetest.get_node_timer(pos):start(math.random(300, 1500)) minetest.get_node_timer(pos):start(math.random(300, 1500))
end end
@ -41,6 +48,8 @@ local add_fruit_regrowable = function(fruit, node, leaves)
minetest.remove_node(pos) minetest.remove_node(pos)
elseif minetest.get_node_light(pos) < 13 then elseif minetest.get_node_light(pos) < 13 then
minetest.get_node_timer(pos):start(200) minetest.get_node_timer(pos):start(200)
elseif node == "plumtree:plum" then
minetest.set_node(pos, {name = node, param2 = 1})
else else
minetest.set_node(pos, {name = node}) minetest.set_node(pos, {name = node})
end end
@ -69,11 +78,15 @@ add_fruit_regrowable("persimmon", "ebony:persimmon", "ebony:leaves")
add_fruit_regrowable("coollemon", "lemontree:lemon", "lemontree:leaves") add_fruit_regrowable("coollemon", "lemontree:lemon", "lemontree:leaves")
add_fruit_regrowable("acorn", "oak:acorn", "oak:leaves") add_fruit_regrowable("acorn", "oak:acorn", "oak:leaves")
add_fruit_regrowable("coolcoconut", "palm:coconut", "palm:leaves") add_fruit_regrowable("coolcoconut", "palm:coconut", "palm:leaves")
add_fruit_regrowable("plum", "plumtree:plum", "plumtree:leaves") -- TODO: fix param2: 1 add_fruit_regrowable("plum", "plumtree:plum", "plumtree:leaves")
add_fruit_regrowable("pomegranate", "pomegranate:pomegranate", "pomegranate:leaves") add_fruit_regrowable("pomegranate", "pomegranate:pomegranate", "pomegranate:leaves")
-- moretrees -- moretrees
add_fruit_regrowable("moreacorn", "moretrees:acorn", "moretrees:oak_leaves") add_fruit_regrowable("moreacorn", "moretrees:acorn", "moretrees:oak_leaves")
add_fruit_regrowable("cedar_cone", "moretrees:cedar_cone", "moretrees:cedar_leaves") add_fruit_regrowable("cedar_cone", "moretrees:cedar_cone", "moretrees:cedar_leaves")
add_fruit_regrowable("fir_cone", "moretrees:fir_cone", "moretrees:fir_leaves") add_fruit_regrowable("fir_cone", "moretrees:fir_cone", "moretrees:fir_leaves")
add_fruit_regrowable("spruce_cone", "moretrees:spruce_cone", "moretrees:spruce_leaves") add_fruit_regrowable("spruce_cone", "moretrees:spruce_cone", "moretrees:spruce_leaves")
-- farming_plus
add_fruit_regrowable("cocoa", "farming_plus:cocoa", "farming_plus:cocoa_leaves")
add_fruit_regrowable("banana_plus", "farming_plus:banana", "farming_plus:banana_leaves")