MineKhan icon indicating copy to clipboard operation
MineKhan copied to clipboard

Lighting Crash

Open ghost opened this issue 3 years ago • 15 comments

So I was playing minekhan on willard.fun. Then everything went blank. Here is a screenshot: MineKhan - Google Chrome 7_8_2021 8_42_55 PM

ghost avatar Jul 09 '21 03:07 ghost

Was someone else in the world? I wrapped it in a try-catch to stop it from freezing from that multiplayer lighting bug, but that happens instead, so it's not a great fix lol.

Willard21 avatar Jul 09 '21 11:07 Willard21

I wasn't in multiplayer.

ghost avatar Jul 09 '21 19:07 ghost

Oh. Were you building at the edge of ungenerated chunks or something then? 🤔

Willard21 avatar Jul 09 '21 20:07 Willard21

I was playing around with slabs and it was nowhere near ungenerated chunks.

ghost avatar Jul 09 '21 21:07 ghost

There were also some dropped items but they were really far away.

ghost avatar Jul 09 '21 21:07 ghost

It's prob willard. as herobrine

ghost avatar Jul 10 '21 18:07 ghost

I just joined a multiplayer world and everything was blank. It looks like the same thing as the screenshot above.

ghost avatar Jul 14 '21 19:07 ghost

I think I found out how to reproduce this bug but its not quite right. EDIT: I think this is actually another bug.

  1. So make a 3x3 square above the ground.
  2. Put a upside-down slab on one edge (not the corner)
  3. Throw an item in the middle of the square.
  4. If the item falls through the square, you did it right
  5. Wait
  6. Everything goes weird. So if you throw more items, There will be weird things going on.

Screenshot: Screenshot 2021-07-14 at 12 37 25 PM

ghost avatar Jul 14 '21 19:07 ghost

Actually if you throw an item at a bunch of upside-down slabs above the ground, it will also happen

ghost avatar Jul 14 '21 20:07 ghost

There are a lot of errors in the console.

ghost avatar Jul 14 '21 20:07 ghost

I think you need to change the getlight function. Just make it so if the y is less than 1, return 0.

ghost avatar Jul 14 '21 20:07 ghost

Can you send a small world save with reproduction steps? This bug has been around for awhile, but I've only experienced it myself in multiplayer, and only very sporadically, so I haven't been able to debug it to fix it.

Willard21 avatar Jul 14 '21 20:07 Willard21

I don't know how to reproduce the first bug. For the second bug, You just have to throw an item on an upside-down slab.

ghost avatar Jul 14 '21 21:07 ghost

I think this fixes the bug:

getLight(x, y, z, blockLight = 0) {
	if(y < 1) return 0 //<= that
	let X = (x >> 4) + this.offsetX
	let Z = (z >> 4) + this.offsetZ
	if (X < 0 || X >= this.lwidth || Z < 0 || Z >= this.lwidth) {
		return this.chunks[x >> 4][z >> 4].getLight(x & 15, y, z & 15, blockLight)
	}
	return this.loaded[X * this.lwidth + Z].getLight(x & 15, y, z & 15, blockLight)
}

Putting this in the console can also fix it:

world.__proto__.getLight = function(t,e,r,n=0){
if(e<1) return 0;
var o=(t>>4)+this.offsetX,i=(r>>4)+this.offsetZ;return(o<0||o>=this.lwidth||i<0||i>=this.lwidth?this.chunks[t>>4][r>>4]:this.loaded[o*this.lwidth+i]).getLight(15&t,e,15&r,n)}

ghost avatar Jul 14 '21 21:07 ghost

Ummm, what?

Blqtent avatar Jul 14 '21 23:07 Blqtent

Reading over this again, it appears the crash was caused by dropped items outside rendered chunks. As dropped items are gone, this shouldn't be an issue any more. Hopefully.

Willard21 avatar Apr 14 '23 17:04 Willard21