Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible feature update: Only spawn from actual trees #10

Open
BrekiTomasson opened this issue Jan 6, 2021 · 5 comments
Open

Possible feature update: Only spawn from actual trees #10

BrekiTomasson opened this issue Jan 6, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@BrekiTomasson
Copy link
Collaborator

This should be configurable with an on/off toggle, but somehow it feels wrong when I place a leaf block manually, that leaves begin falling from it. There should be some kind of check (similar to the leaf-decay check) which checks if the leaf block is in concact with a log (or within touching distance of other leaf blocks that touch a log). I'm sure there are already samples of code available that do this very check that we can slot in.

@BrekiTomasson BrekiTomasson added the enhancement New feature or request label Jan 6, 2021
@Fourmisain
Copy link
Collaborator

Fourmisain commented Jan 11, 2021

I just found state.get(LeavesBlock.PERSISTENT) which is true exactly if it was placed manually.
There's also state.get(LeavesBlock.DISTANCE), an integer between 1 and 7 telling the distance to an appropriate log.

Leaves despawn when state.get(DISTANCE) == 7 && !state.get(PERSISTENT).

So we could either use the distance or the persistence flag.
I guess it makes more sense to use the persistence flag, since most of the times, leaves are placed nearby logs anyways, so there wouldn't be any actual change otherwise.

How should we name the config option?
"Drop from manually placed leaves", defaulting to true?
It's the shortest description I can come up with and still kinda a mouthfull

@BrekiTomasson
Copy link
Collaborator Author

I think LeavesBlock.DISTANCE returns 0 if you've got a leaf block touching a stone block touching a log. It should only return the distance as it travels along other leaf blocks, making it a good way to check if a leaf block is part of an actual tree or part of something else. I haven't checked if it only works in straight lines and 90-degree angles or if it supports diagonal distances, as that would be required for some modded tree types.

As for the config option, I'd probably prefer something like "Only drop from actual trees" or similar, defaulting to false. Yours is good too, although I agree that "manually" might make it a bit wordy. Maybe "Drop from player-placed leaves"?

Fourmisain added a commit that referenced this issue Jan 20, 2021
@BrekiTomasson
Copy link
Collaborator Author

I believe this issue can be closed?

@Fourmisain
Copy link
Collaborator

Fourmisain commented Jul 10, 2021

For me, the "player placed" option is enough, though it is different from what was originally suggested.
Implementing an actual tree check would be too expensive and basically impossible to get 100% right anyway.
There might be some merit in looking at LeavesBlock.DISTANCE but I'm not sure if it's worth getting into.

So I'd vote close until someone has a better suggestion.

@BrekiTomasson
Copy link
Collaborator Author

Agreed, the "Player Placed" option should be enough. We can revisit this at a later date to see how leaf blocks placed as part of structures in Worldgen are handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants