mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 04:55:47 +01:00
9dc4d6448b
While it wasn't really "broken" before, if plugins use NMS (which they really should't be) and mess with entity management themselves, and get it wrong, they could ultimately corrupt our state expectations. I've been unable to reproduce any issues locally, but these changes are the result of me analyzing the code pretty deeply and seeing about how to make it more durable to abnormal usage. Any servers seeing oddities, please run with -Ddebug.entities=true and send me any logs triggered.
53 lines
2.5 KiB
Diff
53 lines
2.5 KiB
Diff
From 722c4b837cfcb6db6ac546e4d3952b9552d7a56d Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Fri, 28 Sep 2018 20:46:29 -0400
|
|
Subject: [PATCH] Optimize Light Recalculations
|
|
|
|
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 4f64072a7b..966879a894 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -353,7 +353,7 @@ 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;
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 97a0fbd55c..fb71879ac0 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -591,8 +591,9 @@ 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
|
|
}
|
|
}
|
|
|
|
@@ -2220,6 +2221,11 @@ 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;
|
|
--
|
|
2.21.0
|
|
|