Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
54 Zeilen
2.9 KiB
Diff
54 Zeilen
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Mon, 23 Aug 2021 04:50:05 -0700
|
|
Subject: [PATCH] Always parse protochunk light sources unless it is marked as
|
|
non-lit
|
|
|
|
Chunks not marked as lit will always go through the light engine,
|
|
so they should always have their block sources parsed.
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
|
index ad4081efec9c7eaf315ddb660f813f6ef3cfbb5b..7921ee2786d0d6a60d43786b20efc03a0f9178e3 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
|
@@ -267,16 +267,33 @@ public class ChunkSerializer {
|
|
protochunk.setLightEngine(lightengine);
|
|
}
|
|
|
|
- if (!flag && protochunk.getStatus().isOrAfter(ChunkStatus.LIGHT)) {
|
|
- Iterator iterator = BlockPos.betweenClosed(pos.getMinBlockX(), world.getMinBuildHeight(), pos.getMinBlockZ(), pos.getMaxBlockX(), world.getMaxBuildHeight() - 1, pos.getMaxBlockZ()).iterator();
|
|
+ if (!flag) { // Paper - fix incorrect parsing of blocks that emit light - it should always parse it, unless the chunk is marked as lit
|
|
+ // Paper start - let's make sure the implementation isn't as slow as possible
|
|
+ int offX = pos.x << 4;
|
|
+ int offZ = pos.z << 4;
|
|
+
|
|
+ int minChunkSection = io.papermc.paper.util.WorldUtil.getMinSection(world);
|
|
+ int maxChunkSection = io.papermc.paper.util.WorldUtil.getMaxSection(world);
|
|
+
|
|
+ LevelChunkSection[] sections = achunksection;
|
|
+ for (int sectionY = minChunkSection; sectionY <= maxChunkSection; ++sectionY) {
|
|
+ LevelChunkSection section = sections[sectionY - minChunkSection];
|
|
+ if (section == null || section.isEmpty()) {
|
|
+ // no sources in empty sections
|
|
+ continue;
|
|
+ }
|
|
+ int offY = sectionY << 4;
|
|
|
|
- while (iterator.hasNext()) {
|
|
- BlockPos blockposition = (BlockPos) iterator.next();
|
|
+ for (int index = 0; index < (16 * 16 * 16); ++index) {
|
|
+ if (section.states.get(index).getLightEmission() <= 0) {
|
|
+ continue;
|
|
+ }
|
|
|
|
- if (((ChunkAccess) object).getBlockState(blockposition).getLightEmission() != 0) {
|
|
- protochunk.addLight(blockposition);
|
|
+ // index = x | (z << 4) | (y << 8)
|
|
+ protochunk.addLight(new BlockPos(offX | (index & 15), offY | (index >>> 8), offZ | ((index >>> 4) & 15)));
|
|
}
|
|
}
|
|
+ // Paper end
|
|
}
|
|
}
|
|
|