2

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?

  • I don't know what kind of answer you will get here for this. I have the same understanding though I don't know the answer for sure. Do you have discord? – IronAnvil Jan 30 '18 at 0:24
  • @IronAnvil unfortunately I don't have discord. I will try reading through the code to see if I am right, however I might not get the answer for a while. – Grant Garrison Jan 30 '18 at 0:39
3

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)

  • This was pretty close to what I was thinking it was. Does this mean that if I changed a block (using bukkit) like redstone repeaters to not emit light server side, it would remove client side lag? (From BLUs) – Grant Garrison Jan 30 '18 at 13:07
  • 1
    Myrean Eario has a video that abuses lighting updates to generate server lag so that he can show something in slow-motion without having low FPS. Yes, it will probably save a little bit of client lag, but much more on the server. – Fabian Röling Jan 30 '18 at 13:15
  • Update for 1.14: The lighting system was changed a lot. I don't know how much of this answer still applies. – Fabian Röling Apr 28 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.