Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

 

  • Author

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

  • Author

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

  • Author

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. :)

  • Author

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.