CommandHelper icon indicating copy to clipboard operation
CommandHelper copied to clipboard

pfacing resets player velocity to 0

Open LadyCailin opened this issue 3 years ago • 2 comments

As this is a commonly used function, this can be used to avoid fall damage when run just before landing. Player velocity should be looked up before the location set, then set back to that immediately afterwards. In the meantime, this can be worked around by doing this in code, but this shouldn't be necessary. Untested, but likely works with set_ploc as well, though perhaps this is not a problem.

Discussion wanted, as this is a breaking change.

LadyCailin avatar Dec 20 '22 19:12 LadyCailin

pfacing() has always just been a teleport and behaved this way. Even re-applying the velocity will still result in jutter.

Technically the real solution is to use relative teleport flags. This was only possible via nms until it was added to Paper earlier this year in 1.19.

https://jd.papermc.io/paper/1.19/org/bukkit/entity/Player.html#teleport(org.bukkit.Location,org.bukkit.event.player.PlayerTeleportEvent.TeleportCause,boolean,boolean,io.papermc.paper.entity.RelativeTeleportFlag...)

PseudoKnight avatar Dec 20 '22 19:12 PseudoKnight

Might it be possible to maintain velocity through the Bukkit API, then we should consider adding an optional keepVelocity or resetVelocity boolean parameter to pfacing(). This solution is possible without changing existing behavior.

Pieter12345 avatar Dec 20 '22 20:12 Pieter12345