Jump to content

[Solved][1.7.10] Server and client gets out of sync


EmperorZelos

Recommended Posts

Hello, I am doing my mod where I have steam being generated, I know the differens between server/client and .isRemote and such but the server and client get's out of sync where one side has more or less steam than the other, shouldn't it be equal? Is there a way to make them update more or?

 

This especially occures for tileentity data that is saved onto the server but then not loaded into the client (I have checked the data, they are close to identical when it starts, I save and quit and then reopen and the client side has low data while the server data is where it should be, having been saved)

 

Kind Regards

Link to comment
Share on other sites

You have two options:

 

1) Server contains all variables, and sends a 'syncing' packet whenever the value is either changed. This would involve overriding getDescriptionPacket (I'm assuming you're using a TileEntity) so that the client also gets the values whenever it loads the TileEntity. This is a great tutorial on Packet (or more correctly, IMessage?) handling. Some people prefer using the vanilla packet instead, I personally don't like that. Personal preference, really. To make sure you send update whenever the important values that need to be synced are changed, just make sure you create getters and setters, and send the packet from the setter.

2) Update the values that you need whenever the server recognises that the player needs them - for example if they're only needed to be displayed on a GUI, then only update the values before the GUI opening (and maybe during the GUI being open if the values are changed).

 

Make sure that you only send the packets to players that are near the TileEntity.

 

Basically the same thing happens to update variables from the Client to the Server. Send the server the value that needs to be changed, and what is should be changed to, have the server verify that the value is possible (to prevent 'cheating'), and after changing then send the variable to any players around the TileEntity again.

 

Hope this helps~

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.

Link to comment
Share on other sites

Well, I haven't seen your code, so I can't tell you. Whenever the client exits the world, all Client data relating to the tile entity is gone. It is then synced again through getDescriptionPacket, onDescriptionPacket and possibly readFromNBT (or is it loadFromNBT?).

 

Only the Server actually saves the information.

 

 

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.

Link to comment
Share on other sites

Alright, I have managed to solve it but I have the issue of metadata of a block (which changes as the steam pressure increases) starts at 0 when the world is loaded and remains at 0 until it changes from it's data point (let's say the pressure is 2 for the sake of arguement) and then when ti changes to 3, the client gets the change and shows correct but until then it does not. How would I fix that?

Link to comment
Share on other sites

How important is it for them to be in sync? It sounds to me like the steam is something you render on the client but hold the data for on the server? Is it affecting gameplay? If its just rendering and has no effect on gameplay, I would basically expect them to be out of sync and you as the debugger are most likely the only one who will ever even realize they are out of sync, and only from watching so closely in your debugging. If it DOES effect gameplay and needs to be the same across all clients then you may have an issue and need to send a LOT of packets or follow the advice from above, but you may be able to at least make the logic make sense per player by handling as much as you can on the client, like you would particles or a gui, and most clients wouldn't know the difference. Maybe a more in depth description of what this "steam" is doing in your game and post some more code?

I'll need help, and I'll give help. Just ask, you know I will!

Link to comment
Share on other sites

I have acctually done huge progress so most of it is solved, the issue seems to be more metadata related now.

 

Anotehr example I worked throughout the day is a pressure gauge pipe that generates a redstone signal who's strength depends on the pressure inside, the metadata of the pipe changes and as such generates more redstone power but the redstone connected doesn't react to the new strength, when I remove the closest redstone and replace it it goes as far as it should though.

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.