Paper/patches/server/0751-Always-parse-protochunk-light-sources-unless-it-is-m.patch
Jake Potrebic 9147456fc9
Updated Upstream (CraftBukkit/Spigot) (#8815)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

CraftBukkit Changes:
ab8ace685 SPIGOT-7236: Bone meal doesn't increase use statistic
7dcb59b8e Avoid switch on material in previous commit

Spigot Changes:
19641c75 SPIGOT-7235: World.Spigot#strikeLightningEffect doesn't do anything
2023-01-27 12:52:04 -08:00

54 lines
3.1 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 313a3319c630a4f26f9c53255a0ac67f3c15e410..d4c4d37bcef14e392739d9aae9e20b7d69b05c12 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
@@ -327,16 +327,33 @@ public class ChunkSerializer {
BelowZeroRetrogen belowzeroretrogen = protochunk.getBelowZeroRetrogen();
boolean flag5 = chunkstatus.isOrAfter(ChunkStatus.LIGHT) || belowzeroretrogen != null && belowzeroretrogen.targetStatus().isOrAfter(ChunkStatus.LIGHT);
- if (!flag && flag5) {
- Iterator iterator = BlockPos.betweenClosed(chunkPos.getMinBlockX(), world.getMinBuildHeight(), chunkPos.getMinBlockZ(), chunkPos.getMaxBlockX(), world.getMaxBuildHeight() - 1, chunkPos.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 = chunkPos.x << 4;
+ int offZ = chunkPos.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.hasOnlyAir()) {
+ // 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) object1).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
}
}