How/where is Minecraft lighting handled?

How/where is lighting handled with a vanilla Minecraft server and client? My current understanding of lighting is that the server would store the block's light in the block data, then send this to the client for rendering. Is this correct?


Solution 1:

Yes, it's server-side and also saved to file. It has to be server-side, because it determines where mobs spawn, crops grow, etc.

That's also why lighting bugs often persist relogging and only get fixed when placing/removing/blocking/unblocking a light source.

Sunlight is saved in two-dimensional matrices that include the height of highest opaque block in every column. Block light is stored per block. The total light gets calculated from both sources at runtime. Nothing is saved in the block data, because that would require every block to be a block entity, which would be very laggy. Instead it's a separate system.

The client then uses these light levels, together with their source (block or sun), the time of day (evening is more red than noon) and your brightness setting to determine which colour and brightness to apply when rendering the blocks and entities.

(wiki page about light, archive)