Page 1 of 1

[mod] Tree Cutter [woodcutting]

PostPosted: Wed Jul 05, 2017 21:38
by bell07
I know there are already some tree-cutter mods, but I decided to write my own from scratch that does match my needs.

Woodcutting

Mine the first tree node from a tree while the sneak key is pressed, then wait till the whole tree is breaked down and in your inventory. The process can be stopped by pressing sneak key again. This is useful in jungle because no tree shape determination is implemented so all touching tree nodes are a single tree (could be half of the jungle :-().

Image
Highlights / Features

  • Lag-free because the work is not done at once. You can observe the woodcutting.
  • You can stop the woodcutting by press sneak key second time
  • You can add additional trees to process by digging other tree nodes manually
  • The distance to the player is used to prefer next node so the player can partially influence the work direction on big areas
  • The auto-mining speed is dependent on wielded tool, so the diamond axe is still advantageously than empty hand
  • All checks and functionalities are processed (like hunger damage and tool wear) as if the player did the mining manually
  • Really nice effect in combination with item_drop mod
  • Does work with all trees in Item group "tree" and "leafdecay" leaves and fruits
  • Simple HUD message about woodcutting process status if active
  • For developers - an enhancement API (See README.md on github)

License: LGPL-3
Dependencies: None
Code/Download: https://github.com/minetest-mods/woodcutting
Recipes: none
Mod review video by Nathan.S: http://nathansalapat.com/minetest/woodcutting

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Wed Jul 05, 2017 21:46
by Nathan.S
This is a great idea, will definitely check it out.

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Thu Jul 06, 2017 10:15
by duane
This is already one of my favorite mods. However, I recommend adding options for a few sanity checks.

(1) An option to stop cutting after the player's axe wears out. You might let it keep cutting for a while, just to avoid uncut treetops, but it should stop eventually, otherwise someone could conceivably defoliate an entire region with a wooden axe.

(2) An option to stop cutting when the player's inventory fills up. Once you're full, all the cut nodes drop individually, making a terrible mess and taking forever to clean up if you just forgot to hit sneak again.

(3) An option to stop cutting after a large number of nodes or after so many nodes are cut in a period of time.

I thought of these while testing woodcutting on a giant tree.

Image

At about the above point, my wooden axe disintegrated and my inventory was full. Nodes started raining down on me, along with the occasional angry treeman. (My game gives you a tiny chance of summoning one when you cut any wood.)

Image

Still humming along. My log is filling with digging messages and deleting too many nodes messages. As you can see below, it chops down the roots for quite a way. It can't get the whole tree because the top and bottom haven't even been built by the mapgen yet.

Image

I may have to move a bit, but I think it's going to get most of the tree.

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Thu Jul 06, 2017 12:03
by bell07
Thanks for the feedback.
I noticed the disabling by sneak key works only if the key is pressed during a node is digged. So I added a hud message as "Woodcutting active. Hold sneak key to disable it" as indicator for active process.

duane wrote:An option to stop cutting after the player's axe wears out
I like the option to swich the axe during the cutting process is working, because of hunger damage I like to eat apples to not to starve. :-/

Feel free to create PR's for restrictions as you need it: optional. I like the way the player decides if the cutting process is done. I added one restriction: Stop the work if the player dies

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Thu Jul 06, 2017 12:11
by azekill_DIABLO
wooo, duane what have you done?

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Thu Jul 06, 2017 17:08
by bell07
Ok, second restriction: Maximum distance to the player is set to 100 so the woodcutting is stopped if you run away.

Site-note: I plan to rewrite the core functionality next days to reusable class so different tools could use it with different parameters

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Thu Jul 06, 2017 23:56
by bell07
As usual I did a rewrite after the first version was working ;-) Now with new bugs and features in objects style.
Some hooks are implemented to be able to customize the mod for subgames

Code: Select all
woodcutting.settings = {
   tree_distance = 1,   -- Apply tree nodes with this distance to the queue. 1 means touching tree nodes only
   leaves_distance = 2, -- do not touch leaves around the not removed trees with this distance
   player_distance = 80, -- Allow cutting tree nodes with this maximum distance away from player
   on_new_process_hook = function(process) return true end, -- do not start the process if set to nil or return false
   on_step_hook = function(process) return true end,        -- if false is returned finish the process
   on_before_dig_hook = function(process, pos) return true end, -- if false is returned the node is not digged
   on_after_dig_hook = function(process, pos, oldnode) return true end, -- if false is returned do nothing after digging node
}

Please note: in on_new_process_hook(process) it is possible to redefine the woodcutting process methods like
Code: Select all
process:get_delay_time(pos)
process:check_processing_allowed(pos)
process:select_next_tree_node()
process:show_hud(pos)
and other process methods

Anything missed before release?

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Fri Jul 07, 2017 17:24
by bell07
First post updated, screenshot added. On github README.md is now a full API documentation for possible enhancements

EDIT: Added hook examples https://github.com/bell07/minetest-woodcutting/blob/master/hook_examples.lua
- Change the hud message trough method redefinition in on_new_process_hook
- Count the cutted tree nodes and stop after 99 in on_after_dig_hook

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Sun Jul 09, 2017 21:42
by Nathan.S
After actually using this mod I can say for certain that it is really well done. I'm so glad that I won't have to have tree tops dotting the landscape that I can't reach any more.
In fact I liked this mod so much that I went ahead and recorded a video for it. http://nathansalapat.com/minetest/woodcutting

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Mon Jul 10, 2017 04:12
by bell07
Many thanks for your review! It is an honor for me to be on your review list.
For your question: The counter in the HUD message is the current todo-list size. The mod does not capture the whole tree/region for cutting at once but checks for related neighbors nodes each digged node. So in case of pine wood it is mostly 1 per tree if only the nodes above are not cutted, or it is 2 if node above and under the digged is still in the world. The counter becomes interesting in jungle region because of many connected trees and tree nodes with more then 2 neighbors.

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Mon Jul 24, 2017 08:44
by Drgnrdr
I like this mod very well done. One setting I would like is to ignore collecting of leaves. After a while you have leaves scattered all over the landscape. So a setting to stop leaf collecting would be ideal.

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Mon Jul 24, 2017 11:37
by bell07
One of my intentions was to collect leaves for compost and homedecor's oil and plastic ;-)

But now I added the requested setting defaulted to true:
minetest.conf:
Code: Select all
# If enabled the woodcutting dig not connected leaves
# after tree nodes removed
woodcutting_dig_leaves (Dig leaves) bool true

For developers: accessible from other mods:
Code: Select all
woodcutting.settings.dig_leaves = true
or dynamic/per process:
Code: Select all
process.dig_leaves = true
(README with Hooks/API updated also)

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Tue Aug 15, 2017 20:49
by bell07
For reference: a similar mod to collect ores: orecutting

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Tue Aug 15, 2017 23:22
by TumeniNodes
This is great! Now I can cut down all the jungles... I hates them :D
Could you do a mod which spreads a disease to all jungle trees next? (j/k).... kinda

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Wed Aug 16, 2017 04:56
by bell07
TumeniNodes wrote:Could you do a mod which spreads a disease to all jungle trees next? (j/k).... kinda
Such a mod exists already, it is called "fire" ;-)
If you like to do it with woodcutting, just change the setting
Code: Select all
   tree_distance = 1,    -- Apply tree nodes with this distance to the queue. 1 means touching tree nodes only
to a higher value (to 2 or 3?) in the line 4 in init.lua.

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Thu Aug 31, 2017 18:36
by bell07
The woodcutting is now a part of the minetest-mods family!!!
Github link adjusted to https://github.com/minetest-mods/woodcutting in first post

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Sat Sep 02, 2017 16:02
by John_Constructor
Great mod! Tested it out on my Testing Survival (Not very creative name, I know.) world and came to find that it's decently fast with a steel axe.

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Thu Oct 17, 2019 00:22
by TommyTreasure
I had just upgraded both woodcutting and hbhunger on the same day. Here's what I posted in the hbhunger forum. Sorry for crossposting, but it seems as either of these mods, or the combination of them is the cause.

In the short time after that post and this one, I have isolated that cutting 1 redwood tree triggers it. Clean start of minetest 5.0.1 client, fresh join, cut one tree with no other actions prior, and the lag starts. Client side only.

And here's another issue. Client side lag -- massive. I haven't been able to track the action that triggers it, but in most cases, it seems related to either hbhunger and woodcutting. Both mods were updated on the same day, and the lag issue with the next player to join after restarting the server.

Server 5.0.1 via ppa.
Clients 5.0.1 (most of my players run the Windows 64 version)

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Thu Oct 17, 2019 19:23
by ThorfinnS
Redwood?

We have no problems, but don't have the mod (moretrees?) installed that gives redwood. As I recall, one of the tree mods gave us massive lag, and I don't think we ever isolated what the problem was.

Re: [mod] Tree Cutter [woodcutting]

PostPosted: Fri Oct 18, 2019 12:43
by TommyTreasure
For what its worth, redwood trees are in the ethereal mod. :)

I had also said that it was a 'client side lag issue'. Server status max_lag was always less than 0.6. But the client could not open doors, chests, move, or even chat, without a 2 to 5 minute delay. When this happened, only the player that cut a tree experienced that lag problem. Clearly not a server issue, except for the possibility of conflicts with other mods.

However, further tests seem to be pointing to the hbhunger mod. Both woodcutting and hbhunger were updated on the same day. Disabling woodcutting did not stop the issue, but reverting to my older version of hbhunger seemed to bring things back to normal.