mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-14 03:11:25 +01:00
hollow-cube/lighting-join-patch (#56)
This commit is contained in:
parent
e2efdbb427
commit
010fe985bb
@ -165,64 +165,66 @@ public class LightingChunk extends DynamicChunk {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LightData createLightData(boolean sendLater) {
|
protected LightData createLightData(boolean sendLater) {
|
||||||
BitSet skyMask = new BitSet();
|
synchronized (lightCache) {
|
||||||
BitSet blockMask = new BitSet();
|
BitSet skyMask = new BitSet();
|
||||||
BitSet emptySkyMask = new BitSet();
|
BitSet blockMask = new BitSet();
|
||||||
BitSet emptyBlockMask = new BitSet();
|
BitSet emptySkyMask = new BitSet();
|
||||||
List<byte[]> skyLights = new ArrayList<>();
|
BitSet emptyBlockMask = new BitSet();
|
||||||
List<byte[]> blockLights = new ArrayList<>();
|
List<byte[]> skyLights = new ArrayList<>();
|
||||||
|
List<byte[]> blockLights = new ArrayList<>();
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (Section section : sections) {
|
for (Section section : sections) {
|
||||||
boolean wasUpdatedBlock = false;
|
boolean wasUpdatedBlock = false;
|
||||||
boolean wasUpdatedSky = false;
|
boolean wasUpdatedSky = false;
|
||||||
|
|
||||||
if (section.blockLight().requiresUpdate()) {
|
if (section.blockLight().requiresUpdate()) {
|
||||||
relightSection(instance, this.chunkX, index + minSection, chunkZ, LightType.BLOCK);
|
relightSection(instance, this.chunkX, index + minSection, chunkZ, LightType.BLOCK);
|
||||||
wasUpdatedBlock = true;
|
wasUpdatedBlock = true;
|
||||||
} else if (section.blockLight().requiresSend()) {
|
} else if (section.blockLight().requiresSend()) {
|
||||||
wasUpdatedBlock = true;
|
wasUpdatedBlock = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (section.skyLight().requiresUpdate()) {
|
if (section.skyLight().requiresUpdate()) {
|
||||||
relightSection(instance, this.chunkX, index + minSection, chunkZ, LightType.SKY);
|
relightSection(instance, this.chunkX, index + minSection, chunkZ, LightType.SKY);
|
||||||
wasUpdatedSky = true;
|
wasUpdatedSky = true;
|
||||||
} else if (section.skyLight().requiresSend()) {
|
} else if (section.skyLight().requiresSend()) {
|
||||||
wasUpdatedSky = true;
|
wasUpdatedSky = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
final byte[] skyLight = section.skyLight().array();
|
final byte[] skyLight = section.skyLight().array();
|
||||||
final byte[] blockLight = section.blockLight().array();
|
final byte[] blockLight = section.blockLight().array();
|
||||||
|
|
||||||
if ((wasUpdatedSky || sendLater) && this.instance.getDimensionType().isSkylightEnabled()) {
|
if ((wasUpdatedSky || sendLater) && this.instance.getDimensionType().isSkylightEnabled()) {
|
||||||
if (skyLight.length != 0 && skyLight != emptyContent) {
|
if (skyLight.length != 0 && skyLight != emptyContent) {
|
||||||
skyLights.add(skyLight);
|
skyLights.add(skyLight);
|
||||||
skyMask.set(index);
|
skyMask.set(index);
|
||||||
} else {
|
} else {
|
||||||
emptySkyMask.set(index);
|
emptySkyMask.set(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wasUpdatedBlock || sendLater) {
|
||||||
|
if (blockLight.length != 0 && blockLight != emptyContent) {
|
||||||
|
blockLights.add(blockLight);
|
||||||
|
blockMask.set(index);
|
||||||
|
} else {
|
||||||
|
emptyBlockMask.set(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wasUpdatedBlock || sendLater) {
|
if (sendNeighbours) {
|
||||||
if (blockLight.length != 0 && blockLight != emptyContent) {
|
updateAfterGeneration(this);
|
||||||
blockLights.add(blockLight);
|
sendNeighbours = false;
|
||||||
blockMask.set(index);
|
|
||||||
} else {
|
|
||||||
emptyBlockMask.set(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (sendNeighbours) {
|
return new LightData(skyMask, blockMask,
|
||||||
updateAfterGeneration(this);
|
emptySkyMask, emptyBlockMask,
|
||||||
sendNeighbours = false;
|
skyLights, blockLights);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LightData(skyMask, blockMask,
|
|
||||||
emptySkyMask, emptyBlockMask,
|
|
||||||
skyLights, blockLights);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final LongSet queuedChunks = new LongOpenHashSet();
|
private static final LongSet queuedChunks = new LongOpenHashSet();
|
||||||
@ -412,10 +414,10 @@ public class LightingChunk extends DynamicChunk {
|
|||||||
Chunk c = instance.getChunk(chunkX, chunkZ);
|
Chunk c = instance.getChunk(chunkX, chunkZ);
|
||||||
if (c == null) return;
|
if (c == null) return;
|
||||||
|
|
||||||
Set<Point> collected = collectRequiredNearby(instance, new Vec(chunkX, sectionY, chunkZ));
|
|
||||||
// System.out.println("Calculating " + chunkX + " " + sectionY + " " + chunkZ + " | " + collected.size() + " | " + type);
|
|
||||||
|
|
||||||
synchronized (instance) {
|
synchronized (instance) {
|
||||||
|
Set<Point> collected = collectRequiredNearby(instance, new Vec(chunkX, sectionY, chunkZ));
|
||||||
|
// System.out.println("Calculating " + chunkX + " " + sectionY + " " + chunkZ + " | " + collected.size() + " | " + type);
|
||||||
|
|
||||||
relight(instance, collected, type);
|
relight(instance, collected, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user