diff --git a/Spigot-Server-Patches/Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch b/Spigot-Server-Patches/Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch index 5503554a9..ed1c7a505 100644 --- a/Spigot-Server-Patches/Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch +++ b/Spigot-Server-Patches/Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch @@ -18,7 +18,7 @@ This change ensures the chunks are always loaded when entities are added to the world, or a valid entity moves between chunks. diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 763401835d..3379b68acb 100644 +index 4179ba7cd8..d659ffe9ba 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc diff --git a/Spigot-Server-Patches/Optimize-Light-Recalculations.patch b/Spigot-Server-Patches/Optimize-Light-Recalculations.patch index 5c49e9965..b34241b51 100644 --- a/Spigot-Server-Patches/Optimize-Light-Recalculations.patch +++ b/Spigot-Server-Patches/Optimize-Light-Recalculations.patch @@ -10,10 +10,22 @@ do not impact light calculations. So the only way light should change, is if the block itself changes from 1 block to another. +Also optimizes to not repeatedly look up the same chunk for +light lookups. + diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 53aab97866..e4bda70bb9 100644 +index 9162151e2a..651bb23be9 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java +@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { + private void a(int i, int j, int k, int l) { + if (l > k && this.areNeighborsLoaded(1)) { // Paper + for (int i1 = k; i1 < l; ++i1) { +- this.world.c(EnumSkyBlock.SKY, new BlockPosition(i, i1, j)); ++ this.world.updateBrightness(EnumSkyBlock.SKY, new BlockPosition(i, i1, j), this); // Paper + } + + this.x = true; @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { } else { if (flag1) { @@ -24,7 +36,7 @@ index 53aab97866..e4bda70bb9 100644 int i1 = iblockdata.b(this.world, blockposition); int j1 = iblockdata1.b(this.world, blockposition); diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 13f69f1b82..763401835d 100644 +index 13f69f1b82..4179ba7cd8 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc @@ -36,4 +48,28 @@ index 13f69f1b82..763401835d 100644 this.methodProfiler.a("checkLight"); chunk.runOrQueueLightUpdate(() -> this.r(blockposition)); // Paper - Queue light update this.methodProfiler.e(); +@@ -0,0 +0,0 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc + } + + if (this.worldProvider.g()) { +- for (i1 = k; i1 <= l; ++i1) { +- this.c(EnumSkyBlock.SKY, new BlockPosition(i, i1, j)); ++ Chunk chunk = getChunkIfLoaded(i >> 4, j >> 4); // Paper ++ for (i1 = k; chunk != null && i1 <= l; ++i1) { // Paper ++ this.updateBrightness(EnumSkyBlock.SKY, new BlockPosition(i, i1, j), chunk); // Paper + } + } + +@@ -0,0 +0,0 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc + public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) { + // CraftBukkit start - Use neighbor cache instead of looking up + Chunk chunk = this.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4); ++ // Paper start - optimize light updates where chunk is known ++ return updateBrightness(enumskyblock, blockposition, chunk); ++ } ++ public boolean updateBrightness(EnumSkyBlock enumskyblock, BlockPosition blockposition, Chunk chunk) { ++ // Paper end + if (chunk == null || !chunk.areNeighborsLoaded(1) /*!this.areChunksLoaded(blockposition, 17, false)*/) { + // CraftBukkit end + return false; -- \ No newline at end of file