IClientPacketHandler.handlePacket may have null NetClientHandler
izstas opened this issue ยท 3 comments
The method is being called like this:
((IClientPacketHandler)handler).handlePacket(packet, Minecraft.getMinecraft().getNetHandler(), Minecraft.getMinecraft());
The handler may be called before the player is logged in. In that case, getNetHandler()
will return null. However, getting null as netHandler value may be unexpected for implementations of IClientPacketHandler
, and this can be seen in ForgeMultipart.
I think this should be fixed in CCL, if possible.
What would be the cause of a null nethandler and yet a packet coming through?
Here is an example: https://gist.github.com/izstas/6149561
The client prints something like this:
Received packet: type=1, netHandler=null, thePlayer=null
Received packet: type=2, netHandler=net.minecraft.client.multiplayer.NetClientHandler@890415b, thePlayer=EntityClientPlayerMP['Player171'/426, l='MpServer', x=-197,50, y=70,62, z=238,50]
I made a working fix (https://github.com/izstas/CodeChickenLib/commit/f4d41d3622239c5a068435f334b68d50122525b6), however it uses reflection. I'm not sure if that's a good solution.