mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Lighting:
- bring fixes to 1.16 - Fix for all lighting where it only set sky lighting if not present, even if it was trying to set block lighting (unlikely to have caused issues as block lighting seems always to be present, but wrong nonetheless)
This commit is contained in:
parent
3b19738ea0
commit
6be429cc96
@ -698,7 +698,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
|||||||
byte[] a = new byte[2048];
|
byte[] a = new byte[2048];
|
||||||
Arrays.fill(a, skyBlock == EnumSkyBlock.SKY ? (byte) 15 : (byte) 0);
|
Arrays.fill(a, skyBlock == EnumSkyBlock.SKY ? (byte) 15 : (byte) 0);
|
||||||
nibble = new NibbleArray(a);
|
nibble = new NibbleArray(a);
|
||||||
((LightEngine) world.getChunkProvider().getLightEngine()).a(EnumSkyBlock.SKY, sectionPosition, nibble);
|
((LightEngine) world.getChunkProvider().getLightEngine()).a(skyBlock, sectionPosition, nibble);
|
||||||
}
|
}
|
||||||
synchronized (nibble) {
|
synchronized (nibble) {
|
||||||
for (int i = 0; i < 4096; i++) {
|
for (int i = 0; i < 4096; i++) {
|
||||||
|
@ -716,7 +716,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
byte[] a = new byte[2048];
|
byte[] a = new byte[2048];
|
||||||
Arrays.fill(a, skyBlock == EnumSkyBlock.SKY ? (byte) 15 : (byte) 0);
|
Arrays.fill(a, skyBlock == EnumSkyBlock.SKY ? (byte) 15 : (byte) 0);
|
||||||
nibble = new NibbleArray(a);
|
nibble = new NibbleArray(a);
|
||||||
((LightEngine) world.getChunkProvider().getLightEngine()).a(EnumSkyBlock.SKY, sectionPosition, nibble);
|
((LightEngine) world.getChunkProvider().getLightEngine()).a(skyBlock, sectionPosition, nibble);
|
||||||
}
|
}
|
||||||
synchronized (nibble) {
|
synchronized (nibble) {
|
||||||
for (int i = 0; i < 4096; i++) {
|
for (int i = 0; i < 4096; i++) {
|
||||||
|
@ -43,8 +43,7 @@ import static org.slf4j.LoggerFactory.getLogger;
|
|||||||
|
|
||||||
public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(
|
private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_16_1.class);
|
||||||
BukkitGetBlocks_1_16_1.class);
|
|
||||||
|
|
||||||
private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
|
private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
|
||||||
private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_1(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_1(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||||
@ -110,7 +109,17 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
public int getSkyLight(int x, int y, int z) {
|
public int getSkyLight(int x, int y, int z) {
|
||||||
int layer = y >> 4;
|
int layer = y >> 4;
|
||||||
if (skyLight[layer] == null) {
|
if (skyLight[layer] == null) {
|
||||||
skyLight[layer] = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(SectionPosition.a(nmsChunk.getPos(), layer));
|
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||||
|
NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition);
|
||||||
|
// If the server hasn't generated the section's NibbleArray yet, it will be null
|
||||||
|
if (nibbleArray == null) {
|
||||||
|
byte[] a = new byte[2048];
|
||||||
|
// Safe enough to assume if it's not created, it's under the sky. Unlikely to be created before lighting is fixed anyway.
|
||||||
|
Arrays.fill(a, (byte) 15);
|
||||||
|
nibbleArray = new NibbleArray(a);
|
||||||
|
((LightEngine) world.getChunkProvider().getLightEngine()).a(EnumSkyBlock.SKY, sectionPosition, nibbleArray, true);
|
||||||
|
}
|
||||||
|
skyLight[layer] = nibbleArray;
|
||||||
}
|
}
|
||||||
long l = BlockPosition.a(x, y, z);
|
long l = BlockPosition.a(x, y, z);
|
||||||
return skyLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l)));
|
return skyLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l)));
|
||||||
@ -119,8 +128,18 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
@Override
|
@Override
|
||||||
public int getEmmittedLight(int x, int y, int z) {
|
public int getEmmittedLight(int x, int y, int z) {
|
||||||
int layer = y >> 4;
|
int layer = y >> 4;
|
||||||
if (blockLight[layer] == null) {
|
if (skyLight[layer] == null) {
|
||||||
blockLight[layer] = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(SectionPosition.a(nmsChunk.getPos(), layer));
|
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
|
||||||
|
if (nibbleArray == null) {
|
||||||
|
byte[] a = new byte[2048];
|
||||||
|
// Safe enough to assume if it's not created, it's under the sky. Unlikely to be created before lighting is fixed anyway.
|
||||||
|
Arrays.fill(a, (byte) 15);
|
||||||
|
nibbleArray = new NibbleArray(a);
|
||||||
|
((LightEngine) world.getChunkProvider().getLightEngine()).a(EnumSkyBlock.BLOCK, sectionPosition, nibbleArray, true);
|
||||||
|
}
|
||||||
|
skyLight[layer] = nibbleArray;
|
||||||
}
|
}
|
||||||
long l = BlockPosition.a(x, y, z);
|
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)));
|
return blockLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l)));
|
||||||
@ -286,7 +305,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
} else {
|
} else {
|
||||||
existingSection = sections[layer];
|
existingSection = sections[layer];
|
||||||
if (existingSection == null) {
|
if (existingSection == null) {
|
||||||
System.out.println("Skipping invalid null section. chunk:" + X + "," + Z + " layer: " + layer);
|
log.error("Skipping invalid null section. chunk:" + X + "," + Z + " layer: " + layer);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +334,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
.newChunkSection(layer, this::load, setArr, fastmode);
|
.newChunkSection(layer, this::load, setArr, fastmode);
|
||||||
if (!BukkitAdapter_1_16_1
|
if (!BukkitAdapter_1_16_1
|
||||||
.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
||||||
System.out.println("Failed to set chunk section:" + X + "," + Z + " layer: " + layer);
|
log.error("Failed to set chunk section:" + X + "," + Z + " layer: " + layer);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
||||||
@ -662,9 +681,13 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
if (light[Y] == null) {
|
if (light[Y] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NibbleArray nibble = world.getChunkProvider().getLightEngine().a(skyBlock).a(SectionPosition.a(nmsChunk.getPos(), Y));
|
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), Y);
|
||||||
|
NibbleArray nibble = world.getChunkProvider().getLightEngine().a(skyBlock).a(sectionPosition);
|
||||||
if (nibble == null) {
|
if (nibble == null) {
|
||||||
continue;
|
byte[] a = new byte[2048];
|
||||||
|
Arrays.fill(a, skyBlock == EnumSkyBlock.SKY ? (byte) 15 : (byte) 0);
|
||||||
|
nibble = new NibbleArray(a);
|
||||||
|
((LightEngine) world.getChunkProvider().getLightEngine()).a(skyBlock, sectionPosition, nibble, true);
|
||||||
}
|
}
|
||||||
synchronized (nibble) {
|
synchronized (nibble) {
|
||||||
for (int i = 0; i < 4096; i++) {
|
for (int i = 0; i < 4096; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user