mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-13 11:18:23 +01:00
SPIGOT-1753: ChunkGenerator lighting updates
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
parent
f294d260b8
commit
353c9f5090
2 changed files with 17 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue