SPIGOT-1753: ChunkGenerator lighting updates

This commit is contained in:
DerFrZocker 2021-07-23 16:43:53 +10:00 committed by md_5
parent 82f0955b3b
commit 64d149a5a9
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
2 changed files with 17 additions and 0 deletions

View File

@ -22,6 +22,7 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
private final int maxHeight;
private final ChunkSection[] sections;
private Set<BlockPosition> tiles;
private final Set<BlockPosition> lights = new HashSet<>();
public CraftChunkData(World world) {
this(world.getMinHeight(), world.getMaxHeight());
@ -149,6 +150,13 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
ChunkSection section = getChunkSection(y, true);
section.setType(x, y & 0xf, z, type);
// SPIGOT-1753: Capture light blocks, for light updates
if (type.f() > 0) { // PAIL rename getLightEmission
lights.add(new BlockPosition(x, y, z));
} else {
lights.remove(new BlockPosition(x, y, z));
}
if (type.isTileEntity()) {
if (tiles == null) {
tiles = new HashSet<>();
@ -174,4 +182,8 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
Set<BlockPosition> getTiles() {
return tiles;
}
Set<BlockPosition> getLights() {
return lights;
}
}

View File

@ -159,6 +159,11 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
}
}
}
// Apply captured light blocks
for (BlockPosition lightPosition : craftData.getLights()) {
((ProtoChunk) ichunkaccess).j(new BlockPosition((x << 4) + lightPosition.getX(), lightPosition.getY(), (z << 4) + lightPosition.getZ())); // PAIL rename addLightBlock
}
}
@Override