Add ClientboundSetChunkCacheCenterPacket to respawn related packet list#477
Add ClientboundSetChunkCacheCenterPacket to respawn related packet list#477Ingrim4 wants to merge 2 commits into
Conversation
|
This does not solve the infinite loading issue #475 with ItemsAdder. Even without this patch the packet ordering seems correct without ItemsAdder installed:
Upon adding a ProtocolLib listener to ClientboundRespawnPacket the ordering is the following:
This is probably incorrect as the client's chunkcache is recreated with the respawn packet thus keeping it's center at (0,0). This might also be what ItemsAdder does because the only relevant packet I could find it registers with ProtocolLib is the ClientboundRespawnPacket. (https://gist.github.com/DasLulilaan/e41196fba89286d4daf1e0f410532f3e#file-dump-2026-04-25_13-10-19-txt-L161) The same bug can also be triggered using ProtoclLib's debug command: Could this have something to with that packet being "downgraded" to being synchronous because of that non-async listener (either ItemsAdder or debug command) thus pushing it into the next tick? |
|
In ProtocolLib, every packet that is processed asynchronously is assigned a packet sending index. This index represents the absolute order in which the packet would have been sent to the player if it had been processed synchronously. Using this index, ProtocolLib ensures that all asynchronously processed packets are ultimately sent in the correct order. If asynchronous processing is canceled by a synchronous listener, the packet simply falls back to synchronous handling and is sent immediately. We rely on this behavior to preserve correct packet ordering during respawns. When switching between dimensions (e.g., overworld to nether), differences in world height can cause the client to disconnect if chunk data does not match the new world. To avoid this, we temporarily capture all packets sent after the respawn packet and process them asynchronously until the next tick. This ensures the correct ordering while minimizing additional delay. Regarding your observations: are you saying that you ran That would be unexpected. Packet listeners in ProtocolLib are normally executed strictly in priority order. Unless a packet is explicitly canceled and re-queued for later processing, the presence of additional listeners should not affect packet ordering. |
|
I just downloaded fresh jars of everything and ran them on a fresh papermc server. With ProtocolLib 4.5.0 (i had some dev build before) the packet ID is now 75 but the same problem stil occurs. As soon as i run sha256sums of the files to be sure: |
|
Thank you again for your findings. I will review this in more detail over the next few days, as I am currently unable to fully explain the observed behavior. |
|
It looks like the issue is caused by ProtocolLib. After async processing, ProtocolLib delays a packet by one tick if at least one sync listener requires the packet to be handled on the main thread. As far as I can tell, this only affects MONITOR packet processing. I’ll flag this as a bug and fix it directly in ProtocolLib, since MONITOR listeners should not be able to modify packets. Because of that, I don’t see a reason to delay packet execution in this case. |
Description
Add missing
ClientboundSetChunkCacheCenterPacketto respawn related packet list in sync injector.Related Issue
closes #475
How Has This Been Tested?
Not tested
Types of Changes