Fix incorrect light array reference.

Possibly fixes #531 and #535
This commit is contained in:
dordsor21 2020-07-24 20:21:05 +01:00
parent 28837c7106
commit d3ff4131a3
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -105,8 +105,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
return AdaptedMap.immutable(nmsTiles, posNms2We, nmsTile2We);
}
@Override
public int getSkyLight(int x, int y, int z) {
@Override public int getSkyLight(int x, int y, int z) {
int layer = y >> 4;
if (skyLight[layer] == null) {
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
@ -125,10 +124,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
return skyLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l)));
}
@Override
public int getEmmittedLight(int x, int y, int z) {
@Override public int getEmmittedLight(int x, int y, int z) {
int layer = y >> 4;
if (skyLight[layer] == null) {
if (blockLight[layer] == null) {
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition);
// If the server hasn't generated the section's NibbleArray yet, it will be null
@ -139,7 +137,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
nibbleArray = new NibbleArray(a);
((LightEngine) world.getChunkProvider().getLightEngine()).a(EnumSkyBlock.BLOCK, sectionPosition, nibbleArray, true);
}
skyLight[layer] = nibbleArray;
blockLight[layer] = nibbleArray;
}
long l = BlockPosition.a(x, y, z);
return blockLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l)));