[1.21 Fabric] Server disconnect due to ClientSyncMessage payload not registered
smehringer1 opened this issue · 4 comments
Fabric 1.21 Client and Dedicated Server
Fabric Loader 16.0.0 on both, QuarryPlus build 21.1.97
Happened whenever I would try to interact with the quarry block.
Server logs:
[Server thread/INFO]: Player lost connection: Internal Exception: io.netty.handler.codec.EncoderException: Failed to encode packet 'clientbound/minecraft:custom_payload' (quarryplus:client_sync_message)
[Netty Server IO #4/ERROR]: Error sending packet clientbound/minecraft:custom_payload io.netty.handler.codec.EncoderException: Failed to encode packet 'clientbound/minecraft:custom_payload' (quarryplus:client_sync_message)
Caused by: java.lang.ClassCastException: class com.yogpc.qp.packet.ClientSyncMessage cannot be cast to class net.minecraft.class_8711 (com.yogpc.qp.packet.ClientSyncMessage and net.minecraft.class_8711 are in unnamed module of loader net.fabricmc.loader.impl.launch.knot.KnotClassLoader @13deb50e) at net.minecraft.class_9139$6.encode(class_9139.java:42) ~[server-intermediary.jar:?]
Fix
ClientSyncMessage payload is never registered when running as dedicated Fabric server. All payloads need to be registered during common initialization. Moving ClientSyncMessage registration from initClient() to initServer() resolved this issue.
Related:
emilyploszaj/emi#586 (comment)
Try removing the registrations that are done in initClient(). They're already registered via ModInitializer's call to initServer(). Duplicate registrations cause a crash.
Try removing the registrations that are done in initClient(). They're already registered via ModInitializer's call to initServer(). Duplicate registrations cause a crash.
This is not the point. I should have shared the registration code to register packet to PayloadTypeRegistry.playS2C()
(NOT C2S) entry point.
I started the publish workflow.