MineKhan
MineKhan copied to clipboard
How to fix lighting bug
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)
}
this should be a pull request
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.