From 288d8d3080a1074002fb9d76f7d699f5228686ab Mon Sep 17 00:00:00 2001 From: iam4722202468 Date: Wed, 7 Feb 2024 14:15:55 -0500 Subject: [PATCH] client doesn't work as expected --- .../minestom/server/instance/LightingChunk.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minestom/server/instance/LightingChunk.java b/src/main/java/net/minestom/server/instance/LightingChunk.java index e1e8628b2c9..0e9289bed50 100644 --- a/src/main/java/net/minestom/server/instance/LightingChunk.java +++ b/src/main/java/net/minestom/server/instance/LightingChunk.java @@ -195,6 +195,17 @@ protected LightData createLightData() { Set combined = new HashSet<>(); int chunkMin = instance.getDimensionType().getMinY(); + int highestRegionPoint = instance.getDimensionType().getMinY(); + for (int x = chunkX - 1; x <= chunkX + 1; x++) { + for (int z = chunkZ - 1; z <= chunkZ + 1; z++) { + Chunk chunk = instance.getChunk(x, z); + if (chunk instanceof LightingChunk light) { + light.getHeightmap(); + if (light.highestBlock > highestRegionPoint) highestRegionPoint = light.highestBlock; + } + } + } + int index = 0; for (Section section : sections) { boolean wasUpdatedBlock = false; @@ -222,7 +233,7 @@ protected LightData createLightData() { final byte[] blockLight = section.blockLight().array(); final int sectionMaxY = index * 16 + chunkMin; - if ((wasUpdatedSky) && this.instance.getDimensionType().isSkylightEnabled() && sectionMaxY <= (highestBlock + 16)) { + if ((wasUpdatedSky) && this.instance.getDimensionType().isSkylightEnabled() && sectionMaxY <= (highestRegionPoint + 16)) { if (skyLight.length != 0 && skyLight != emptyContent) { skyLights.add(skyLight); skyMask.set(index); @@ -355,8 +366,8 @@ private static Set getNearbyRequired(Instance instance, Point point, Ligh for (int y = point.blockY() - 1; y <= point.blockY() + 1; y++) { Point sectionPosition = new Vec(x, y, z); - int sectionHeight = instance.getDimensionType().getMinY() + 16 * y; - if ((sectionHeight + 16) > highestRegionPoint && type == LightType.SKY) continue; + // int sectionHeight = instance.getDimensionType().getMinY() + 16 * y; + // if ((sectionHeight + 16) > highestRegionPoint && type == LightType.SKY) continue; if (sectionPosition.blockY() < chunkCheck.getMaxSection() && sectionPosition.blockY() >= chunkCheck.getMinSection()) { Section s = chunkCheck.getSection(sectionPosition.blockY());