From e7ff2c2126e3561f84d464c29623cc558d6d6232 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 1 Oct 2018 01:00:09 -0400 Subject: [PATCH] Fix Async Chunk Load Callback if chunk was already loaded Fixes ACL API mainly, but might fix other smaller things too Also improved the high priority check if the chunk was already marked done --- .../Async-Chunk-Loading-and-Generation.patch | 20 +++++++++++-------- ...unk-Unloads-based-on-Player-Movement.patch | 10 +++++----- .../Fix-Sending-Chunks-to-Client.patch | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Spigot-Server-Patches/Async-Chunk-Loading-and-Generation.patch b/Spigot-Server-Patches/Async-Chunk-Loading-and-Generation.patch index 9564e1bf62..0ed728aa52 100644 --- a/Spigot-Server-Patches/Async-Chunk-Loading-and-Generation.patch +++ b/Spigot-Server-Patches/Async-Chunk-Loading-and-Generation.patch @@ -735,7 +735,7 @@ index 98d182fdb8..487d98eb1b 100644 diff --git a/src/main/java/net/minecraft/server/PaperAsyncChunkProvider.java b/src/main/java/net/minecraft/server/PaperAsyncChunkProvider.java new file mode 100644 -index 0000000000..47d9ecdbf1 +index 0000000000..a3fc989832 --- /dev/null +++ b/src/main/java/net/minecraft/server/PaperAsyncChunkProvider.java @@ -0,0 +0,0 @@ @@ -866,6 +866,9 @@ index 0000000000..47d9ecdbf1 + long key = ChunkCoordIntPair.asLong(x, z); + Chunk chunk = this.chunks.get(key); + if (chunk != null || !load) { // return null if we aren't loading ++ if (consumer != null) { ++ consumer.accept(chunk); ++ } + return chunk; + } + return loadOrGenerateChunk(x, z, gen, priority, consumer); // Async overrides this method @@ -1215,7 +1218,7 @@ index 0000000000..47d9ecdbf1 + +} diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java -index 2a889dc20a..242691d89d 100644 +index 2c7c8adf7c..04ad94e171 100644 --- a/src/main/java/net/minecraft/server/PlayerChunk.java +++ b/src/main/java/net/minecraft/server/PlayerChunk.java @@ -0,0 +0,0 @@ public class PlayerChunk { @@ -1237,7 +1240,7 @@ index 2a889dc20a..242691d89d 100644 }; + private boolean markedHigh = false; + void checkHighPriority(EntityPlayer player) { -+ if (markedHigh || chunk != null) { ++ if (done || markedHigh || chunk != null) { + return; + } + final double dist = getDistance(player.locX, player.locZ); @@ -1279,13 +1282,14 @@ index 2a889dc20a..242691d89d 100644 } @@ -0,0 +0,0 @@ public class PlayerChunk { - chunkHasPlayers = false; // Paper - delay chunk unloads - markChunkUsed(); // Paper - delay chunk unloads - } -+ checkHighPriority(entityplayer); // Paper - this.c.add(entityplayer); if (this.done) { + this.sendChunk(entityplayer); +- } ++ } else checkHighPriority(entityplayer); // Paper + + } + } @@ -0,0 +0,0 @@ public class PlayerChunk { if (this.chunk != null) { return true; diff --git a/Spigot-Server-Patches/Delay-Chunk-Unloads-based-on-Player-Movement.patch b/Spigot-Server-Patches/Delay-Chunk-Unloads-based-on-Player-Movement.patch index e08efe5845..1affac57fc 100644 --- a/Spigot-Server-Patches/Delay-Chunk-Unloads-based-on-Player-Movement.patch +++ b/Spigot-Server-Patches/Delay-Chunk-Unloads-based-on-Player-Movement.patch @@ -99,7 +99,7 @@ index 2d10f4aa37..719d5deb2c 100644 this.chunkScheduler.a(booleansupplier); } diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java -index ac0e90eeca..abf5a7554d 100644 +index ac0e90eeca..2fd8fa30ee 100644 --- a/src/main/java/net/minecraft/server/PlayerChunk.java +++ b/src/main/java/net/minecraft/server/PlayerChunk.java @@ -0,0 +0,0 @@ public class PlayerChunk { @@ -114,13 +114,13 @@ index ac0e90eeca..abf5a7554d 100644 + if (chunk == null) { + return; + } -+ if (!chunkHasPlayers) { ++ if (chunkHasPlayers) { + chunk.scheduledForUnload = null; + } else if (chunk.scheduledForUnload == null) { + chunk.scheduledForUnload = System.currentTimeMillis(); + } + } -+ private boolean chunkHasPlayers = true; ++ private boolean chunkHasPlayers = false; + // Paper end // CraftBukkit end @@ -137,7 +137,7 @@ index ac0e90eeca..abf5a7554d 100644 } else { if (this.c.isEmpty()) { this.i = this.playerChunkMap.getWorld().getTime(); -+ chunkHasPlayers = false; // Paper - delay chunk unloads ++ chunkHasPlayers = true; // Paper - delay chunk unloads + markChunkUsed(); // Paper - delay chunk unloads } @@ -146,7 +146,7 @@ index ac0e90eeca..abf5a7554d 100644 this.c.remove(entityplayer); if (this.c.isEmpty()) { -+ chunkHasPlayers = true; // Paper - delay chunk unloads ++ chunkHasPlayers = false; // Paper - delay chunk unloads + markChunkUsed(); // Paper - delay chunk unloads this.playerChunkMap.b(this); } diff --git a/Spigot-Server-Patches/Fix-Sending-Chunks-to-Client.patch b/Spigot-Server-Patches/Fix-Sending-Chunks-to-Client.patch index aef1379d8d..dcc8f0dc63 100644 --- a/Spigot-Server-Patches/Fix-Sending-Chunks-to-Client.patch +++ b/Spigot-Server-Patches/Fix-Sending-Chunks-to-Client.patch @@ -41,7 +41,7 @@ index 895eb60854..350479dc68 100644 } diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java -index 242691d89d..86f0fb3c2a 100644 +index 04ad94e171..748d5f28e5 100644 --- a/src/main/java/net/minecraft/server/PlayerChunk.java +++ b/src/main/java/net/minecraft/server/PlayerChunk.java @@ -0,0 +0,0 @@ public class PlayerChunk {