mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 02:55:47 +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
48b1b0aac5
commit
6371b4581d
@ -1,4 +1,4 @@
|
||||
From a372872c9ea4562ff3b4cf6ab8b5853649d9db80 Mon Sep 17 00:00:00 2001
|
||||
From 35769e706c68ba327d1264aacd7cd27c1df767fe Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 18 Jun 2016 23:22:12 -0400
|
||||
Subject: [PATCH] Delay Chunk Unloads based on Player Movement
|
||||
@ -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
|
||||
@@ -33,8 +33,22 @@ 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);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 34048ff608e60efadf17ad137dd11cf19ac7dc34 Mon Sep 17 00:00:00 2001
|
||||
From 8a454e3fcde0690de840976757e8c22cb5974e73 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 21 Jul 2018 16:55:04 -0400
|
||||
Subject: [PATCH] Async Chunk Loading and Generation
|
||||
@ -735,10 +735,10 @@ 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 +1,475 @@
|
||||
@@ -0,0 +1,478 @@
|
||||
+/*
|
||||
+ * This file is licensed under the MIT License (MIT).
|
||||
+ *
|
||||
@ -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
|
||||
@@ -30,13 +30,42 @@ 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);
|
||||
@ -1278,15 +1281,16 @@ index 2a889dc20a..242691d89d 100644
|
||||
markChunkUsed(); // Paper - delay chunk unloads
|
||||
}
|
||||
|
||||
@@ -76,6 +105,7 @@ public class PlayerChunk {
|
||||
chunkHasPlayers = false; // Paper - delay chunk unloads
|
||||
markChunkUsed(); // Paper - delay chunk unloads
|
||||
}
|
||||
+ checkHighPriority(entityplayer); // Paper
|
||||
|
||||
@@ -80,7 +109,7 @@ public class PlayerChunk {
|
||||
this.c.add(entityplayer);
|
||||
if (this.done) {
|
||||
@@ -105,8 +135,13 @@ public class PlayerChunk {
|
||||
this.sendChunk(entityplayer);
|
||||
- }
|
||||
+ } else checkHighPriority(entityplayer); // Paper
|
||||
|
||||
}
|
||||
}
|
||||
@@ -105,8 +134,13 @@ public class PlayerChunk {
|
||||
if (this.chunk != null) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 352ece97092f16a3e286a80a585c9da808c174dc Mon Sep 17 00:00:00 2001
|
||||
From e0ed2e74e4a3a027832171214b5e6fca71c42fa1 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 29 Sep 2018 01:18:16 -0400
|
||||
Subject: [PATCH] Fix Sending Chunks to Client
|
||||
@ -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
|
||||
@@ -23,7 +23,7 @@ public class PlayerChunk {
|
||||
@ -53,7 +53,7 @@ index 242691d89d..86f0fb3c2a 100644
|
||||
|
||||
// CraftBukkit start - add fields
|
||||
// You know the drill, https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse
|
||||
@@ -146,6 +146,7 @@ public class PlayerChunk {
|
||||
@@ -145,6 +145,7 @@ public class PlayerChunk {
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user