From a9174508dfc2b55b68422775793285a1bdb882fe Mon Sep 17 00:00:00 2001 From: philipmi Date: Wed, 29 Dec 2021 17:30:22 +0100 Subject: [PATCH] Add more mod support (cool_trees modpack and moretrees) --- README.md | 2 +- depends.txt | 12 +++++++++++- init.lua | 46 ++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9375051..c3dc133 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. -At the moment only ethereal mod is supported, but I'm sure there are other mods with this problem I do not use. Please tell me on Minetest Forum topic! +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! 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 2ffd916..d4a4c64 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1,12 @@ default -ethereal? \ No newline at end of file +ethereal? +cherrytree? +chestnuttree? +clementinetree? +ebony? +lemontree? +oak? +palm? +plumtree? +pomegranate? +moretrees? diff --git a/init.lua b/init.lua index be6c6cd..cc31349 100644 --- a/init.lua +++ b/init.lua @@ -2,8 +2,21 @@ local regrowing_apples = minetest.settings:get_bool("regrowing_apples", true) local add_fruit_regrowable = function(fruit, node, leaves) + -- check if node exists + if not minetest.registered_nodes[node] then + return + end + -- override fruit minetest.override_item(node, { + drawtype = "torchlike", -- make sure (moretrees) fruits disappear when the tree is cut down + groups = {dig_immediate=3}, -- make sure (moretrees) fruits don't fall on dig + after_place_node = function(pos, placer) + if placer:is_player() then + minetest.set_node(pos, {name = node, param2 = 1}) + end + end, -- make sure (moretrees) fruits aren't placed by player + 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 minetest.set_node(pos, {name = "regrowing_fruits:"..fruit.."_mark"}) @@ -36,15 +49,32 @@ local add_fruit_regrowable = function(fruit, node, leaves) }) end +-- apples if regrowing_apples then add_fruit_regrowable("apple", "default:apple", "default:leaves") end -if minetest.get_modpath("ethereal") then - add_fruit_regrowable("banana","ethereal:banana", "ethereal:bananaleaves") - add_fruit_regrowable("coconut", "ethereal:coconut", "ethereal:palmleaves") - add_fruit_regrowable("goldapple", "ethereal:golden_apple", "ethereal:yellowleaves") - add_fruit_regrowable("lemon", "ethereal:lemon", "ethereal:lemon_leaves") - add_fruit_regrowable("olive", "ethereal:olive", "ethereal:olive_leaves") - add_fruit_regrowable("orange", "ethereal:orange", "ethereal:orange_leaves") -end \ No newline at end of file +-- ethereal +add_fruit_regrowable("banana","ethereal:banana", "ethereal:bananaleaves") +add_fruit_regrowable("coconut", "ethereal:coconut", "ethereal:palmleaves") +add_fruit_regrowable("goldapple", "ethereal:golden_apple", "ethereal:yellowleaves") +add_fruit_regrowable("lemon", "ethereal:lemon", "ethereal:lemon_leaves") +add_fruit_regrowable("olive", "ethereal:olive", "ethereal:olive_leaves") +add_fruit_regrowable("orange", "ethereal:orange", "ethereal:orange_leaves") + +-- cool_trees TODO: add cacao +add_fruit_regrowable("cherry", "cherrytree:cherries", "cherrytree:blossom_leaves") +add_fruit_regrowable("chestnut", "chestnuttree:bur", "chestnuttree:leaves") +add_fruit_regrowable("clementine", "clementinetree:clementine", "clementinetree:leaves") +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("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