From 7c419073e4de76ab36d0366ae1e331dd079110a5 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Mon, 22 Jun 2020 21:17:28 -0400 Subject: [PATCH] Fix not running level updates for light if no pre/post task --- .../Optimize-Light-Engine.patch | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Spigot-Server-Patches/Optimize-Light-Engine.patch b/Spigot-Server-Patches/Optimize-Light-Engine.patch index 46acc7c520..6cf38f1f3d 100644 --- a/Spigot-Server-Patches/Optimize-Light-Engine.patch +++ b/Spigot-Server-Patches/Optimize-Light-Engine.patch @@ -1274,6 +1274,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + // Paper start - replace impl ++ private final java.util.List pre = new java.util.ArrayList<>(); ++ private final java.util.List post = new java.util.ArrayList<>(); private void b() { - int i = Math.min(this.c.size(), this.f); - ObjectListIterator> objectlistiterator = this.c.iterator(); @@ -1286,7 +1288,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (pair.getFirst() == LightEngineThreaded.Update.PRE_UPDATE) { - ((Runnable) pair.getSecond()).run(); - } -- } ++ int i = Math.min(queue.size(), 4); ++ boolean ran = false; ++ while (i-- > 0 && queue.poll(pre, post)) { ++ pre.forEach(Runnable::run); ++ pre.clear(); ++ super.a(Integer.MAX_VALUE, true, true); ++ post.forEach(Runnable::run); ++ post.clear(); ++ ran = true; + } - - objectlistiterator.back(j); - super.a(Integer.MAX_VALUE, true, true); @@ -1298,15 +1309,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - } - - objectlistiterator.remove(); -+ java.util.List pre = new java.util.ArrayList<>(); -+ java.util.List post = new java.util.ArrayList<>(); -+ int i = Math.min(queue.size(), 4); -+ while (i-- > 0 && queue.poll(pre, post)) { -+ pre.forEach(Runnable::run); -+ pre.clear(); ++ if (!ran) { ++ // might have level updates to go still + super.a(Integer.MAX_VALUE, true, true); -+ post.forEach(Runnable::run); -+ post.clear(); } - + // Paper end