Environment
Minecraft code always runs on two environments: Client and Server.
Most of Minecraft logic is handled on the server so clients cannot alter Minecraft features (preventing cheats) and clients are also more lightweight. Game logic is piloted by the server that communicates states to the clients. Clients are more of a interface for players and just send to the server player actions 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.
Singleplayer
Section titled “Singleplayer”Since 12w18a
snapshot singleplayer game uses the same architecture of multiplayer with Client and Server.
When you enter a singleplayer world the server engine will be spawned on your machine instead of a remote one.
This infrastructure allows Minecraft code to be the same for singleplayer and multiplayer therefore smaller bundles sizes and easier for Minecraft developers to maintain.
(Before 12w18a
snapshot singleplayer code was a separated jar file with the same exact features of multiplayer game mode)
Despite having the same architecture lags don’t occur with singleplayer: on your machine client and server code communicate using actual wires in your computer and not and Internet connection making it likely impossible of bad persisted states on the server as updates are instant.
You can open your world to LAN connections (from the in game menù) and the server on your machine will behave the same way for multiplayer on a remote one, so other players can join to your world with the multiplayer menu using a LAN address.
If the players are not on your network, port forwarding is required so the server can communicate with clients over the Internet.
In the end the only difference between singleplayer and multiplayer game architecture is the place the server is running.