OpenBlocks Elevator

OpenBlocks Elevator

128M Downloads

Manually teleport the player to preserve rotation

ChiefArug opened this issue ยท 5 comments

commented

In your code you use the teleportTo method to teleport the player to the destination teleport pad. This in turn uses a fully absolute teleport packet to tell the client to move to the new position, which has the unfortunate side effect of forgetting anything the player did in the round trip to the server, which can be quite high (half a second) on moderately bad ping.

Instead it would be great if you could manually move the player and send the teleport packet yourself, and in said teleport packet (manual moving isnt required, theres an overload of teleportTo that works). Make the yaw and pitch relative (and passing values of 0 for those), so the players head rotation isn't reset, to remove some of the jarring effect from that.

I can provide code examples if needed.

commented

Hello,
Does this still happen when disabling resetPitch in the config?
We rely on setting the yaw angle when directional is enabled on the destination elevator, maybe we can use the other overload when the destination isn't directional? Is this what you had in mind?

commented

Unfortunately I cannot test that properly as its most noticable with higher ping, and I do not have access to the server to change that config option. I've played around in single player and I think it still happens but cannot be sure.

Is this what you had in mind?

Yes. You can even choose to make only yaw relative for directional elevators when resetPitchDirectional = false. (You give it a set of x/y/z/yaw/pitch to make relative, everything else is absolute. by default the set is empty)

commented

Hi, can you test with this version?

It will not force camera angles if destination is not directional and reset pitch is disabled

commented

As I said before I unfortunatelt can't test this due to it requiring a higher ping and me not having access to the server.

However, reading the code in the linked commit, it does not fix it because you still send an absolute yaw and pitch value in the teleport packet.
When you do that, any head movements the player makes in the last (ping * 2) milliseconds get discarded, as the server is sending them what the server thinks is their current position, which is not their actual current position because of ping (its their position (ping) milliseconds ago, and by the time it gets back to the player its (ping * 2) milliseconds ago).

You need to set the values to 0 and pass a set containing x_rot and y_rot to the relative position types argument (where you currently have Set.of()). There is a prefilled set for this already in the relative position types enum class.

commented

Sorry, forgot that you don't have access to the server.

I've tested it with artificial latency (using tc delay) and it did fix the head position being reset to values before roundtrip time (when using the 3 parameter overload of teleportTo)

Anyways, I think I now understand what you meant by using the relative set. I'll do a bit of refactoring tomorrow.

Thank you for your patience!