Jump to content

[1.9] Crash when sending packet to server


gegy1000

Recommended Posts

I am trying to send a packet to the server, and I am experiencing a crash.

 

http://pastebin.com/6uqpJGCr

 

While researching this crash, all the problems seemed to be from sending a packet to the server, while on the server-side. I am checking the side with worldObj.isRemote on my entity, that the packet is being sent from. FMLCommonHandler#getEffectiveSide() will also have the same outcome as world.isRemote, however FMLCommonHandler#getSide() will have a different output, but using that results in a different error when using sendToAll: http://pastebin.com/vMPK9cUH

 

This is my message sending code in my entity class:

 

  if (worldObj.isRemote)
            {
                JurassiCraft.NETWORK_WRAPPER.sendToServer(new UpdateAnimationMessage(this));
            }
            else
            {
                AnimationHandler.INSTANCE.sendAnimationMessage(this, newAnimation); // This calls sendToAll
            }

 

You can view sendAnimationMessage here https://github.com/iLexiconn/LLibrary/blob/1.9/src/main/java/net/ilexiconn/llibrary/server/animation/AnimationHandler.java#L30.

 

Thanks in advance.

 

Link to comment
Share on other sites

  • Do not use
    getEffectiveSide

    for mission-critical things. It is meant solely for debugging or quick tests. If you want to check the logical side, you must check

    World#isRemote

    .

  • You should not be sending the message to all players. Not every player's client knows about the entity. To get all players, whose client's know about the entity (i.e. the player can see the entity) use
    WorldServer#getEntityTracker().getTrackingPlayers

    .

  • Why is there a client-to-server message at all? That sounds like a horrible idea, the client should not have any say in this.

Oh, yeah, I should probably not send it from the client. Not sure why I thought of doing it like that.

I was only using

getEffectiveSide

for debugging, I'm not using it for this.

I'm also having the same crash, however, for a different packet. It is being sent to the server from inside my GUI class, so it definitely is on the client-side.

Thanks.

Link to comment
Share on other sites

So, now I have to learn how that stupid @NetworkWrapper annotation works...

Apart from the implementation being horrid (why in gods name are you classtransforming FML... please stop...), you just register every message blindly for client & server. With different IDs for each.

This is designed to blow up.

Sorry about that. :/ Would there be another way be to detect those annotations?

Also, I got it wrong. The crash is different. (Sorry D:) This is the crash http://pastebin.com/f4fFfvH1

Link to comment
Share on other sites

Sorry about that. :/ Would there be another way be to detect those annotations?

Handle
FMLConstructionEvent

in the

ModContainer

for the coremod part of the library. It provides you with the ASMDataTable.

Also, I got it wrong. The crash is different. (Sorry D:) This is the crash http://pastebin.com/f4fFfvH1

How did you think that crash was related to your packets? :o

Put a breakpoint in the erroring method and check what is null there.

Okay, thanks! I'll have a go at it. :)

Link to comment
Share on other sites

Put a breakpoint in the erroring method and check what is null there.

Looks like the MinecraftServer instance is null (FMLCommonHandler#getWorldThread), and sidedDelegate is an instance of FMLServerHandler but the net handler is client-side.

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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