[Mod] Regrowing Fruits [regrowing_fruits]

Post Reply
philipmi
Member
Posts: 10
Joined: Wed Apr 08, 2020 18:23

[Mod] Regrowing Fruits [regrowing_fruits]

by philipmi » Post

Regrowing Fruits

Image Image

Image

Info
This mod causes fruits on trees from various other mods to regrow like apples in the 5.0 release of Minetest Game. It also offers a small API to add fruit regrowth quickly.
If the fruit was placed by hand or the tree was chopped down, the fruit won't grow back. There is also a small chance that regrowth will stop randomly, so trees will bear less fruit over time.

Currently supported mods/modpacks are: default, ethereal, cool_trees, moretrees, farming_plus, multibiomegen, australia and aotearoa.

The standard regrowth time can be changed in settings (min_regrow_interval and max_regrow_interval) as well as the chance of regrowth stopping (regrowth_stop_chance).

Ideas, bug reports or requests for more mod support are always welcome here in the Minetest Forum topic or via the Git Issue Tracker!
The regrowing_fruits.add() function overrides the fruits after_dig_node function and registers a placeholder node that will be placed once the fruit is taken and regrows the fruit after a timer expires.

Definition:

Code: Select all

regrowing_fruits.add(fruitname, leafname, param2, multiplier)
  • fruitname: nodename of the fruit to be added.
  • leafname: nodename of the corresponding leaves (used as a reference whether tree is still alive).
  • param2: param2 value of fruit when placed naturally (not by player). Defaults to 0; -1 disables param2 checks for fruit regrowth (use this if your fruit has different rotations). If set, overrides after_place_node of fruit node to be able to differentiate fruits by param2 when placed by player.
  • multiplier: multiplier for the standard average regrowth time.
Examples:

Code: Select all

regrowing_fruits.add("default:apple", "default:leaves")
regrowing_fruits.add("ethereal:golden_apple", "ethereal:yellowleaves", nil, 3)
regrowing_fruits.add("cacaotree:pod", "cacaotree:trunk", -1)
For more examples see init.lua. Alternative Mods
Consider using regrow by TenPlus1. It has similar features, but registers only one placeholder node in total instead of one node for every fruit.

Credits
This mod is based on "endless_apples" by Shara RedCat (2018).

License
Code for this mod is released under MIT.

Mod dependencies
none

Optional dependencies
default, ethereal, cacaotree, cherrytree, chestnuttree, clementinetree, ebony, lemontree, oak, palm, plumtree, pomegranate, moretrees, farming_plus, multibiomegen, australia, aotearoa

Download
Source: https://git.sp-codes.de/minetest/regrowing_fruits.git
Last edited by philipmi on Wed Aug 09, 2023 12:17, edited 13 times in total.

User avatar
firefox
Member
Posts: 1709
Joined: Wed Jan 14, 2015 07:34
In-game: Red_Fox
Location: Xanadu

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by firefox » Post

great! :D

i never bothered with fruit, since i had to fell and replant the whole forest for a handful of fruits.
and then hunger would force me to eat, consuming the entire harvest...
✨🏳️‍🌈♣️✨

revevil
Member
Posts: 49
Joined: Tue May 14, 2019 03:11

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by revevil » Post

philipmi wrote:
Sat Jun 27, 2020 20:03
Regrowing Fruits

Image

Info
This mod causes fruits on trees from various 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, farming_plus, multibiomegen and moretrees are supported, but maybe there are other mods with this problem that I don't know about. Please tell me below!

Default apples in older versions than Minetest 5.0 will also regrow.

Credits
This mod is inspired by "endless_apples" by Shara RedCat (2018).

License
Code for this mod is released under MIT (https://opensource.org/licenses/MIT).

Mod dependencies
none

Optional dependencies
default, ethereal, cacaotree, cherrytree, chestnuttree, clementinetree, ebony, lemontree, oak, palm, plumtree, pomegranate, moretrees, farming_plus

Download
Source: https://git.sp-codes.de/philipmi/regrowing_fruits.git


If you got ideas or found bugs, please let me know below!
Hello philipmi,

You said to let you know if anyone found bugs in this mod. I just wanted to say I have had this mod installed for the last 2 weeks, and it has not regrown any fruit on trees. I tested it on an oak tree and a plum tree. I'm not sure why it didn't work. Looked at the init.lua script, and you spelled everything correctly! (I checked with the debug output). If it makes a difference, I know for sure I had a pickaxe equipped when I picked the fruit, but I did not touch any leaves at all.

philipmi
Member
Posts: 10
Joined: Wed Apr 08, 2020 18:23

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by philipmi » Post

revevil wrote:
Sat Feb 26, 2022 04:18

Hello philipmi,

You said to let you know if anyone found bugs in this mod. I just wanted to say I have had this mod installed for the last 2 weeks, and it has not regrown any fruit on trees. I tested it on an oak tree and a plum tree. I'm not sure why it didn't work. Looked at the init.lua script, and you spelled everything correctly! (I checked with the debug output). If it makes a difference, I know for sure I had a pickaxe equipped when I picked the fruit, but I did not touch any leaves at all.
Thank you for reporting this, revevil.

I tested it myself again and it worked normally...
So I assume that you use other mods which also override the fruit nodes causing regrowth not to work properly. I updated the git repository, so it overrides the fruit nodes after all mods are loaded. Could you test if that solves your issue?
Please notice that this can cause the other mods not to work...

revevil
Member
Posts: 49
Joined: Tue May 14, 2019 03:11

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by revevil » Post

philipmi wrote:
Sat Feb 26, 2022 16:43
revevil wrote:
Sat Feb 26, 2022 04:18

Hello philipmi,

You said to let you know if anyone found bugs in this mod. I just wanted to say I have had this mod installed for the last 2 weeks, and it has not regrown any fruit on trees. I tested it on an oak tree and a plum tree. I'm not sure why it didn't work. Looked at the init.lua script, and you spelled everything correctly! (I checked with the debug output). If it makes a difference, I know for sure I had a pickaxe equipped when I picked the fruit, but I did not touch any leaves at all.
Thank you for reporting this, revevil.

I tested it myself again and it worked normally...
So I assume that you use other mods which also override the fruit nodes causing regrowth not to work properly. I updated the git repository, so it overrides the fruit nodes after all mods are loaded. Could you test if that solves your issue?
Please notice that this can cause the other mods not to work...
I just took a long look at other mods I'm using after you said that. I think it's the plantlife modpack interfering with your mod working. I just did some testing...

I downloaded the new copy from github and installed it in Minetest. I created a new world but took out plantlife and left all other mods in. Your mod started working perfectly. I found a lemon tree and apple tree and picked all fruit on both. They both started regrowing. Then I deleted that world and started another test world. I left all mods activated including plantlife. Again I found both a lemon and apple tree. Picked all fruit on both. The apples started regrowing but the lemons did not.

I'm horrible at understanding scripting, but I think this means that the plantlife modpack regrows apples but interferes with regrowth of fruit from other mods. I almost wish I could just delete the part that interferes with fruit regrowth. It may be the nature classic mod that is interfering with regrowing fruits.

---edit---

I just got done doing some more testing, and I've seen both clementines and acorns regrow for sure. Acorns seem to regrow a little slower but not sure, so I think the change you made is actually working. I'll do some more testing and post again tomorrow.

philipmi
Member
Posts: 10
Joined: Wed Apr 08, 2020 18:23

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by philipmi » Post

revevil wrote:
Sun Feb 27, 2022 01:56

I just took a long look at other mods I'm using after you said that. I think it's the plantlife modpack interfering with your mod working. I just did some testing...

I downloaded the new copy from github and installed it in Minetest. I created a new world but took out plantlife and left all other mods in. Your mod started working perfectly. I found a lemon tree and apple tree and picked all fruit on both. They both started regrowing. Then I deleted that world and started another test world. I left all mods activated including plantlife. Again I found both a lemon and apple tree. Picked all fruit on both. The apples started regrowing but the lemons did not.

I'm horrible at understanding scripting, but I think this means that the plantlife modpack regrows apples but interferes with regrowth of fruit from other mods. I almost wish I could just delete the part that interferes with fruit regrowth. It may be the nature classic mod that is interfering with regrowing fruits.

---edit---

I just got done doing some more testing, and I've seen both clementines and acorns regrow for sure. Acorns seem to regrow a little slower but not sure, so I think the change you made is actually working. I'll do some more testing and post again tomorrow.
I just tested the previous version with plantlife and it worked normally for me. So it doesn't seem to be plantlife which causes regrowth not to work, but I hope it works now anyway. I'm curious about your testing results... If it doesn't work, could you list the mods you use?

Btw, you are talking about cool_trees' fruits right?

revevil
Member
Posts: 49
Joined: Tue May 14, 2019 03:11

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by revevil » Post

philipmi wrote:
Sun Feb 27, 2022 12:40
revevil wrote:
Sun Feb 27, 2022 01:56

I just took a long look at other mods I'm using after you said that. I think it's the plantlife modpack interfering with your mod working. I just did some testing...

I downloaded the new copy from github and installed it in Minetest. I created a new world but took out plantlife and left all other mods in. Your mod started working perfectly. I found a lemon tree and apple tree and picked all fruit on both. They both started regrowing. Then I deleted that world and started another test world. I left all mods activated including plantlife. Again I found both a lemon and apple tree. Picked all fruit on both. The apples started regrowing but the lemons did not.

I'm horrible at understanding scripting, but I think this means that the plantlife modpack regrows apples but interferes with regrowth of fruit from other mods. I almost wish I could just delete the part that interferes with fruit regrowth. It may be the nature classic mod that is interfering with regrowing fruits.

---edit---

I just got done doing some more testing, and I've seen both clementines and acorns regrow for sure. Acorns seem to regrow a little slower but not sure, so I think the change you made is actually working. I'll do some more testing and post again tomorrow.
I just tested the previous version with plantlife and it worked normally for me. So it doesn't seem to be plantlife which causes regrowth not to work, but I hope it works now anyway. I'm curious about your testing results... If it doesn't work, could you list the mods you use?

Btw, you are talking about cool_trees' fruits right?
Yes I am. I just tested clementine, lemon, and plum trees, and they are all working perfect, but I'm still using the version you added to github yesterday. On a side note, I love using a grappling hook for harvesting fruit. Makes it easier. But I think later I'm going to try the previous version just to see if I was wrong. Still, I'm backing up this one anyway. Thanks for your help too!

revevil
Member
Posts: 49
Joined: Tue May 14, 2019 03:11

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by revevil » Post

Just a quick update: I archived the newer github version and deleted it, then went to the Mods section in Minetest and downloaded the old version. I was totally wrong. The mod works just fine with plantlife! I think the reason I thought it did not work is because the fruit does not tend to regrow on the bottom nodes as much as the ones above it, but it does definitely regrow. I have now planted multiple fruit trees and picked all the fruit at once just to test it, so I'm sure about this. I use the hook mod to get all the fruit, but I just wanted to suggest the plum trees to people if you want lots of fruit. Plant a few of those around your base, and you will never run out.

philipmi
Member
Posts: 10
Joined: Wed Apr 08, 2020 18:23

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by philipmi » Post

revevil wrote:
Mon Feb 28, 2022 02:37
Just a quick update: I archived the newer github version and deleted it, then went to the Mods section in Minetest and downloaded the old version. I was totally wrong. The mod works just fine with plantlife! I think the reason I thought it did not work is because the fruit does not tend to regrow on the bottom nodes as much as the ones above it, but it does definitely regrow. I have now planted multiple fruit trees and picked all the fruit at once just to test it, so I'm sure about this. I use the hook mod to get all the fruit, but I just wanted to suggest the plum trees to people if you want lots of fruit. Plant a few of those around your base, and you will never run out.
The regrowth time is actually random, so it shouldn't matter if the fruit is on the bottom nodes or above, but I'm glad to hear that it is working now.

philipmi
Member
Posts: 10
Joined: Wed Apr 08, 2020 18:23

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by philipmi » Post

Just added 1. support for moretrees apple trees (missed that when I added moretrees support) and 2. Minetest 0.4.x compatibility.

philipmi
Member
Posts: 10
Joined: Wed Apr 08, 2020 18:23

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by philipmi » Post

australia and aotearoa mods are now also supported.

Awkanimus
Member
Posts: 13
Joined: Mon Nov 28, 2022 21:31
GitHub: Awkanimus
In-game: Awkanimus

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by Awkanimus » Post

Ran into a missing nil-check when using working_villagers. According to https://minetest.gitlab.io/minetest/min ... -functions ... a nil placer is valid.

Given where the source is hosted, I don't think I can create a pull request there. I've created a patch which I've attached here. You can apply it with `git apply 0001-Add-placer-nil-check-for-register_on_place.txt`
From: Awkanimus <awkanimus@thenightstalkers.org>
Date: Sun, 4 Dec 2022 12:08:43 -0500
Subject: [PATCH] Add placer nil-check for register_on_place

---
init.lua | 2 ++--
1 file changed, 1 insertions(+), 1 deletions(-)

diff --git a/init.lua b/init.lua
--- a/init.lua
+++ b/init.lua
@@ -35,7 +35,7 @@ local add_fruit_regrowable = function(fruit, node, leaves)
})

minetest.register_on_placenode(function(pos, newnode, placer)
- if placer:is_player() and newnode.name == "cacaotree:pod" then
+ if placer and placer:is_player() and newnode.name == "cacaotree:pod" then
minetest.set_node(pos, {name = "regrowing_fruits:cacao", param2 = newnode.param2})
end
end)
--
2.25.1

philipmi
Member
Posts: 10
Joined: Wed Apr 08, 2020 18:23

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by philipmi » Post

@Awkanimus

Thank you for reporting the issue, I've updated the mod...

mcaygerhard
Member
Posts: 129
Joined: Tue Mar 05, 2019 17:37
GitHub: mckaygerhard
IRC: mckaygerhard
In-game: mckaygerhard

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by mcaygerhard » Post

philipmi wrote:
Sat Jun 27, 2020 20:03
Default apples in older versions than Minetest 5.0 will also regrow.

Credits
This mod is inspired by "endless_apples" by Shara RedCat (2018).

License
Code for this mod is released under MIT (https://opensource.org/licenses/MIT).

Source: https://git.sp-codes.de/philipmi/regrowing_fruits.git

If you got ideas or found bugs, please let me know below!
hi @philipmi i try to find original base fo both code .. seems your code is more ancient rather the tenplus1 .. so i will cite you taking into consideration the MIT license

also i want to provide you a more proper REAME (cos that you used has several missing information) due you use a crapo git service (people are unnable to send merge request i provide only for tenplus flavour.. https://notabug.org/minenux/minetest-mo ... ter-readme

if you are interested on improvement (cos i tested your mod) we need a place where we can fork and send code.. sending a patch here is so tedious and promotes unorganization

philipmi
Member
Posts: 10
Joined: Wed Apr 08, 2020 18:23

Re: [Mod] Regrowing Fruits [regrowing_fruits]

by philipmi » Post

mcaygerhard wrote:
Mon Jan 02, 2023 01:38
hi @philipmi i try to find original base fo both code .. seems your code is more ancient rather the tenplus1 .. so i will cite you taking into consideration the MIT license

also i want to provide you a more proper REAME (cos that you used has several missing information) due you use a crapo git service (people are unnable to send merge request i provide only for tenplus flavour.. https://notabug.org/minenux/minetest-mo ... ter-readme

if you are interested on improvement (cos i tested your mod) we need a place where we can fork and send code.. sending a patch here is so tedious and promotes unorganization

Hello @mcaygerhard, I had the idea for this mod when I saw viewtopic.php?t=20060. Its basically how apples regrow in mtg...

You can create an account at https://git.sp-codes.de/ and open a PR, but you can also fork it on any other git instance (github, gitlab or others) and send me the link to your repo so I am able to merge it.

Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests