Jump to content

Program Trees as Entities Instead of Block Structures


Eleghrin

Recommended Posts

I've been reading through the JSON files to get a better idea of how the game handles blocks, items, and entities, and I feel like trees would feel more organic in game if they were programed as entities instead of being generated as blocks.

I know this would be a pretty significant change to how they function currently, and that entities have a greater impact on performance than blocks, but let me go over some of the thoughts I had on this.

The tree lifecycle, as an entity, would go something like this:

-The existing sapling, which is coded as a plant block, would be planted as usual.

-At the end of the sapling growth time, the sapling would be replaced by a 'young-tree' entity. This entity would only really need the 'growth' code and the 'death' code. "Killing" a young tree with a tool would, like existing entities, create a "corpse," which could be harvested with the existing corpse harvesting mechanics for a chance at sticks and saplings.

-At the end of the young tree growth cycle, depending on how in depth you wanted to go, the young tree could grow into either an 'adolescent-tree' or a 'full-grown-tree.' At this stage killing the tree and harvesting would yield the existing wood log blocks and a chance at sticks, saplings, and leaves.

-If you wanted to go even farther, rather than wood blocks a dead tree would provide you with a tree trunk, which would be crafted into wood blocks in your inventory with an axe or a saw. Using a saw would provide more blocks. Following this path would also pave the way for automated lumber processing with machines, allowing players to build wind powered tree saws to cut trunks for the best yield of blocks (or planks, if you really wanted to be more realistic).

As far as worldgen is concerned, trees would spawn in various stages of growth in groups at world start and as chunks are loaded. Spawning like other entities could also allow for small chances for young trees to spawn on their own while the game is running.

Technical description aside, treating trees as entities has upsides and downsides:

Pros:

-You get a more immersive tree-felling experience, with the tree falling over and requiring further processing with a tool.

-Tree growth would look more aesthetically pleasing, with observable growth phases over time.

-The tree can be animated as a whole. Behaviors can be added when there is wind to allow younger trees to bend and sway, and leaves and branches can move in unison.

-Opens an avenue for a mechanical logging mechanic, wherein a tree might drop a full trunk that could be sawed at a lumber mill.

-Opens an avenue towards natural propagation, wherein new creatures like squirrels could interact with trees and generate saplings when they forget where they buried their nuts.

-No further need for treegen code.

Cons:

-Entities have more complex code, increasing performance strain. Would run the risk of forests becoming performance bombs. Could be mitigated by behavior code only running in player proximity or by minimizing/reducing animation and behavior options for trees.

-Would require new code for entities to allow for tool requirements when causing damage (ex. trees would only be harmed by axes and saws). However, this could be beneficial if considered in terms of armor, as it could pave the way for tool/weapon/element specific resistances.

-Would require a new solution for seasonal appearances of entities, undoing some of the fantastic shading work already done by the developers.

-Would require a new solution for blocks which spawn on block trees like resin and bee hives

 

In summary, while converting trees from block formations to entities sounds like a huge change, most the assets required to make this change already exist. Treating trees as entities instead of block structures improves the growing and harvesting aesthetics and opens avenues for further game mechanic development, and though there is great risk of straining performance further with additional entity code running in the background I think there are plenty of opportunities to mitigate this strain with careful coding consideration.

 

Thanks for reading!

Link to comment
Share on other sites

  • 9 months later...

I like the idea in principle, but this has been discussed before and the issue is one of performance.

You are talking multiple hundreds of trees (potentially) in every single loaded chunk on a server that has growth/entity/behavior mechanics (if trees "behave" differently by growth stage in wind and various weather conditions), that the game would have to keep up with.  To my understanding, it would take quite a machine to be able to process all of that and not kill performance.  If they could find a way to make handling such things much simpler so as not to be a heavy load on a standard pc, I'd be all for it.

As I recall, there has been discussion about trees as block entities "growing" over time, as if the tree would generate/spawn into maturity one stage at a time, but even that had performance concerns and was not feesable.  Wish I could recall where I saw that discussion, but it was several years ago at least, and is buried somewhere deep in the forums.

Link to comment
Share on other sites

On 10/5/2020 at 3:25 AM, Eleghrin said:

Would run the risk of forests becoming performance bombs.

They already are. I had to turn off "waving foliage" and change some other stuff to counter that at least a little bit, but I still better stay away from bigger forests. Making them even worse could kill the game.

Link to comment
Share on other sites

I would loves to see trees like in dynamic tress mod for minecraft. These works very well on my slow computer :): VS take many ideas form minecraft mods, these is one of the better. It's not in video but falling tress can fall on you and kill you ;).

 

  • Like 3
Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.