Skip to content

Fix incorrect lighting between chunks - #4292

Open
willymv wants to merge 3 commits into
webbukkit:v3.0-community-editionfrom
willymv:fix/chunk-section-lighting
Open

willymv wants to merge 3 commits into
webbukkit:v3.0-community-editionfrom
willymv:fix/chunk-section-lighting

Conversation

@willymv

@willymv willymv commented Nov 6, 2026 •

Copy link
Copy Markdown

Fixes two causes for Dynmap to incorrectly run the generateSky() method in the GenericMapChunkCache class.

// Assume skylight is only trustworthy in a lit state
if ((!hasLitState) || (!lit)) {
hasLight = false;
}
// If no light, do simple generate
if (!hasLight) {
//Log.info(String.format("generateSky(%d,%d)", x, z));
bld.generateSky();
}

Issues

hasLitState

  • Chunks from roughly 1.20 onwards have the "minecraft:" prefix in their chunk status causing the if (status.equals(litState)) to always fail and for hasLitState to stay false.

lit

  • Chunks with starlight lighting data always have their "isLightOn" value set to false causing lit to always be false. Starlight data is in chunks from versions of Paper servers of 1.18 onwards and for Fabric servers that use the Starlight mod (Less common scenario than Paper as the Starlight mod has been discontinued for awhile).

Fixes

  • Add modern chunk status to litStates. Allowing the hasLitState check to accurately represent the lighting state of modern chunks. This change resolves the issue for all platforms and versions supported by Dynmap from roughly 1.20 and newer.
  • Add a check to see if a chunk contains Starlight data and override the isLightOn value if it does. Resolves the issue for Paper chunks >1.18 and Fabric chunks from a server/client with the starlight mod.

Example image
beforevsaftershadowfix

Notes

  • Lighting will still render 'incorrectly' if the lighting is actually incorrect in the chunk data. e.g A world pregenerated with Chunky on Spigot has a lot of this going on.
  • Doesn't fix the generateSky() method not handling lighting between neighbouring chunks correctly.

@willymv
willymv marked this pull request as ready for review November 8, 2026 11:22
@willymv
willymv requested a review from a team November 8, 2026 11:22

@taranovegor taranovegor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of thoughts:

  1. The condition can be simpler. Could be fold the light check into lit right where it's read: boolean lit = nbt.getBoolean("isLightOn") || orignbt.contains("starlight.light_version");.
  2. I'm curious what the border between an old chunk and a new one looks like after this. By old I mean a chunk that still gets the generated sky light, and by new one that now uses its real light data. A screenshot of a spot like that would help.
  3. This isn't Paper-only. Because of the prefix change, Fabric and Forge on 1.20.5 and newer will also start using real skylight instead of the generated one, so it needs testing there too.

Overall the change LGTM. The part that makes me a bit cautious is that it changes how every map renders.

@willymv

willymv commented Nov 19, 2026

Copy link
Copy Markdown
Author

Thank you

  1. Definitely a lot cleaner doing it this way, I've fixed this up now.
  2. I'm struggling to think of examples of this other than the edges of pre-generated worlds where things can be a bit weird sometimes as chunks are often not fully generated (they don't pass the hasLitState check). Below is the nether on Fabric 1.21.11 after the fix. It renders the same as before the fix. Paper is similar before and after expect it goes directly from light level 0 to 15 and Forge for whatever reason renders as correctly lit. I'll do more testing and see if I can force some edge cases.
netheredge
  1. My bad on this, I have done a decent amount of testing across the versions. I just completely forgot to say it. When I set this as no longer a draft I had tested the following with all dimensions and default dynmap settings: Fabric, Paper Spigot 1.16.5, Fabric, Paper, Spigot 1.21.11, Forge 26.1 and Fabric, Paper Spigot 26.3. All of which don't seem to have any new problems.

Being cautious is probably the right move. I've also cleaned up the PR description a bit. I'll get back to doing more testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants