From ccb9a2782789ee3e14c1f4923c6e99bab8902830 Mon Sep 17 00:00:00 2001 From: philipmi Date: Sun, 2 Jan 2022 18:05:08 +0100 Subject: [PATCH] Add plumtree and farming_plus support + fix groups --- README.md | 2 +- depends.txt | 1 + init.lua | 27 ++++++++++++++++++++------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c3dc133..7766c1c 100644 --- a/README.md +++ b/README.md @@ -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. -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. diff --git a/depends.txt b/depends.txt index d4a4c64..70878e3 100644 --- a/depends.txt +++ b/depends.txt @@ -10,3 +10,4 @@ palm? plumtree? pomegranate? moretrees? +farming_plus? \ No newline at end of file diff --git a/init.lua b/init.lua index d9f0297..fb8c1ef 100644 --- a/init.lua +++ b/init.lua @@ -7,17 +7,24 @@ local add_fruit_regrowable = function(fruit, node, leaves) return 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 minetest.override_item(node, { - groups = {dig_immediate=3}, -- make sure (moretrees) fruits don't fall on dig - after_place_node = function(pos, placer) - if placer:is_player() then + groups = groups, -- make sure (moretrees) fruits don't fall on dig + after_place_node = function(pos, placer) -- make sure (moretrees and plumtree) fruits aren't placed by player + 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}) 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 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.get_node_timer(pos):start(math.random(300, 1500)) end @@ -41,6 +48,8 @@ local add_fruit_regrowable = function(fruit, node, leaves) minetest.remove_node(pos) elseif minetest.get_node_light(pos) < 13 then minetest.get_node_timer(pos):start(200) + elseif node == "plumtree:plum" then + minetest.set_node(pos, {name = node, param2 = 1}) else minetest.set_node(pos, {name = node}) end @@ -69,11 +78,15 @@ add_fruit_regrowable("persimmon", "ebony:persimmon", "ebony:leaves") add_fruit_regrowable("coollemon", "lemontree:lemon", "lemontree:leaves") add_fruit_regrowable("acorn", "oak:acorn", "oak: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") -- moretrees add_fruit_regrowable("moreacorn", "moretrees:acorn", "moretrees:oak_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("spruce_cone", "moretrees:spruce_cone", "moretrees:spruce_leaves") \ No newline at end of file +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") \ No newline at end of file