iam fix to lighting

(cherry picked from commit 8ff6339365)
This commit is contained in:
mworzala 2023-06-10 19:09:35 -04:00 committed by Matt Worzala
parent 3408df73f8
commit 2f6941c68e
3 changed files with 8 additions and 6 deletions

View File

@ -62,7 +62,7 @@ public final class MinecraftServer {
// In-Game Manager
private static volatile ServerProcess serverProcess;
private static int chunkViewDistance = Integer.getInteger("minestom.chunk-view-distance", 8);
private static int chunkViewDistance = Integer.getInteger("minestom.chunk-view-distance", 32);
private static int entityViewDistance = Integer.getInteger("minestom.entity-view-distance", 5);
private static int compressionThreshold = 256;
private static boolean terminalEnabled = System.getProperty("minestom.terminal.disabled") == null;

View File

@ -22,6 +22,8 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import static net.minestom.server.instance.light.LightCompute.emptyContent;
public class LightingChunk extends DynamicChunk {
private int[] heightmap;
final CachedPacket lightCache = new CachedPacket(this::createLightPacket);
@ -169,7 +171,7 @@ public class LightingChunk extends DynamicChunk {
// System.out.println("Relit sky: " + wasUpdatedSky + " block: " + wasUpdatedBlock + " for section " + (index + minSection) + " in chunk " + chunkX + " " + chunkZ);
if ((wasUpdatedSky || sendAll) && this.instance.getDimensionType().isSkylightEnabled()) {
if ((wasUpdatedSky || (sendAll && skyLight != emptyContent)) && this.instance.getDimensionType().isSkylightEnabled()) {
if (skyLight.length != 0) {
skyLights.add(skyLight);
skyMask.set(index);
@ -178,7 +180,7 @@ public class LightingChunk extends DynamicChunk {
}
}
if (wasUpdatedBlock || sendAll) {
if (wasUpdatedBlock || (sendAll && blockLight != emptyContent)) {
if (blockLight.length != 0) {
blockLights.add(blockLight);
blockMask.set(index);

View File

@ -12,14 +12,14 @@ import java.util.Objects;
import static net.minestom.server.instance.light.BlockLight.buildInternalQueue;
final class LightCompute {
public final class LightCompute {
static final BlockFace[] FACES = BlockFace.values();
static final int LIGHT_LENGTH = 16 * 16 * 16 / 2;
static final int SIDE_LENGTH = 16 * 16;
static final int SECTION_SIZE = 16;
private static final byte[][] emptyBorders = new byte[FACES.length][SIDE_LENGTH];
static final byte[] emptyContent = new byte[LIGHT_LENGTH];
public static final byte[][] emptyBorders = new byte[FACES.length][SIDE_LENGTH];
public static final byte[] emptyContent = new byte[LIGHT_LENGTH];
static @NotNull Result compute(Palette blockPalette) {
Block[] blocks = new Block[4096];