Make the recheckGaps method async like other lighting updates

This commit is contained in:
Byteflux 2015-08-04 15:44:54 -07:00
parent eaaf2c2cf3
commit c38e8ec349
2 changed files with 44 additions and 7 deletions

View File

@ -1,11 +1,11 @@
From d07732a069908d93da75d3a248da456f696dd8a8 Mon Sep 17 00:00:00 2001
From 91555b67e652b6e5797f45ddc4090b0f01f81371 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Wed, 1 Jul 2015 00:18:10 -0700
Subject: [PATCH] Configurable async light updates
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 7242d45..ab4de94 100644
index 7242d45..5a3b22a 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -11,6 +11,8 @@ import java.util.Map;
@ -37,6 +37,39 @@ index 7242d45..ab4de94 100644
}
this.q = true;
@@ -1044,7 +1050,7 @@ public class Chunk {
public void b(boolean flag) {
if (this.k && !this.world.worldProvider.o() && !flag) {
- this.h(this.world.isClientSide);
+ this.recheckGaps(this.world.isClientSide); // PaperSpigot - Asynchronous lighting updates
}
this.p = true;
@@ -1065,6 +1071,23 @@ public class Chunk {
}
+ /**
+ * PaperSpigot - Recheck gaps asynchronously.
+ */
+ public void recheckGaps(final boolean isClientSide) {
+ if (!world.paperSpigotConfig.useAsyncLighting) {
+ this.h(isClientSide);
+ return;
+ }
+
+ world.lightingExecutor.submit(new Runnable() {
+ @Override
+ public void run() {
+ Chunk.this.h(isClientSide);
+ }
+ });
+ }
+
public boolean isReady() {
// Spigot Start
/*
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 975d666..ae0f276 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
@ -55,7 +88,7 @@ index 975d666..ae0f276 100644
if (!this.world.c(i, j)) {
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 915a02d..e0a7161 100644
index 915a02d..ed0b63d 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -18,6 +18,12 @@ import org.bukkit.generator.ChunkGenerator;
@ -75,7 +108,7 @@ index 915a02d..e0a7161 100644
public static boolean haveWeSilencedAPhysicsCrash;
public static String blockLocation;
private int tileTickPosition;
+ private ExecutorService lightingExecutor; // PaperSpigot - Asynchronous lighting updates
+ public ExecutorService lightingExecutor; // PaperSpigot - Asynchronous lighting updates
public static long chunkToKey(int x, int z)
{
@ -115,7 +148,7 @@ index 915a02d..e0a7161 100644
// CraftBukkit end
return false;
} else {
@@ -2479,11 +2486,66 @@ public abstract class World implements IBlockAccess {
@@ -2479,11 +2486,70 @@ public abstract class World implements IBlockAccess {
}
}
@ -170,6 +203,10 @@ index 915a02d..e0a7161 100644
+ }
+ }
+
+ if (!Bukkit.isPrimaryThread()) {
+ return this.c(enumskyblock, position, chunk, neighbors);
+ }
+
+ lightingExecutor.submit(new Runnable() {
+ @Override
+ public void run() {
@ -199,5 +236,5 @@ index bcd8b65..fa9ae6c 100644
+ }
}
--
1.9.5.msysgit.1
2.4.6.windows.1

View File

@ -128,7 +128,7 @@ index b3e77d5..39cf1a3 100644
@@ -133,6 +133,7 @@ public abstract class World implements IBlockAccess {
public static String blockLocation;
private int tileTickPosition;
private ExecutorService lightingExecutor; // PaperSpigot - Asynchronous lighting updates
public ExecutorService lightingExecutor; // PaperSpigot - Asynchronous lighting updates
+ public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<Explosion.CacheKey, Float>(); // PaperSpigot - Optimize explosions
public static long chunkToKey(int x, int z)