[mod] Tree Cutter [woodcutting]

Post Reply
bell07
Member
Posts: 604
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

[mod] Tree Cutter [woodcutting]

by bell07 » Post

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
Attachments
screenshot_20170707_190137.png
screenshot_20170707_190137.png (447.14 KiB) Viewed 1970 times
Last edited by bell07 on Thu Aug 31, 2017 18:36, edited 4 times in total.

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: [mod] Tree Cutter [woodcutting]

by Nathan.S » Post

This is a great idea, will definitely check it out.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
duane
Member
Posts: 1715
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r
Location: Oklahoma City
Contact:

Re: [mod] Tree Cutter [woodcutting]

by duane » Post

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.
Attachments
t01.jpg
t01.jpg (251.45 KiB) Viewed 1970 times
t04.jpg
t04.jpg (369.26 KiB) Viewed 1970 times
t03.jpg
t03.jpg (340.56 KiB) Viewed 1970 times
Believe in people and you don't need to believe anything else.

bell07
Member
Posts: 604
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Post

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

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [mod] Tree Cutter [woodcutting]

by azekill_DIABLO » Post

wooo, duane what have you done?
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

bell07
Member
Posts: 604
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Post

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

bell07
Member
Posts: 604
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Post

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?

bell07
Member
Posts: 604
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Post

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-wood ... amples.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

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: [mod] Tree Cutter [woodcutting]

by Nathan.S » Post

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
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

bell07
Member
Posts: 604
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Post

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.

Drgnrdr
Member
Posts: 34
Joined: Tue Jul 11, 2017 08:57

Re: [mod] Tree Cutter [woodcutting]

by Drgnrdr » Post

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.

bell07
Member
Posts: 604
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Post

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)

bell07
Member
Posts: 604
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Post

For reference: a similar mod to collect ores: orecutting

User avatar
TumeniNodes
Member
Posts: 2941
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: [mod] Tree Cutter [woodcutting]

by TumeniNodes » Post

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
A Wonderful World

bell07
Member
Posts: 604
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Post

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.

bell07
Member
Posts: 604
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Post

The woodcutting is now a part of the minetest-mods family!!!
Github link adjusted to https://github.com/minetest-mods/woodcutting in first post

John_Constructor
Member
Posts: 76
Joined: Thu Jun 01, 2017 20:06
GitHub: John-Constructor
In-game: Nooberton
Location: On Minetest 24/7

Re: [mod] Tree Cutter [woodcutting]

by John_Constructor » Post

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.
Constructing mechs and wingless aircraft since 2016.

TommyTreasure
Member
Posts: 44
Joined: Tue Nov 15, 2016 01:37
IRC: TommyTreasure
In-game: TommyTreasure

Re: [mod] Tree Cutter [woodcutting]

by TommyTreasure » Post

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)

ThorfinnS
Member
Posts: 311
Joined: Mon Feb 25, 2019 22:05
GitHub: ThorfinnS

Re: [mod] Tree Cutter [woodcutting]

by ThorfinnS » Post

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.

TommyTreasure
Member
Posts: 44
Joined: Tue Nov 15, 2016 01:37
IRC: TommyTreasure
In-game: TommyTreasure

Re: [mod] Tree Cutter [woodcutting]

by TommyTreasure » Post

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.

TommyTreasure
Member
Posts: 44
Joined: Tue Nov 15, 2016 01:37
IRC: TommyTreasure
In-game: TommyTreasure

Re: [mod] Tree Cutter [woodcutting]

by TommyTreasure » Post

I should have made this suggestion a year ago. Changing the activation key from 'sneak' to 'aux1', allows for players to use the shift/ladder trick to climb trees, without cutting down the tree.

Only requires the change in 2 lines. One for the activation key (line 321), and one for the description text (line 272).

Drawbacks: Mobile app players may not be able to use the aux1 key.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 31 guests