Posted May 23, 20205 yr I've written a player capability class which keeps track of some statistics kept and incremented on the server. Most of the information isn't expected to be updated very often so it's only synchronized with the client when it meets a certain flag. However, some of the information (stamina, fuel, etc) is updated every tick, and directly affects client-side rendering. For example, the player cannot left click (the hand's swing render event doesn't even trigger) if stamina does not meet a certain threshold. Sending packets back and forth between client/server every tick is obviously a terrible idea, how should I approach something like this? Is it possible to keep two counts running synchronously between client/server? And then sync the two every once in a while. Edited May 23, 20205 yr by Turtledove
May 23, 20205 yr Hi Yeah that's exactly how vanilla does it in many places (eg block mining); it executes the code logic on both client and server (eg eating to reduce fuel, gradual regeneration of stamina, etc), and periodically resynchs the client by sending it a packet. It will help a lot if you design your gameplay to be tolerant of mis-synch between client and server - for example, instead of making the player unable to swing at all below a certain stamina, you could make it always swing but just be very weak. That makes mis-synchronisation a lot less noticeable to the player than an on/off threshold (i.e. where the client thinks the player can swing but the server doesn't). -TGG
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.