mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Create light packet slightly more dynamically.
This commit is contained in:
parent
4d5f8cf468
commit
9de6c5aa8f
@ -385,20 +385,30 @@ public abstract class Chunk implements Viewable, Tickable, DataContainer {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public UpdateLightPacket getLightPacket() {
|
public UpdateLightPacket getLightPacket() {
|
||||||
// TODO do not hardcode light
|
// TODO do not hardcode light
|
||||||
|
|
||||||
|
// Creates a light packet for the given number of sections with all block light at max and no sky light.
|
||||||
UpdateLightPacket updateLightPacket = new UpdateLightPacket(getIdentifier(), getLastChangeTime());
|
UpdateLightPacket updateLightPacket = new UpdateLightPacket(getIdentifier(), getLastChangeTime());
|
||||||
updateLightPacket.chunkX = getChunkX();
|
updateLightPacket.chunkX = getChunkX();
|
||||||
updateLightPacket.chunkZ = getChunkZ();
|
updateLightPacket.chunkZ = getChunkZ();
|
||||||
//updateLightPacket.skyLightMask = 0b111111111111111111;
|
|
||||||
//updateLightPacket.emptySkyLightMask = 0b000000000000000000;
|
final int sectionCount = 16 + 2; //todo
|
||||||
//updateLightPacket.blockLightMask = 0b000000000000000000;
|
final int maskLength = (int) Math.ceil((double) sectionCount / 64);
|
||||||
//updateLightPacket.emptyBlockLightMask = 0b111111111111111111;
|
|
||||||
|
updateLightPacket.skyLightMask = new long[maskLength];
|
||||||
|
updateLightPacket.blockLightMask = new long[maskLength];
|
||||||
|
updateLightPacket.emptySkyLightMask = new long[maskLength];
|
||||||
|
updateLightPacket.emptyBlockLightMask = new long[maskLength];
|
||||||
|
// Set all block light and no sky light
|
||||||
|
Arrays.fill(updateLightPacket.blockLightMask, -1L);
|
||||||
|
Arrays.fill(updateLightPacket.emptySkyLightMask, -1L);
|
||||||
|
|
||||||
byte[] bytes = new byte[2048];
|
byte[] bytes = new byte[2048];
|
||||||
Arrays.fill(bytes, (byte) 0xFF);
|
Arrays.fill(bytes, (byte) 0xFF);
|
||||||
final List<byte[]> temp = new ArrayList<>(18);
|
final List<byte[]> temp = new ArrayList<>(sectionCount);
|
||||||
for (int i = 0; i < 18; ++i) {
|
for (int i = 0; i < sectionCount; ++i) {
|
||||||
temp.add(bytes);
|
temp.add(bytes);
|
||||||
}
|
}
|
||||||
//updateLightPacket.skyLight = temp;
|
updateLightPacket.blockLight = temp;
|
||||||
return updateLightPacket;
|
return updateLightPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user