[mod] Tree Cutter [woodcutting]

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

[mod] Tree Cutter [woodcutting]

by bell07 » Wed Jul 05, 2017 21:38

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
(447.14 KiB) Not downloaded yet
Last edited by bell07 on Thu Aug 31, 2017 18:36, edited 4 times in total.
 

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

Re: [mod] Tree Cutter [woodcutting]

by Nathan.S » Wed Jul 05, 2017 21:46

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: 1274
Joined: Wed Aug 19, 2015 19:11
Location: Oklahoma City
GitHub: duane-r

Re: [mod] Tree Cutter [woodcutting]

by duane » Thu Jul 06, 2017 10:15

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
(251.45 KiB) Not downloaded yet
t04.jpg
(369.26 KiB) Not downloaded yet
t03.jpg
(340.56 KiB) Not downloaded yet
Believe in people and you don't need to believe anything else.
 

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

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Thu Jul 06, 2017 12:03

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: 7459
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO
 

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

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Thu Jul 06, 2017 17:08

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: 534
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Thu Jul 06, 2017 23:56

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: 534
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Fri Jul 07, 2017 17:24

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
 

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

Re: [mod] Tree Cutter [woodcutting]

by Nathan.S » Sun Jul 09, 2017 21:42

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: 534
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Mon Jul 10, 2017 04:12

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: 31
Joined: Tue Jul 11, 2017 08:57

Re: [mod] Tree Cutter [woodcutting]

by Drgnrdr » Mon Jul 24, 2017 08:44

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: 534
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Mon Jul 24, 2017 11:37

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: 534
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07
 

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

Re: [mod] Tree Cutter [woodcutting]

by TumeniNodes » Tue Aug 15, 2017 23:22

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
I'm not your buddy, guy...
 

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

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Wed Aug 16, 2017 04:56

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: 534
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [mod] Tree Cutter [woodcutting]

by bell07 » Thu Aug 31, 2017 18:36

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
Location: On Minetest 24/7
GitHub: John-Constructor
In-game: Nooberton

Re: [mod] Tree Cutter [woodcutting]

by John_Constructor » Sat Sep 02, 2017 16:02

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.
 


Return to Mod Releases



Who is online

Users browsing this forum: runs and 5 guests