Make trees fall over when harvested
ferreusveritas opened this issue · 13 comments
This is a placeholder issue for the tree felling feature that will eventually make it's way into a future release. Once this feature is complete then Dynamic Trees will be at version 0.8.X.
Notes about the new feature:
This is my attempt to provide a long awaited feature to my mod and minecraft in general. Since Dynamic Trees can maintain a solitary tree structure in the world it provides some opportunities previously unavailable to minecraft trees. We can make a entity model with the branches and animate it using whatever means we please. Falling down when chopped(felling), branches falling down when cut, tree bits flying through the air when a creeper blows up. The entire tree model can be cached as a BakedModel for performance. I will apply animations that are only rudimentary based on physics. These animations can be easily overridden with another mod if someone wants more(or less) complex animations. This system is by no means perfect. I don't intend to make it perfect. The falling entities will not have accurate collision detection with the environment, moments of inertia, even the rotations are hokey. Keep in mind that this is meant to be a fun little animation to give minecraft more charm while being quick and dirty. I won't add a plethora of options for people to tweak the falling speed and what have you. If you're interested in doing so then you can create your own animations in another mod.
Todo before launch:
- Falling tree entity
- Tree falls and hits the ground when chopped at it's base.
- Falling trees damage living entities
- Taller trees take longer to fall
- Balance falling tree damage with game play
- Add damage multiplier for falling tree damage to configuration
- Falling trees damage players
- Burning trees drop limbs as they are damaged
- Dropped limbs are on fire an burn the ground where they land
- Falling tree limbs float on water
- Data efficiently sent to client via entity
- Falling trees feature is optional
- Fully tested falling trees
- Fully tested falling trees in dedicated server mod
- Fully tested with feature disabled to ensure nothing broke
- Trees damaged by explosions have limbs that are thrown by the explosive force
- Tree entity changes the rooty dirt to plain dirt when cut at it's base
- Sneak while chopping to make tree fall in opposite direction
- Palm trees
- Cacti
- Falling sound effect(don't know where i'm going to get this)
- Optionally line up logs where the tree fell like tree chopper mod(disabled by default)
- Optionally scatter harvested tree parts where the tree fell(disabled by default)
- Ignore dynamic leaves blocks collisions so trees can semi-reliably fall in a forest.
Won't fix:
- Objects in trees that don't update if the leaves around it are destroyed will hang in the air after the tree falls. e.g. Bee Hives. Not my problem.
- Physics isn't perfect. It's not supposed to be.
- Falling trees will collide with vanilla leaves.
Thanks for the suggestion but I think it's presumed that Steve is a knowledgeable enough woodsman to make the tree fall in a favored and controlled direction. Such is an easy task for any worker in that field.
Here's a preview of the tree falling feature.
Thanks :)
A little description of the work so far.. The portion of the tree you see falling is an entity. It's created from the data that is collected before the tree cut off portion is destroyed in the world. This data is compressed by storing all of the relative offsets and encoding them as an integer array. The connection sizes for each node are similarly stored in an integer array. This compressed data is stored in an NBT Integer array and shot off to the client side entity where it recreates the data in the form of a model. This model is cached as an array of baked quads for performance reasons. An animation style is selected based on how the branch was cut. Once the animation is complete the entity will drop it's payload using whatever method is appropriate for the animation.
For those of you who rub your nipples when the frame rates are high you'll be glad to know that this operation is not going to kill your frame rate. I'm using methods not unlike falling gravel and sand block entities. Also, this feature is entirely optional and can be disabled in the config file. So quit yer bitchin'
At the moment the "fallover" animation simply makes the tree rotate over with acceleration depending on how high it's center off mass is from the cutoff point. When the tree reaches 90 degrees then the animation ends and the payload is dispensed at the cutoff point. It completely ignores surroundings and the model harmlessly goes into hills and other would-be obstructions. This is not how I intend it to be in the end. I plan to make the animation end when the trunk encounters a solid block. Also mobs and other players can take damage from being in the wrong place when the tree falls(yes, configurable damage of course).
Here's another point to bring up.. Many people want the tree to fall to the ground and stay there so they can hack it up into pieces à la Tree Chopper. If you know anything about how Dynamic Trees function then you'll understand right away why that can't be. Instead I will try to include an option where the appropriate amount of whole logs are placed at the trees final resting place surrounded by the remaining wood in the form of stick itemStacks. Everyone has their own idea about how this should function, many of those same people have no idea how Dynamic Trees work at all. Just remember that perfect is the enemy of good.
That already looks amazing! Absolutely love this mod and just want to say that I appreciate all the work you put in.
Yeah separate sounds is what I was thinking in the 2nd point. Pitch shifting based on wood diameter sounds elegant. Would you want leafy and non-leafy versions?
That clip's source is under the Creative Commons license and probably has more to offer than just the leafy impact. I haven't spent much time searching Freesound yet.
re: Falling sound effect
What would be ideal? I was considering helping before realizing some possible complications.
- Chopping a thin branch shouldn't make the same heavy crack & thump a whole tree would.
- Some trees hit the ground sooner/later than other trees because of surrounding elevation/slope differences, so sfx for impacts should play separately from sfx for breakages.
- Sfx for impacts for trees without leaves should sound different from trees with leaves.
Maybe I'm giving it too much thought. Anyway, attached is a clip of a leafy tree hitting the ground.
edit: removed attached sound to repackage with source/license included, with a bunch more later.
What if it was two sounds? One for the creaky fall and the other on impact. The sounds could be pitch shifted for tree size. Terminating the sound early could be a problem as I don't think MC lets you do that.
Plus the sounds MUST be royalty free with no restrictions.
There would need to be 2 or 3 variations of the same sounds so the audio doesn't get repetitive. Yeah, having a leafy and non leafy ground contact sound might be something to consider.
Here is a handful of sfx I pulled and edited from other Freesound.org samples, including the previously posted one, bundled with license info and source URLs.
I suggest to add some radomness when cutting the tree(only 4 directions of course), for example the tree can fall in the player direction, that will make cutting a tree a little bit more dangerous. ;-)