Rework async chunk api implementation
Firstly, the old methods all routed to the CompletableFuture method. However, the CF method could not guarantee that if the caller was off-main that the future would be "completed" on-main. Since the callback methods used the CF one, this meant that the callback methods did not guarantee that the callbacks were to be called on the main thread. Now, all methods route to getChunkAtAsync(x, z, gen, urgent, cb) so that the methods with the callback are guaranteed to invoke the callback on the main thread. The CF behavior remains unchanged; it may still appear to complete on main if invoked off-main. Secondly, remove the scheduleOnMain invocation in the async chunk completion. This unnecessarily delays the callback by 1 tick. Thirdly, add getChunksAtAsync(minX, minZ, maxX, maxZ, ...) which will load chunks within an area. This method is provided as a helper as keeping all chunks loaded within an area can be complicated to implement for plugins (due to the lacking ticket API), and is already implemented internally anyways. Fourthly, remove the ticket addition that occured with getChunkAt and getChunkAtAsync. The ticket addition may delay the unloading of the chunk unnecessarily. It also fixes a very rare timing bug where the future/callback would be completed after the chunk unloads.
This commit is contained in:
parent
de6173b061
commit
8c5b837e05
720 changed files with 978 additions and 1034 deletions
|
@ -11,10 +11,10 @@ Co-authored-by: lexikiq <noellekiq@gmail.com>
|
|||
Co-authored-by: Aikar <aikar@aikar.co>
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 828f47c6aadb609402f7237f8c234d595f39c970..88c93a2e67c8d1bc227c7fa35bb919a40009f931 100644
|
||||
index 92387bffda6d7a7bfe6197b33c69142f184f9d3b..3d54f52ed43ceef368804f7dce1dd95de3acc045 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1305,7 +1305,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -1310,7 +1310,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
|
||||
@Override
|
||||
public void levelEvent(@Nullable Player player, int eventId, BlockPos pos, int data) {
|
||||
|
@ -23,7 +23,7 @@ index 828f47c6aadb609402f7237f8c234d595f39c970..88c93a2e67c8d1bc227c7fa35bb919a4
|
|||
}
|
||||
|
||||
public int getLogicalHeight() {
|
||||
@@ -2122,6 +2122,17 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -2127,6 +2127,17 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
return this.serverLevelData.getGameRules();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue