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

Add safe-teleport detection to spawn points. #7530

Merged
merged 10 commits into from
Sep 12, 2024

Conversation

Intybyte
Copy link
Contributor

Description:

Teleport a player near a safe location when teleporting to town spawn/outpost/nation spawn, for now it only fails the teleport


Relevant Towny Issue ticket:

#7463


  • I have tested this pull request for defects on a server.

By making this pull request, I represent that I have the right to waive copyright and related rights to my contribution, and agree that all copyright and related rights in my contributions are waived, and I acknowledge that the TownyAdvanced organization has the copyright to use and modify my contribution under the Towny License for perpetuity.

@LlmDl
Copy link
Member

LlmDl commented Jul 28, 2024

It would appear that this would prevent towns from placing any not-fully-solid blocks where players spawn, such as signs, buttons, pressure plates, and similar.

@LlmDl
Copy link
Member

LlmDl commented Jul 28, 2024

This new behaviour should also only be enabled via a new config option that defaults to a false setting.

@LlmDl LlmDl changed the title Fix town spawn/outpost tp/nation tp Add safe-teleport detection to spawn points. Jul 29, 2024
@Intybyte
Copy link
Contributor Author

Do I have anything left to do for the PR to get pushed? Just to know if I forgot something

Copy link
Member

@LlmDl LlmDl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment on the getSafeLocation(Location location, Player p) method, and how it prefers to go downwards that should be addressed.

@Intybyte Intybyte requested a review from LlmDl August 2, 2024 19:14
Copy link
Member

@LlmDl LlmDl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code backing this looks fine at this point. I'm still stuck on a point I made in an earlier comment:

I am a bit apprehensive about this method for a couple reasons:
I'm fairly sure that calling world.getBlockAt(Location) has to load the chunks to learn about the blocks. Part of using PaperLib to teleport players was making teleports less painful on servers. This new system will probably result in losing that performance gain. It is possible to load the WorldCoord that contains the spawn point though so this is something that can probably get solved for.

Do we know what sort of performance hit this feature adds yet?

@Intybyte
Copy link
Contributor Author

The code backing this looks fine at this point. I'm still stuck on a point I made in an earlier comment:

I am a bit apprehensive about this method for a couple reasons:
I'm fairly sure that calling world.getBlockAt(Location) has to load the chunks to learn about the blocks. Part of using PaperLib to teleport players was making teleports less painful on servers. This new system will probably result in losing that performance gain. It is possible to load the WorldCoord that contains the spawn point though so this is something that can probably get solved for.

Do we know what sort of performance hit this feature adds yet?

Only one chunk will get loaded as this only looks in the Y axis, and it is the one the /t spawn is on, which would get loaded regarless, every check looks like it is performed in a completable future, the only sync operation that would happen is loading the chunk, and if I am correct all the calculation gets calculated async, iirc the expensive operation you talking about is getting blockStates, which we don't really need in this case, tell me if I am missing something

@LlmDl LlmDl modified the milestone: 0.100.5.0 Sep 12, 2024
@LlmDl LlmDl merged commit a7d8a53 into TownyAdvanced:master Sep 12, 2024
1 check passed
LlmDl added a commit that referenced this pull request Sep 12, 2024
with PR #7530. (First-Time Contributor!)
    - New detection system scans players' teleport destinations to make
sure they will not suffocate or fall.
    - Closes #7463.
  - New Config Option: spawning.safe_teleport
    - Default: false
    - If enabled tries to find a safe location when teleporting to a
town spawn/nation spawn/outpost.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants