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

My Client > Server Request packets never seem to be being recieved on the server.

 

I registered the message using

NETWORK.registerMessage(MessageSyncEPP.Request.Handler.class, MessageSyncEPP.Request.class, 0, Side.SERVER);

 

This is the Handler class:

public static final class Handler implements IMessageHandler<Request, Response>
{
    @Override
    public Response onMessage(Request message, MessageContext ctx)
    {
        System.out.println(String.format("REQUEST RECIEVED ON SIDE: %s", ForestMagic.instance.getSide()));
        LogHelper.packetRecieved(message);
        ExtendedPlayer properties = ExtendedPlayer.get(ctx.getServerHandler().playerEntity);

        Response response = new Response();

        //ADD PROPERTIES HERE
        LogHelper.packetSent(response);

        return response;
    }
}

 

onMessage never seems to get called.

 

I'm sending the packet like this

MessageSyncEPP.Request request = new MessageSyncEPP.Request();
LogHelper.packetSent(request);
NETWORK.sendToServer(request);

 

The packetSent logging DOES happen, and it definitely happens from the client side. Is sendToServer not the proper way to send the message to the server?

 

 

EDIT: Forgot to mention that my NETWORK variable is declared like this:

public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MOD_ID.toLowerCase());

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

  • Author

The request packet is empty from client > server and the response is sent back from server > client with appropriate details so that the client resyncs is information from the server.

 

I'm sending the packet from the EntityConstructing event, I know that the event is called on both Server and Client.

 

I check to make sure the entity is an instance of EntityPlayer, then check to make sure world.isRemote is true (So I'm only sending the request client side).

 

The reason I'm using the Request/Response is because I'm going to need to use it in GUIs, and other client-only things where I can't send the 'response' directly. I was testing out to make sure it works first so I don't run into issues later.

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

  • Author

It is for this case, I can just use sendToPlayer with the 'Response' without the request.

 

I was just testing the request to make sure it works and it seems it does not. Could it be because the request packet is empty?

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

He's asking why do you need to send a packet from the client requesting information? What exactly are you trying to accomplish? Typically, the server already knows what's going on and can send information directly to the client when needed, such as when a GUI is opened, meaning you are making your code too complicated.

 

What information do you need, where do you need it, and when do you need it?

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.