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'm receiving this error when trying to host a server with a built version of my mod (quickconsume):

Reveal hidden contents

 

Here's the class in question: http://pastebin.com/hqGR6Cjm

The purpose of the MessageSyncClient class is to be sent from the server to the client, so it has to be registered on the server side. I'm not sure why it's referencing EntityPlayerSP too.

Edited by TLHPoE

Kain

I think you call a client method in your "onMessage" method in the handler class.

Can you post the code of you "MessageSyncClientHandler" class?

  • Author
  On 2/25/2017 at 7:38 PM, Lhykos said:

I think you call a client method in your "onMessage" method in the handler class.

Can you post the code of you "MessageSyncClientHandler" class?

http://pastebin.com/0FXgPP5C

 

I'm not sure how I would accomplish this without referencing the player. I was thinking about having a static class that would just hold the items in a field so that it won't have to reference any piece of Minecraft at all, but that seems hacky.

Kain

You need to call your actions on the main thread. From the Forge Documentation:

  Quote

As of Minecraft 1.8 packets are by default handled on the network thread.

That means that your IMessageHandler can not interact with most game objects directly. The example above for example would not be correct. Minecraft provides a convenient way to make your code execute on the main thread instead using IThreadListener.addScheduledTask.

The way to obtain an IThreadListener is using either the Minecraft instance (client side) or a WorldServer instance (server side).

 

  On 2/25/2017 at 7:53 PM, TLHPoE said:

http://pastebin.com/0FXgPP5C

 

I'm not sure how I would accomplish this without referencing the player. I was thinking about having a static class that would just hold the items in a field so that it won't have to reference any piece of Minecraft at all, but that seems hacky.

The Minecraft class doesn't exist on the server (it's @SideOnly(Side.Client)). To reference it, you need to make methods in your proxies which return the objects you need (i.e. the player) in the client proxy, and throw an exception in the server proxy (because they should never be called from there). I just had (and solved) this problem today - link!

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.