Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

Tree Science: definitive guide up-to-date for 1.2_02


  • Please log in to reply
52 replies to this topic

#1

Marglyph
    Marglyph

    Redstone Miner

  • Members
  • 535 posts

Posted 23 January 2011 - 01:52 AM

Hello again. I've been poring through more decompiled source code and running tests, and have prepared a definitive guide to tree growth and leaf decay.

Growth rate

Trees in single player have a chance to grow if they are within a 19x19 chunk area (304x304 blocks) centered on the player. Their growth function is called at intervals that appear somewhat random. In tests, I was getting a long-term average of slightly less than 3 calls per minute per sapling.

When the growth function is called, it first checks the light level 1 block above the sapling, which must be 9 or more. Trees are no more likely to grow in daylight than in torchlight. Trees that are artificially lit should therefore grow twice as fast as unlit outdoor trees, which only have a chance to grow during daytime.

If there is sufficient light, there is only a 1/5 chance of continuing (in effect turning 3 calls per minute into 0.6 calls per minute).

The function then increments the counter on each sapling, which starts at 0 and must reach 15. If it has reached 15, the tree-spawning function is called. If I'm doing my math right, it should be "about" 27 real minutes on average from planting to when the tree gets its first chance to spawn.

The tree-spawn function attempts to place a tree at the sapling's location. There is a 1/10 chance of using the big-tree algorithm, and a 9/10 chance of using the small-tree algorithm. Pine and birch trees are entirely separate and have their own algorithms, which are only called by world/biome creation.

If the attempt to spawn fails, the sapling's counter is reset to 0 and life goes on (for another ~27 minutes).

Finally, trees never grow additional logs or leaves after they spawn.

Small trees vs. big trees

Height and logs: Small trees require 6-8 blocks of vertical space; the trunk itself will be 2 less than this (so 4-6 logs per tree). Big trees require 6-16 blocks of vertical space, and have an additional 1/11 chance of failing to spawn because they can roll 5 height but are then canceled. Their trunk can branch out, but I think the top will often be 2 blocks lower than the clearance as well. I have seen big trees with up to 64 blocks of wood, but they can have as little as 4 and mostly seem to be in the 20s.

Horizontal clearance: Small trees require no empty (air or leaf) spaces around the sapling (so you can have a block next to it or dig it into the ground), 2 empty spaces around the top of the trunk to the top of the vertical clearance, and 1 empty space around the rest of the trunk. Only air and leaves count as empty; signs, glass, etc., do not (but see below for more on that). Note: this clearance is square, so "2" clearance means a 5x5 square around the trunk at that level must be empty. Big trees do not require any horizontal clearance at all.

Ground: Both types of trees only grow on grass or dirt. But small trees will replace grass with dirt and big ones won't.

Leaves: On small trees, leaves spawn starting from the third log down from the top, up to a single leaf block above the trunk. Big trees spawn branches and leaves all over the place.

Leaf spawning, partial blocks, and redstone

Trees behave oddly when it comes to signs, pressure plates, redstone wires, and other similar blocks that occupy a block partially. If such a block is within the clearance needed around the trunk for small trees, it will stop the tree from growing. If, however, it is outside the clearance but is in a block where leaves grow, the leaves will replace (delete) it.

This can be used to affect redstone circuits. For example (side view):

[]  []  []  :Notch:  []
[]  []  []  []  []
[]  []  []  []  []
[]  []  []  []  []
[]  []  []  []  []
[]  :Red:  []  []  []
:Red:  :VV:  :Red:  :VV:  :--+:

Where  :Red: = redstone wire and  :VV: = sapling

The ceiling height here is 6 to force a small tree of trunk height 4, which will have leaves 1 block off the ground. When the tree grows, it will delete the redstone that is on top of the stone, breaking the circuit. This can be used for very long timers (unfortunately, the exact time is random).

Bone meal

Bone meal bypasses the counter mechanism and the light-level condition, and gives the tree a chance to spawn immediately. It uses the exact same spawn function as natural growth does, so the tree must still be able to fit in its surroundings, and has the same big-tree/small-tree probability. This means that the number of bonemeal uses it takes to grow a tree in given surroundings is proportional to the time it will take to grow naturally (though both have random factors involved).

The fact that bone meal does not require light to grow trees ought to be exploitable, but I don't see how -- you're going to want light to see where to click with the bone meal.

Empirical test of indoor tree farming

Using MCEdit, I created two 32x32 tree farms with solid walls and ceilings (height 8), one with trees in a grid with 2 spaces in all directions (total 100 saplings) and one using a checkerboard pattern (total 512 saplings).

I inserted logging functions into the code to track the actual number of log blocks created over time in each farm, and sped growth up dramatically by making the counter go to 3 instead of 15 and increasing the 1/5 chance to 1/3. These changes should evenly apply to all farm/tree types and just made the test take less time. I did not harvest any trees, because I couldn't figure out a way to do that in a controlled way while collecting data.

The 2-spaced tree farm soon looked better, as all the saplings sprouted, whereas only 2/5 of saplings in the checkerboard sprouted. The checkerboard produced 2x as much wood during my test period, before growth slowed as many of the remaining saplings were unable to spawn.

Effectively, you're planting 5x the saplings for a 2x increase in total logs produced in a "reasonable" growing time.

I then tested the 2-spaced grid against a 1-spaced grid (256 saplings). The 1-spaced grid, although it had 2.5x as many saplings, only grew slightly more trees (and logs) than the 2-spaced grid.

Therefore, my initial conclusion is in favor of the 2-spaced grid, since the checkerboard approach requires so much more planting. Trees spaced 2 apart are also easier to cut down. 1-spaced grids are not really useful.

I don't think attempting to spawn only big trees can be efficient. Although they can produce a lot of wood, they don't produce 10x as much on average as small trees.

Leaf Decay

A leaf block will eventually decay unless there is a "path" leading through other leaf blocks, no more than 4 blocks long (no diagonals), to a log.

In other words, a single log can support leaves in an octahedral pattern, with this cross-section from the top and from the side:

[]  []  []  []  :VV:  []  []  []  []
[]  []  []  :Leaves:  :Leaves:  :Leaves:  []  []  []
[]  []  :Leaves:  :Leaves:  :Leaves:  :Leaves:  :Leaves:  []  []
[]  :Leaves:  :Leaves:  :Leaves:  :Leaves:  :Leaves:  :Leaves:  :Leaves:  []
:Leaves:  :Leaves:  :Leaves:  :Leaves:  :log:  :Leaves:  :Leaves:  :Leaves:  :Leaves:
[]  :Leaves:  :Leaves:  :Leaves:  :Leaves:  :Leaves:  :Leaves:  :Leaves:  []
[]  []  :Leaves:  :Leaves:  :Leaves:  :Leaves:  :Leaves:  []  []
[]  []  []  :Leaves:  :Leaves:  :Leaves:  []  []  []
[]  []  []  []  :Leaves:  []  []  []  []

Isolated leaves/small groups of leaves will decay quickly, while large amounts of leaves connected to each other will decay slowly.

There is no distinction between "original" logs and logs that you place, or between different colors of logs. However, it appears that if you place a log while leaf decay is already taking place, it might or might not prevent decay.

When a leaf block decays or is destroyed, it has a 1/16 chance of dropping a sapling.

Trees destroyed with TNT can drop logs and saplings. TNT destroys 7/10 of all item drops from destroyed blocks.

Biomes

The following are the probabilities of different types of trees appearing in different biomes. Note that some biomes simply generate more or fewer trees than others; the below is just the probability, given that a tree is being placed, of it being each available type of tree.

Rainforest: 33% big, 67% small
Forest: 20% birch, 27% big, 53% small
Taiga: 33% pine with round top, 67% pine with conical shape
Others: 10% big, 90% small

Questions?

Register or log in to remove.

#2

MoreOne
    MoreOne

    Coal Miner

  • Members
  • 125 posts

Posted 23 January 2011 - 02:19 AM

Can trees grow in less than 27 minutes, without bonemeal? Because the trees I plant seen to grow so much faster than that...

#3

Marglyph
    Marglyph

    Redstone Miner

  • Members
  • 535 posts

Posted 23 January 2011 - 02:25 AM

Yep, there's a lot of randomness involved. That's an estimated average, and might be off a bit.

#4

Treborn
    Treborn

    Zombie Killer

  • Members
  • 223 posts
  • Minecraft: XxTrebornxX

Posted 23 January 2011 - 02:34 AM

I'm very impressed, nice work.

#5

Gremlinator

Posted 23 January 2011 - 10:16 AM

Impressive, well done.
However, I have a question. Is it possible to grow birch trees and  redwood/pine trees from saplings?
I've never had any such luck, only ever getting standard trees, even when using saplings harvested from
the new trees.

Posted Image


#6

Aar0n
    Aar0n

    Carpenter

  • Members
  • 61 posts

Posted 23 January 2011 - 10:33 AM

Wow, it helps a lot. Well done.

#7

Castaway
    Castaway

    Forum/Wiki Sponsor

  • Members
  • 484 posts

Posted 23 January 2011 - 11:02 AM

This is awesome. Thanks for making some questions clear
Posted Image

#8

tomtiddly

Posted 23 January 2011 - 11:57 AM

Excellent thanks for this :D

Just confirms I need to increase the size of my tree farm!

#9

Blitzgrutel

Posted 23 January 2011 - 12:06 PM

Bookmarked! I was searching something like that to help me with some leaves constructions.
Posted Image

#10

niels
    niels

    Glowstone Miner

  • Members
  • 3862 posts
  • Location: I am not at places you think i can be
  • Minecraft: niels

Posted 23 January 2011 - 12:11 PM

looks like somebody had too much free time
good work
Me on twitter :D

#11

SpaceGhostCTC

Posted 23 January 2011 - 12:29 PM

Very interesting stuff.
I thought it said troll science at first :D
Life is ruff.

#12

TheNosferatu
  • Minecraft: TheNosferatu

Posted 23 January 2011 - 12:56 PM

Thanks for thr guide, great work!

If i understand it correctly, placing blocks in the spacing, but not directly above the sapling at 4 - 6 high will (eventually) force a super tree
God created the Earth. Except Holland, we took that from the sea ourselves.

#13

Marglyph
    Marglyph

    Redstone Miner

  • Members
  • 535 posts

Posted 23 January 2011 - 07:12 PM

Gremlinator said:

Impressive, well done. However, I have a question. Is it possible to grow birch trees and  redwood/pine trees from saplings?

No, because they use entirely separate code. I started working on a mod for varietal saplings, but it's harder than it seems at first. The data value that other objects use for varieties, like logs, wool, etc., is used in saplings for a growth timer. I know it's possible somehow, Would be easier with non-obfuscated code! (Saplings growing random tree types would be easy, but I want them to propagate correctly.)

niels said:

looks like somebody had too much free time good work

(Looks around forum.) Yes, but did you mean somebody in particular?  :SSSS:

TheNosferatu said:

Thanks for thr guide, great work! If i understand it correctly, placing blocks in the spacing, but not directly above the sapling at 4 - 6 high will (eventually) force a super tree

Yep, all it takes to force the big tree algorithm, or, rather disallow the small tree algorithm, is a pillar two blocks high next to the sapling. Or any other block within the clearance area.

#14

honk
    honk

    Carpenter

  • Members
  • 49 posts

Posted 23 January 2011 - 07:42 PM

Marglyph said:

Horizontal clearance: Small trees require no empty (air or leaf) spaces around the sapling (so you can have a block next to it or dig it into the ground), 2 empty spaces around the top of the trunk to the top of the vertical clearance, and 1 empty space around the rest of the trunk. Only air and leaves count as empty; signs, glass, etc., do not (but see below for more on that).

Questions?
Yes.

My tree-farm has trees growing directly next to each other. This doesn't fit your description. It's a simple small tree farm with rows of trees for easy collection. :Pig: The growth looks somewhat like this:
Posted Image

#15

Marglyph
    Marglyph

    Redstone Miner

  • Members
  • 535 posts

Posted 23 January 2011 - 08:04 PM

honk, small tree and big tree refer to tree types/algorithms, not literally to the size. Trees generated with the "large tree" algorithm can have trunks as short as 4 blocks (total height 6). Also, the first trees to grow in a close-packed environment will not have other trees obstructing them yet.

#16

honk
    honk

    Carpenter

  • Members
  • 49 posts

Posted 23 January 2011 - 08:15 PM

Marglyph said:

honk, small tree and big tree refer to tree types/algorithms, not literally to the size. Trees generated with the "large tree" algorithm can have trunks as short as 4 blocks (total height 6). Also, the first trees to grow in a close-packed environment will not have other trees obstructing them yet.

Uh, I see. I missed that large trees start at height 6 as well. With that it makes perfect sense. :SSSS:

Thanks.

#17

Willy_Galleta

Posted 23 January 2011 - 09:40 PM

Is it true that breaking leaves has the same chance of dropping a sapling than decaying leaves?

Thanks for all the info. Much appreciated.
Spanish webcomic artist! 8D
Steel Jaws in English. ;)

#18

Gremlinator

Posted 23 January 2011 - 09:46 PM

Gremlinator said:

Impressive, well done.
However, I have a question. Is it possible to grow birch trees and  redwood/pine trees from saplings?
I've never had any such luck, only ever getting standard trees, even when using saplings harvested from
the new trees.

I'm gonna throw this out here again, b/c it's an interesting and unanswered point.

Posted Image


#19

Amphouse

Posted 23 January 2011 - 09:52 PM

Nice. I like to see updated threads.

Ultra-Orange said:

Direwolf20 said:

#37) Ores tend to spawn in packs
If you take one out you better be ready to take on its angry cousins!

Took out an over head coal node once and was snuffed by a gang of Gravel seeking revenge!
Posted ImagePosted ImagePosted Image
Posted Image

#20

honk
    honk

    Carpenter

  • Members
  • 49 posts

Posted 23 January 2011 - 10:07 PM

Gremlinator said:

Gremlinator said:

Impressive, well done.
However, I have a question. Is it possible to grow birch trees and  redwood/pine trees from saplings?
I've never had any such luck, only ever getting standard trees, even when using saplings harvested from
the new trees.

I'm gonna throw this out here again, b/c it's an interesting and unanswered point.

That was answered in the original post:

Marglyph said:

Pine and birch trees are entirely separate and have their own algorithms, which are only called by world/biome creation.