Jump to content

[1.12.2] Where to store data from packets client-side?


bluepython508

Recommended Posts

I'm trying to use data stored in a capability on the server side as part of rendering on the client side. I have the networking working correctly, ie I can receive the data on request and l and log it, but I'm not sure where to store the data that I have synced across from the server. I essentially send a packet from the client when I'm about to need the data, then the server responds with the necessary data. Where should I store the data from the server so I can access it when I am rendering?

 

My source is on GitHub: http://github.com/bluepython508/Linguism

The data I'm trying to sync is the known spells (See the

net.soroos.ben.linguism.guide.network

 package)

Link to comment
Share on other sites

7 minutes ago, bluepython508 said:

I essentially send a packet from the client when I'm about to need the data, then the server responds with the necessary data.

Don't do this, the server should be in control as to when to send the data to whom. A malicious client could easily abuse requests.

 

7 minutes ago, bluepython508 said:

Where should I store the data from the server so I can access it when I am rendering?

The capability is attached both on the server and on the client, so store it in the client capability.

Link to comment
Share on other sites

8 minutes ago, V0idWa1k3r said:

Don't do this, the server should be in control as to when to send the data to whom. A malicious client could easily abuse requests.

The server doesn't know when the client opens the category, so should it just update the client when the data changes?

8 minutes ago, V0idWa1k3r said:

The capability is attached both on the server and on the client, so store it in the client capability.

So capabilities exist on both sides, and just don't sync across?

Link to comment
Share on other sites

8 minutes ago, bluepython508 said:

So capabilities exist on both sides, and just don't sync across?

Capabilities exist on whatever side you want them to exist since you are the one attaching them. 

For example - If you only attach your capability to an instance of EntityPlayerMP then sure, it will only exist on the server. But you don't usually want to do that.

If you attach it to an instance of EntityPlayer then all players will have it - EntityPlayerMP(server-side player), EntityPlayerSP(client-side player), EntityOtherPlayerMP(client-side other players).

 

8 minutes ago, bluepython508 said:

The server doesn't know when the client opens the category, so should it just update the client when the data changes?

That seems like a better idea, yes.

Edited by V0idWa1k3r
Link to comment
Share on other sites

5 minutes ago, bluepython508 said:

Just to check, in net.soroos.ben.guide.capability.CapabilityHandler I'm attaching it in a way that works on both sides?

 

That package doesn't exist.

 

In net.soroos.ben.linguism.guide.capability.CapabilityHandler you are attaching it to EntityPlayer instances which encompasses both the client and the server players.

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.