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

Optimize safe location searching with configurable range limit #1892

Merged
merged 4 commits into from
Dec 20, 2021
Merged

Optimize safe location searching with configurable range limit #1892

merged 4 commits into from
Dec 20, 2021

Conversation

HSGamer
Copy link
Contributor

@HSGamer HSGamer commented Dec 16, 2021

This new method will search the spot around the destination, and then expand the y-coordinate up and down, instead of the old method (searching top-down).
This fixes a weird behavior in CaveBlock where the players sometimes go straight to the roof (Close #1891).

A new setting is also added to limit the y-coordinate range, which optimizes the searching a bit.

@HSGamer HSGamer changed the title better safe spot finder (Fix #1891) Optimize safe location searching with configurable range limits Dec 19, 2021
@HSGamer
Copy link
Contributor Author

HSGamer commented Dec 19, 2021

Updated the description

@HSGamer HSGamer changed the title Optimize safe location searching with configurable range limits Optimize safe location searching with configurable range limit Dec 19, 2021
@tastybento
Copy link
Member

This is great! Just out of interest, why have a variable as a configuration? Why not just boolean and yes/no it? Or why have this option at all? I'd say the job of safe search is to find a spot, not need for config. What do you think?

@tastybento tastybento self-requested a review December 19, 2021 16:52
@HSGamer
Copy link
Contributor Author

HSGamer commented Dec 19, 2021

This is to fix a weird case in CaveBlock. When the server owner changes the world depth lower than the default height, the check may cause the players to go to the roof of that world.
Since I don't see a world depth setting in WorldSettings, this is a better way to limit the check not to check the roof.

@HSGamer
Copy link
Contributor Author

HSGamer commented Dec 19, 2021

And I want to archive a behavior that if a safe spot was not found, it would create a spot for the players instead of throwing them to the roof.

@HSGamer HSGamer requested a review from tastybento December 19, 2021 17:05
@HSGamer
Copy link
Contributor Author

HSGamer commented Dec 20, 2021

Since there are a lot of GameModes with different kind of Game Worlds, this setting may need to leave for the owners to decide.
CaveBlock might set the value lower than the world depth, others may not. And it's future-proof for upcoming GameModes.

@HSGamer
Copy link
Contributor Author

HSGamer commented Dec 20, 2021

Much better. It'll check the current chunk before loading the next one, all async now.
This prevents an expensive performance drop when the chunks have to be loaded before checking the first chunk.

@tastybento tastybento added the Status: In progress Working on the issue. label Dec 20, 2021
@tastybento tastybento merged commit e3b9919 into BentoBoxWorld:develop Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In progress Working on the issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Safe Location On Portal - Went to the bedrock roof
2 participants