Fix missing controller result codecs on clients - #648
Conversation
|
Actually this might not be the root cause. It does not reproduce consistently. So, after going another round with my agent, it found this other possible cause: McJtyLib stores all command metadata in this: private static final Map<String, CommandInfo> commandInfos = new HashMap<>();Multiple McJty-family mods can register commands during NeoForge’s parallel mod construction. Concurrent writes to a plain That explanation fits the evidence:
Our XNet patch performs another I'm out of time tonight but it could be worth doing some load/fuzz type testing to try to get a repro. Or simply acknowledge if the above is true and switch that to a concurrent map. |
Summary
Explicitly register the XNet controller list-result codecs during client setup.
This prevents clients from disconnecting when opening an XNet Controller if the annotation-driven command registration is not present in McJtyLib's client-side command-info registry.
Problem
Opening an XNet Controller could disconnect the client with:
The underlying exception was:
The server successfully handles the request and sends a
mcjtylib:sendresulttoclientpayload. While decoding that payload, the client reads the command name and looks up itsCommandInfothroughMcJtyLib.getCommandInfo(). The lookup returnsnull, so the payload cannot be decoded.TileEntityController.CMD_GETCHANNELSandCMD_GETCONNECTEDBLOCKSalready have the appropriate@ServerCommandannotations. McJtyLib normally discovers those annotations while registering the block and uses them to populate its command-info registry. However, in the affected client environment, the corresponding entry was absent when the payload arrived.Fix
Register the serializers for these two controller list commands explicitly during
FMLClientSetupEvent:xnet.controller.getChannelInfoxnet.controller.getConnectedBlocksThe registrations use the existing command names, result types, and serializer implementations already declared by
TileEntityController.This is intentionally a client-side initialization fix. It does not change:
The small helper mirrors the raw
ISerializerboundary already used by McJtyLib's annotation scanner. McJtyLib'sregisterListCommandInfo()accepts functions typed withFriendlyByteBuf, whileISerializerexposes functions typed withRegistryFriendlyByteBuf.Reproduction environment
Before the change:
xnet.controller.getChannelInfo.Testing
./gradlew build.The project currently reports no test sources for its Gradle
testandtestJunittasks.