Jump to content

[1.8] SimpleNetworkWrapper & io.netty.handler.codec.DecoderException


Recommended Posts


I'm working on a mod where I send packets to the clients in the area with simpleNetworkWrapper.sendToAllAround and passing my MachineModMessageEntityToClient class which implements IMessage.


When I do so with only 1 player online or in SP it works fine... the data is sent to the client for rendering .


But if I have two (& possibly for more players ) online when the packets are sent both clients are kicked from the server and the error below is in the console.


I've set break points in the FML code where it is causing the exception and I can see from the message object that it is in the processing of my packet but the packet appears to be in this "EmptyByteBuf" state even though I'm creating it with my constructor that will provide the data to it.


I've tried back porting my project to 1.7 and I haven't encountered this problem in 1.7 yet, but i'd prefer to have my mod working in 1.8 because I still have a lot of work to do and 1.8 may be official by then.


I'm still somewhat new to modding so I thought maybe another set of eyes my spot what i'm doing wrong or offer a better way to troubleshoot the issue.


Any help or guidance is greatly appreciated I've been racking my brain on this one for a few days now.




my project on github:






Imessage implementation :



Network Registration line 26 specifically:




Call that is sending the packet line 213 :




ERROR from client side console (spoiler tag seems to not work for me):


Link to comment
Share on other sites



It's been a while since I worked on packets but I don't see an obvious problem.  It looks to me like the handler hasn't even reached your code yet, and given that this works in single player  makes me suspicious that it might be a FML bug.  FML should automatically add a discriminator byte to the buffer so it should always have at least one byte in it.  You could try upgrading Forge to the latest version and seeing if that fixes it.


Otherwise, you could add System.out.println to the handlers, the message constructors and toBytes() & fromBytes  try to track which methods were actually called, it might give you a clue.


Good luck with it; last time I had a Network handler issue (caused by incorrect registration) it took me the whole day to track it down.


I'm about to try and work up an example Network handler, if you haven't cracked it in a couple of days I might practice on your project, but no promises :)





Link to comment
Share on other sites

First , Thank you TheGreyGhost for taking a look & your suggestions I appreciate it.


I can confirm the constructor  ,frombytes & handler are getting called by the client when it is working properly with only one player within range of the packet location.


I can also confirm that sometimes when the client reconnects and other clients are within range that it is not even calling the constructor of my message so it appears to be a bug in FML before my code is running on the client.

This plus the fact that I'm not seeing the same behavior when I back port to 1.7 leads me to believe it is a bug in FML 1.8.


I'm working with forge 18. build  1285 which is the latest so it sounds like I need to wait until it is corrected.


Feel free to use the project as you'd like its the reason its on github :)


I had mostly used other tutorials here on the forums on networking & I have came across a few of your post and examples and I've found them helpful.


Thanks again !

Link to comment
Share on other sites

It looks like you have a packet that is trying to read from an empty buffer, so I would double-check your toBytes and fromBytes implementations (the packet you linked looked fine, though).


Another thing, in 1.8, the network is handled on a separate thread; see some discussion about it here.


Being on a separate thread means that often the world and other objects which you would expect to be up-to-date may actually be out of sync, and odd things can happen.


My own network code seems to be working fine in 1.8 and is almost directly ported from 1.7.10. Feel free to take a look.


Sorry I can't tell you exactly what is wrong with your specific code :(

Link to comment
Share on other sites

Hi coolAlias, Thanks for the response.

I did come across your discussion with Lex Earlier today and tried separating it into another thread at one point to see if that would help but it did not.


I took a look at your project and made a fork to test with.

If i use your code but change it to sendtoAll instead of sendTo in your Combo class I get the same error when I have multiple users connected to the dedicated server & I attack a mob after pressing X to "Lock" on to them.


Looks like FML has a bug when sending packets to multiple clients  but works OK if the packet is going to one player/client. :( 



Guess i'm not crazy after all ;)

Thanks again for another set of code to confirm it with :)

Link to comment
Share on other sites

For anyone who may encounter this issue in the future I've created an issue on FML's Github for this @ https://github.com/MinecraftForge/FML/issues/588

I've also created a temporary helper method that will send a packet to all players around a point by sending the packets individually. I'm sure its not as effecient but it seems to work until we have a permanent solution to the root cause.


Workaround based on how FML finds players around a point:



public static void sendPacketToAllAround( IMessage packet, TargetPoint tp)


for (EntityPlayerMP player : (List<EntityPlayerMP>)FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList)


            if (player.dimension == tp.dimension)


                double d4 = tp.x - player.posX;

                double d5 = tp.y - player.posY;

                double d6 = tp.z - player.posZ;


                if (d4 * d4 + d5 * d5 + d6 * d6 < tp.range * tp.range)



                ModNetwork.simpleNetworkWrapper.sendTo(packet,player );









Hope this helps !

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.