Folia icon indicating copy to clipboard operation
Folia copied to clipboard

Add asyncTeleport events

Open WillQizza opened this issue 1 year ago • 2 comments

Figured out what was wrong with my previous pull request #67 due to a misunderstanding of internal paper methods regarding the chunk coordinate calculations. This pull request fixes what it had problems with.

Currently, teleports caused by methods such as ender pearls or the /tp command do not trigger PlayerTeleportEvent or the EntityTeleportEvent.

This pull request implements the events when teleportAsync is called.

WillQizza avatar May 02 '23 04:05 WillQizza

add this please, it currently create a lot of issue and crash

HyCore avatar May 07 '23 13:05 HyCore

Clean up the imports, and add comments where diff starts and diff ends. https://github.com/PaperMC/Paper/blob/master/CONTRIBUTING.md

The comment where I wrote that events may be placed there is actually wrong. It also needs to check the preconditions for teleporting again, as plugins may modify them. Ideally, given that this is "new" API, if any of those checks fail (i.e wrong tick thread, entity removed, or any other check it made before) then the code needs to throw an exception.

You have also incorrectly handled the case where the plugin modifies the target destination world, position, and yaw/pitch. You have also incorrectly handled the case where the entity being teleported is a vehicle and contains passengers. We could add a new event for this, but really it just needs to be invoked for every entity on the passenger tree.

Spottedleaf avatar May 13 '23 23:05 Spottedleaf