Content: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Background: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Pattern: Blank Waves Notes Sharp Wood Rockface Leather Honey Vertical Triangles
Welcome to TerraFirmaCraft Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

  • Announcements

    • Dries007

      ATTENTION Forum Database Breach   03/04/2019

      There has been a breach of our database. Please make sure you change your password (use a password manager, like Lastpass).
      If you used this password anywhere else, change that too! The passwords themselves are stored hashed, but may old accounts still had old, insecure (by today's standards) hashes from back when they where created. This means they can be "cracked" more easily. Other leaked information includes: email, IP, account name.
      I'm trying my best to find out more and keep everyone up to date. Discord (http://invite.gg/TerraFirmaCraft) is the best option for up to date news and questions. I'm sorry for this, but the damage has been done. All I can do is try to make sure it doesn't happen again.
    • Claycorp

      This forum is now READ ONLY!   01/20/2020

      As of this post and forever into the future this forum has been put into READ ONLY MODE. There will be no new posts! A replacement is coming SoonTM . If you wish to stay up-to-date on whats going on or post your content. Please use the Discord or Sub-Reddit until the new forums are running.

      Any questions or comments can be directed to Claycorp on either platform.
crystalcrag

[Solved] WorldGenCustomBigTree.java

5 posts in this topic

There is something that always bothered me in TFC: those big trees that generates lots of leaves but very little trunk to support them. Whenever they got a block update nearby (like snow), about 3/4 of the leaves decay instantly, leaving only a joke of a tree.

 

I'm using TFC 79.24, but the source file in question doesn't seem to have been updated for the past few months. So I found quite a few errors in it: (yes, I know there are pull request on github, but last time I did any development, that was 10 years ago using VBA, so there is that)

 

line 103: the condition var != a || var != b is always true. I've seen this construct in a lot of places, also in WorldGenCustomHugeTrees.java, but this file does not seem to be used.

if (!var16.isAir(worldObj, var13[0], var13[1], var13[2]) && (var16 != TFCBlocks.leaves || var16 != TFCBlocks.leaves2))

Should have been:

if (!(var16.isAir(worldObj, var13[0], var13[1], var13[2]) || var16 == TFCBlocks.leaves || var16 == TFCBlocks.leaves2))

line 314: same bogus construct :

if (!var14.isAir(worldObj, var11[0], var11[1], var11[2]) && (var14 != TFCBlocks.leaves || var14 != TFCBlocks.leaves2)){   ++var13;}else{   setBlockAndNotifyAdequately(this.worldObj, var11[0], var11[1], var11[2], par6, treeId);   ++var13;}

Replaced by:

if (worldObj.isAirBlock(var11[0], var11[1], var11[2]) || var14 == TFCBlocks.leaves || var14 == TFCBlocks.leaves2)	setBlockAndNotifyAdequately(this.worldObj, var11[0], var11[1], var11[2], par6, treeId);++var13;

But ultimately the culprit was in placeBlockLine() : that's the function that attempt to place branches on line 405:

if(worldObj.isAirBlock(var14[0], var14[1], var14[2]))

I replace this by :

Block block = worldObj.getBlock(var14[0], var14[1], var14[2]);if(worldObj.isAirBlock(var14[0], var14[1], var14[2]) || block == TFCBlocks.leaves || block == TFCBlocks.leaves2)	this.setBlockAndNotifyAdequately(this.worldObj, var14[0], var14[1], var14[2], par3, treeId);

Obligatory screenshot:

V44WP3O.png

2

Share this post


Link to post
Share on other sites

Thanks! I generated a whole bunch of them and chopped them down to make sure they wouldn't result in random floating log blocks, and it looks like those changes did the trick. I also took the liberty of attempting to replace all the variable names with ones that actually mean something. The tree gen code was added before I joined the team, and since it uses generic variable names I'm always hesitant to dig into it. A version with this fix applied should be released within the next week or so, and I would appreciate if you could confirm when it does that this isn't still an issue.

0

Share this post


Link to post
Share on other sites

Maybe, generate trees... as trees? I mean, firstly start to protrude main thunk, then branches (in 4-5 directions in random order, carefully preventing intersection). Each branch is "thinner" than its parent. If thickness < N, grow leaves around the wood block.

 

Maybe, its already working that way; however, the code filled with "var12", arrays-as-3D-points and magical constants is pretty hard to understand (no pun intended).

0

Share this post


Link to post
Share on other sites

I'm about 90% certain that code is just a variation of what vanilla uses to generate the big oak trees. It is working as intended now, so there's no need to try and rewrite it to generate differently. Don't fix what isn't broken. :)

0

Share this post


Link to post
Share on other sites

Okay, just updated with from a snapshot taken november 16. All the big trees I've seen seem to be properly supported now.

 

No more trees like that:

08JK4f0.png

0

Share this post


Link to post
Share on other sites