mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-03 21:37:28 +01:00
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
This commit is contained in:
parent
065868036c
commit
e7ff2c2126
3 changed files with 18 additions and 14 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue