Jump to content

Get all Blocks from a tree when player hits a log


ItsAMysteriousYT

Recommended Posts

I wrote an algorithm once. It was recursive and likely not the best, but it worked.

 

Kill current block and every log above this one.

Then recurse for every adjacent log next to this one, if the block above is air, also recurse for its neighbors.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I wrote an algorithm once. It was recursive and likely not the best, but it worked.

 

Kill current block and every log above this one.

Then recurse for every adjacent log next to this one, if the block above is air, also recurse for its neighbors.

Yea - i thought of that one too, but i need everything of the tree - logs&leaf's. I thought of making a List of all the trees with their logposition and then when a log is destroyed i loop through the list and look for the destroyed log. If it is is in one of the generated trees im gonna loop through the rest of the BlockPos-Array from this tree. All i need is a possibility to get every Block that is generated for a tree from the WorldGenTrees class. Is that possible? Or do i will have to use some class transformers?

Link to comment
Share on other sites

I've written a recursive method to do this myself. One tip if you plan to write your own. make sure you are not going from log to leaf & back to log again.

If you don't in a biome like Roofed forest you'll get 1/2 the forest otherwise :o very OP but very lag inducing.

I'd share mine but i'm not 100% happy with it yet. It still leaves some hanging logs in the big oak trees that have random logs that are not on the up, down,north , south, east, west sides but instead are diagonals or not connected at all.

Its been low priority on my todo list so far.

 

Link to comment
Share on other sites

Extend my method such that you have a log version (recurses itself and calls the leaf version) and a leaf version (recurses only itself).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Not really, no.

My algorithm is the closest I came. It does very well even in the roofed forest, though it can occasionally trim the tops of a neighboring tree.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Also, tree's usually have their own box radius, in that even within a roofed forest you have a limit imposed, so really it's about scoring weight per block within that radius that depends on the distance between logs. You could do recursive but i suspect that's also a bit of an overkill given the nature of Tree Generation... the first pass in a loop could just audit the 16x16 area using the player as a centre point. Put this into two arrays (leaves and logs). Then using the SQRT functions you can simply infer likelihood that the block belongs to the trunk of an adjacent tree by its type and distance from root (which you'd define as being the source of the hit or objectMouseOver position).

 

I've done this already and although its not "accurate" the illusion stays intact and that's all that really matters, if the player believes it to be so, it is honest to goodness true :)

 

For the leaves you can create a random noise true/false statement for all blocks say 8x8 away from your harvest zone...that way it will look less like you took out a clean square of blocks but more so that some linger. If they are orphan leaf blocks the server will clean that up for you aswell.

 

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.