Hi, I'd like to post an "upgraded" version of this script.
I know this is an old post, but Google still offers this as a search result, so lemme explain:
- this code is great as a base template, but has many issues
- it can easily break whole houses if you have the tree accidentaly touching it (house is within a 3 block radius, which can happen)
- I found the checks pretty much not very reliable and inefficient
- I added condition checks that should prevent breaking huge parts of houses (I tested it and it only had issues with jungle trees right next to the house which will not even grow like that in normal game, I had to use WE)
I know I am looping "blocks above" 2 times, but it was necesarry for the code to not have issues with acacia trees
So here's my "upgrade" on the latest version of Skript up to this date for those who are still curious:
(note- I'm using some addons but none should interfere in this code, so it should be vanilla)
Code:
function chain(b: block, n: integer):
wait 1 tick
if {_n} is less than 50:
add 1 to {_n}
loop blocks in radius 3 around {_b}:
if loop-block is any log:
loop blocks above loop-block:
loop-block-2 is air:
block above loop-block-2 is air
exit 1 loop
exit 1 loop
loop blocks above loop-block:
loop-block-2 is any leaves
chain(loop-block-1, {_n})
break loop-block-1
wait 10 tick
on break:
player's gamemode is survival
if event-block is any log:
loop blocks above event-block:
set {_l} to 0
if loop-block is any leaves:
loop all blocks in radius 2 of loop-block:
loop-block-2 is any leaves
add 1 to {_l}
{_l} > 7
set {_tree} to true
if {_tree} is true:
chain(event-block, 0)
Hope this will come in handy to people in 2023+