mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-15 20:02:01 +01:00
fix full light data is not sent (#2191)
* fix full light data is not sent * remove fullLightCache
This commit is contained in:
parent
a909985d8e
commit
0f81bc31ff
@ -264,15 +264,15 @@ public class DynamicChunk extends Chunk {
|
|||||||
|
|
||||||
return new ChunkDataPacket(chunkX, chunkZ,
|
return new ChunkDataPacket(chunkX, chunkZ,
|
||||||
new ChunkData(heightmapsNBT, data, entries),
|
new ChunkData(heightmapsNBT, data, entries),
|
||||||
createLightData()
|
createLightData(true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull UpdateLightPacket createLightPacket() {
|
@NotNull UpdateLightPacket createLightPacket() {
|
||||||
return new UpdateLightPacket(chunkX, chunkZ, createLightData());
|
return new UpdateLightPacket(chunkX, chunkZ, createLightData(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LightData createLightData() {
|
protected LightData createLightData(boolean requiredFullChunk) {
|
||||||
BitSet skyMask = new BitSet();
|
BitSet skyMask = new BitSet();
|
||||||
BitSet blockMask = new BitSet();
|
BitSet blockMask = new BitSet();
|
||||||
BitSet emptySkyMask = new BitSet();
|
BitSet emptySkyMask = new BitSet();
|
||||||
|
@ -37,8 +37,9 @@ public class LightingChunk extends DynamicChunk {
|
|||||||
private static final ExecutorService pool = Executors.newWorkStealingPool();
|
private static final ExecutorService pool = Executors.newWorkStealingPool();
|
||||||
|
|
||||||
private int[] occlusionMap;
|
private int[] occlusionMap;
|
||||||
final CachedPacket lightCache = new CachedPacket(this::createLightPacket);
|
final CachedPacket partialLightCache = new CachedPacket(this::createLightPacket);
|
||||||
private LightData lightData;
|
private LightData partialLightData;
|
||||||
|
private LightData fullLightData;
|
||||||
|
|
||||||
private int highestBlock;
|
private int highestBlock;
|
||||||
private boolean freezeInvalidation = false;
|
private boolean freezeInvalidation = false;
|
||||||
@ -86,9 +87,10 @@ public class LightingChunk extends DynamicChunk {
|
|||||||
);
|
);
|
||||||
|
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
this.lightCache.invalidate();
|
this.partialLightCache.invalidate();
|
||||||
this.chunkCache.invalidate();
|
this.chunkCache.invalidate();
|
||||||
this.lightData = null;
|
this.partialLightData = null;
|
||||||
|
this.fullLightData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LightingChunk(@NotNull Instance instance, int chunkX, int chunkZ) {
|
public LightingChunk(@NotNull Instance instance, int chunkX, int chunkZ) {
|
||||||
@ -160,13 +162,13 @@ public class LightingChunk extends DynamicChunk {
|
|||||||
if (doneInit && !freezeInvalidation) {
|
if (doneInit && !freezeInvalidation) {
|
||||||
invalidateNeighborsSection(coordinate);
|
invalidateNeighborsSection(coordinate);
|
||||||
invalidateResendDelay();
|
invalidateResendDelay();
|
||||||
this.lightCache.invalidate();
|
this.partialLightCache.invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendLighting() {
|
public void sendLighting() {
|
||||||
if (!isLoaded()) return;
|
if (!isLoaded()) return;
|
||||||
sendPacketToViewers(lightCache);
|
sendPacketToViewers(partialLightCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -235,11 +237,18 @@ public class LightingChunk extends DynamicChunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LightData createLightData() {
|
protected LightData createLightData(boolean requiredFullChunk) {
|
||||||
packetGenerationLock.lock();
|
packetGenerationLock.lock();
|
||||||
if (lightData != null) {
|
if (requiredFullChunk) {
|
||||||
packetGenerationLock.unlock();
|
if (fullLightData != null) {
|
||||||
return lightData;
|
packetGenerationLock.unlock();
|
||||||
|
return fullLightData;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (partialLightData != null) {
|
||||||
|
packetGenerationLock.unlock();
|
||||||
|
return partialLightData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BitSet skyMask = new BitSet();
|
BitSet skyMask = new BitSet();
|
||||||
@ -271,14 +280,14 @@ public class LightingChunk extends DynamicChunk {
|
|||||||
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 (requiredFullChunk || 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 (requiredFullChunk || section.skyLight().requiresSend()) {
|
||||||
wasUpdatedSky = true;
|
wasUpdatedSky = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,13 +317,19 @@ public class LightingChunk extends DynamicChunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lightData = new LightData(skyMask, blockMask,
|
LightData lightData = new LightData(skyMask, blockMask,
|
||||||
emptySkyMask, emptyBlockMask,
|
emptySkyMask, emptyBlockMask,
|
||||||
skyLights, blockLights);
|
skyLights, blockLights);
|
||||||
|
|
||||||
|
if (requiredFullChunk) {
|
||||||
|
this.fullLightData = lightData;
|
||||||
|
} else {
|
||||||
|
this.partialLightData = lightData;
|
||||||
|
}
|
||||||
|
|
||||||
packetGenerationLock.unlock();
|
packetGenerationLock.unlock();
|
||||||
|
|
||||||
return this.lightData;
|
return lightData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user