I've got a 2D java game with an infinite generating world with a player and other entities. I wish to make this game multiplayer and have done my research. I read this article multiple times and is what I want to implement.
In short: Client acts as terminal sending input to server. Server is authoritative and controls the game, deciding the result of the input from the client and sending back the relative info. Maintaining performance the server each 100 milliseconds keeps a list of all received input from the client and only then processing it. Client predicts its own game state by its input and when it received the processed state from the server it validates if the state is correct, otherwise corrected by the server.
E.g. Player pressed D -> client sends 'move right" input to server -> client predicts its own location to avoid choppy movement -> server finishes 100ms wait and processes all received input -> server decides new location of player by received input -> server sends the decided location to client -> client validates its current predicted location by the server received one, corrects the client if neccessary.
My question: How do I properly send all the inputs to the server and in what format? And how to receive different kinds of output back?
I shouldn't just send the entire player object (which has all inputs such as if WASD keys are held down), should I? Seems way too bandwidth and CPU intensive. Also seems overkill since most properties at each update will be false. Server only needs to be aware of what happened, not what didn't happen. Can I somehow only send single commands to the server? No strings with switch statement please.
How to receive different kind of information from the server? Player needs new world chunks when it moved. Needs to validate its own world position against the server. Needs to check if client inventory is same as server.