2019-03-28 01:46:46 +01:00
|
|
|
From 74a659caa33a7279b1be97385ce24e7e55082a65 Mon Sep 17 00:00:00 2001
|
2018-09-29 03:30:03 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Fri, 28 Sep 2018 20:46:29 -0400
|
|
|
|
Subject: [PATCH] Optimize Light Recalculations
|
|
|
|
|
2019-03-28 01:46:46 +01:00
|
|
|
Optimizes to not repeatedly look up the same chunk for
|
2018-10-03 03:55:30 +02:00
|
|
|
light lookups.
|
|
|
|
|
2018-09-29 03:30:03 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
2019-03-28 01:46:46 +01:00
|
|
|
index fb00e7a9c..fabfc315c 100644
|
2018-09-29 03:30:03 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -353,7 +353,7 @@ public class Chunk implements IChunkAccess {
|
2018-10-03 03:55:30 +02:00
|
|
|
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;
|
2018-09-29 03:30:03 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2019-03-20 02:46:00 +01:00
|
|
|
index 739fbecac..739448d8b 100644
|
2018-09-29 03:30:03 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2019-02-03 16:34:04 +01:00
|
|
|
@@ -591,8 +591,9 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-10-03 03:55:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-03 16:34:04 +01:00
|
|
|
@@ -2228,6 +2229,11 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-10-03 03:55:30 +02:00
|
|
|
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;
|
2018-09-29 03:30:03 +02:00
|
|
|
--
|
2019-03-20 01:28:15 +01:00
|
|
|
2.21.0
|
2018-09-29 03:30:03 +02:00
|
|
|
|