ThomasOM / Pledge

Bukkit transaction API for predicting when a server packet arrives at a client. Mainly intended for use in Minecraft anticheats.
MIT License
70 stars 7 forks source link

Entire cycle of ping IDs must be sent before Pledge calls handles received pong #18

Open GladUrBad opened 4 months ago

GladUrBad commented 4 months ago

This is on 1.20.6, recently tried Pledge with a PacketEvents plugin to send transactions start/end of tick image image

Here is my configuration. Pledge is sending the pings and the client is responding and the server does recognize the receive (verified using PacketEvents) however Pledge won't handle the pong receive method (start/end) unless an entire cycle of the IDs have been sent first. This was found after using the PingTaskScheduler from Dusk which I used to track player ping by scheduling a task every start of server tick. image

With ID range from -1 to -200, the ping is shown as ~5000ms. (200 ids / 2 per server tick 50ms each tick = 5000ms) With ID range from -1 to -2400, the ping is shown as ~60000ms. (2400 ids / 2 per server tick 50ms each tick = 60000ms)

This is how I concluded that it takes an entire cycle of pings in the ID range to be sent first before Pledge actually can recognize receives.

ThomasOM commented 4 months ago

The first transaction someone receives is actually at the end of the tick, as the login process happens during the tick they cannot receive the start tick transaction

ThomasOM commented 4 months ago

So a quick note to clarify: The first transaction (-1) can be captured at ClientPinger#onPingSendEnd because it is sent at the end of the tick.

GladUrBad commented 4 months ago

Ah you're right, though Pledge itself still appears to have issues with this because it calls onPongReceiveInvalid. Through more debug it appears that the vanilla client only responds consistently after the player has fully joined (after PlayerJoinEvent). image image

For now I have implemented a stupid fix in my Dusk fork image

I'm not well versed in these modern versions protocol or Pledge itself so please let me know if I'm being dumb

ThomasOM commented 4 months ago

I'll test 1.20.6 real quick for you, but Pledge should not send ping packets before play state so this hack shouldn't be needed. This is actually the reason why Pledge cannot send the first transaction on the start of the tick

ThomasOM commented 4 months ago

Seems like there is a 1.20.6 compatibility issue, previous versions work fine