Architecture New
Minecraft compiled codebase consists of two files: the client.jar and the server.jar.
The server.jar includes all the core functionalities of the game.
The client.jar has the server.jar embedded in it. The client.jar also has the code to run client only features, like the main menu, the pause menu and the player’s input. This file is meant to be run on your computer with a Launcher.
Both files are necessary to play Minecraft but are used differently depending on the type of Gameplay.
This architecture allows Minecraft code to be the same for Singleplayer and Multiplayer, and therefore smaller bundles sizes, and easier for Minecraft developers to maintain.
Game logic is piloted by the server.jar that sends states to the clients. Clients are just interfaces for players to interact with and send back actions to the server, to make interactions possible.
That’s why, with bad Internet connections, you and your friends could see different things, get teleported back to previous locations or blocks will not actually break because the state of these changes hasn’t been updated on the server, and propagated to all the other clients yet.
This client-server architecture prevents client to alter the code on server (preventing cheats), and making client more lightweight since only the pure client “part” of the client.jar is used in the Launcher.
When you enter a Singleplayer world the server.jar will be spawned on your computer.
Despite using the same files, lags don’t occur with singleplayer: on your machine client and server code communicate using actual wires in your computer making it likely impossible of bad persisted states on the server as updates are instant.
LAN connections
Section titled “LAN connections”You can open your world to LAN connections and the server.jar on your computer will behave the same way for Multiplayer on a remote one. That’s possible beacuse the file is literally the same you would run on a remote machine.
Other players from the same network, can join to your world using the Multiplayer menu inserting the LAN address as the server address.
If players are not on your network, port forwarding is required so the server can communicate with clients over the Internet.
In the end the main difference between Singleplayer and Multiplayer game architecture is where the server.jar file is running.