Closed smehringer1 closed 3 weeks ago
Seems not working.
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.
Seems working in my development server
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.
https://github.com/Kotori316/QuarryPlus/blob/01d4c978114a0bcbd4db3a22569c24ceb80c209d/fabric/src/main/java/com/yogpc/qp/fabric/packet/PacketHandler.java#L23-L28
https://github.com/Kotori316/QuarryPlus/blob/01d4c978114a0bcbd4db3a22569c24ceb80c209d/fabric/src/main/java/com/yogpc/qp/fabric/packet/PacketHandler.java#L42-L45
Related: https://github.com/emilyploszaj/emi/issues/586#issuecomment-2198645350