MineKhan icon indicating copy to clipboard operation
MineKhan copied to clipboard

How to fix lighting bug

Open ghost opened this issue 2 years ago • 1 comments

There is a lighting bug that makes blocks dark when you build too high. Here is how to fix it: Find updateLight function. Add this code inside:

if(place){ //set vertical column to 15
  let spread = []
  for(let x2 = x-1; x2 <= x+1; x2++) for(let z2 = z-1; z2 <= z+1; z2++){
    //spread around side too so the sides won't get dark
    let i = chunk.sections.length * 16 - 1
    let cx2 = x2 & 15, cz2 = z2 & 15
    for(; i >= 0; i--){
      if(!blockData[chunk.getBlock(cx2,i,cz2)].transparent) break
      if(chunk.getLight(cx2,i,cz2,0) !== 15){
        chunk.setLight(cx2,i,cz2,15,0)
        spread.push(x2,i,z2)
      }
    }
  }
  if(spread.length) chunk.spreadLight(spread, 14, true)
}

ghost avatar Sep 20 '22 23:09 ghost

this should be a pull request

harsha7addanki avatar Oct 20 '22 19:10 harsha7addanki

Pretty sure this is fixed now. I think the issue was new subchunks being generated with no light in them, but I've deleted subchunks now, so no longer an issue.

Willard21 avatar Apr 14 '23 16:04 Willard21