Do not schedule to main for getChunkImmediately type calls (#2362)
They are MT-Safe already. These changes reduce deadlock chances given these calls are used in Entity#isValid(), and plugins check this in packet handling...
This commit is contained in:
@@ -8,7 +8,7 @@ This patch also adds a chunk status cache on region files (note that
|
||||
its only purpose is to cache the status on DISK)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index 220cd197fa..775b5f7fe3 100644
|
||||
index 9765eaf24c..d714b8d01b 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider {
|
||||
@@ -27,24 +27,9 @@ index 220cd197fa..775b5f7fe3 100644
|
||||
+
|
||||
+ @Nullable
|
||||
+ public IChunkAccess getChunkAtImmediately(int x, int z) {
|
||||
+ if (Thread.currentThread() != this.serverThread) {
|
||||
+ return CompletableFuture.supplyAsync(() -> {
|
||||
+ return this.getChunkAtImmediately(x, z);
|
||||
+ }, this.serverThreadQueue).join();
|
||||
+ }
|
||||
+
|
||||
+ long k = ChunkCoordIntPair.pair(x, z);
|
||||
+
|
||||
+ IChunkAccess ichunkaccess;
|
||||
+
|
||||
+ for (int l = 0; l < 4; ++l) {
|
||||
+ if (k == this.cachePos[l]) {
|
||||
+ ichunkaccess = this.cacheChunk[l];
|
||||
+ if (ichunkaccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime
|
||||
+ return ichunkaccess;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Note: Bypass cache to make this MT-Safe
|
||||
+
|
||||
+ PlayerChunk playerChunk = this.getChunk(k);
|
||||
+ if (playerChunk == null) {
|
||||
|
||||
Reference in New Issue
Block a user