Kotori316 / QuarryPlus

Advanced mining machines for Minecraft.
https://www.curseforge.com/minecraft/mc-mods/additional-enchanted-miner
GNU Lesser General Public License v3.0
55 stars 14 forks source link

[1.21 Fabric] Server disconnect due to ClientSyncMessage payload not registered #552

Closed smehringer1 closed 3 weeks ago

smehringer1 commented 3 weeks ago

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

Kotori316 commented 3 weeks ago

Seems not working.

smehringer1 commented 3 weeks ago

Try removing the registrations that are done in initClient(). They're already registered via ModInitializer's call to initServer(). Duplicate registrations cause a crash.

https://github.com/Kotori316/QuarryPlus/blob/6f9248068b948b9f86dd66571faf530e6e51a563/fabric/src/main/java/com/yogpc/qp/fabric/packet/PacketHandler.java#L58-L59

Kotori316 commented 3 weeks ago

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.

Kotori316 commented 3 weeks ago
スクリーンショット 2024-08-24 9 44 17

Seems working in my development server