Make broken leaves drop as saplings when broken (if possible)
kadincool opened this issue ยท 1 comments
Describe the feature
When using the FALL_BLOCK method of chopping trees, the items will get dropped as items if they fall on a tile they cant be placed on (torches, path, etc). This behavior is fine for logs but causes leaves to drop as leaf blocks and not saplings, which are fairly useless and clog up the inventory.
I feel this should be possible seeing as how FALL_ITEM performs this behavior, maybe there could be a check for if the sand entity (which It appears you use) gets destroyed in which it drops as if it was destroyed, but if it can be placed it gets placed.
I'm not sure this is possible. As you seem to have seen in the code, I reuse the "falling block" (like sand, primed tnt, gravel, ...) from Minecraft itself.
There's several way it works. Inside it there's a boolean "cancelDrop" :
- false : it's the default mode, the entity falls, and when it hits the ground :
- The spot is available: The block is set into the world
- The spot is unavailable: The block itself is poped as an itel (and not it's loottable)
- true : the entity falls, and when it hits the ground no drops are made (it simply disappears)
Depending on the FallingTree breaking mode, FALL_XXX, different values of "cancelDrop" will be set.
- FALL_ITEMS has leaves + logs set to true
- FALL_BLOCK has leaves to true and logs to false
- FALL_ALL_BLOCK has heaves + logs set to false
To avoid having loot disappear when the value is set to true, FallingTree will make it pop itself from the loottable (if you look a slowmo you should see that loot is already present when the blocks are falling).
Now, regarding the issue itself, I think it's just not fixable, or at least not in an "easy" way. This would require to make my own "falling block" entity, which I want to avoid as it'd force dedicated servers to have every client to have the mod. Reusing the Minecraft one doesn't impose that and the server can stay server-only.
So basically if you don't want to have leave blocks themselves as items, you'd have to pick FALL_ITEMS, where FallingTree does the loot handling, instead of delegating it to Minecraft's falling block entity. (I guess minecraft did it this way as the falling entity was mainly designed for sand/gravel which drop themselves and not their loottable)