aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/1057-Optimise-getChunkAt-calls-for-loaded-chunks.patch
diff options
context:
space:
mode:
author96DarkCode96 <[email protected]>2024-12-11 19:29:51 +0100
committerGitHub <[email protected]>2024-12-11 19:29:51 +0100
commit4803421326fca1ba974d52844d882d1912ad62a3 (patch)
treee9b03d651b71ae5bf48aa8e2e0f16ce496306b4a /patches/server/1057-Optimise-getChunkAt-calls-for-loaded-chunks.patch
parent8dc76e715261f97bbf4a3f254e123aae08588ad5 (diff)
downloadPaper-4803421326fca1ba974d52844d882d1912ad62a3.tar.gz
Paper-4803421326fca1ba974d52844d882d1912ad62a3.zip
Fix Player.setPlayerListOrder to send update to clients (#11729)
Diffstat (limited to 'patches/server/1057-Optimise-getChunkAt-calls-for-loaded-chunks.patch')
-rw-r--r--patches/server/1057-Optimise-getChunkAt-calls-for-loaded-chunks.patch60
1 files changed, 60 insertions, 0 deletions
diff --git a/patches/server/1057-Optimise-getChunkAt-calls-for-loaded-chunks.patch b/patches/server/1057-Optimise-getChunkAt-calls-for-loaded-chunks.patch
new file mode 100644
index 0000000000..a18ef75e66
--- /dev/null
+++ b/patches/server/1057-Optimise-getChunkAt-calls-for-loaded-chunks.patch
@@ -0,0 +1,60 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Spottedleaf <[email protected]>
+Date: Sat, 25 Jan 2020 17:04:35 -0800
+Subject: [PATCH] Optimise getChunkAt calls for loaded chunks
+
+bypass the need to get a player chunk, then get the either,
+then unwrap it...
+
+diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+index df51c80b73e9922e4b0a1f2291ebabbb74d809ff..6a2af3cd3aebe525a5ff41a801929547d59b8fec 100644
+--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
++++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+@@ -194,6 +194,12 @@ public class ServerChunkCache extends ChunkSource {
+ return this.getChunk(x, z, leastStatus, create);
+ }, this.mainThreadProcessor).join();
+ } else {
++ // Paper start - Perf: Optimise getChunkAt calls for loaded chunks
++ LevelChunk ifLoaded = this.getChunkAtIfLoadedMainThread(x, z);
++ if (ifLoaded != null) {
++ return ifLoaded;
++ }
++ // Paper end - Perf: Optimise getChunkAt calls for loaded chunks
+ ProfilerFiller gameprofilerfiller = Profiler.get();
+
+ gameprofilerfiller.incrementCounter("getChunk");
+@@ -234,33 +240,7 @@ public class ServerChunkCache extends ChunkSource {
+ if (Thread.currentThread() != this.mainThread) {
+ return null;
+ } else {
+- Profiler.get().incrementCounter("getChunkNow");
+- long k = ChunkPos.asLong(chunkX, chunkZ);
+-
+- ChunkAccess ichunkaccess;
+-
+- for (int l = 0; l < 4; ++l) {
+- if (k == this.lastChunkPos[l] && this.lastChunkStatus[l] == ChunkStatus.FULL) {
+- ichunkaccess = this.lastChunk[l];
+- return ichunkaccess instanceof LevelChunk ? (LevelChunk) ichunkaccess : null;
+- }
+- }
+-
+- ChunkHolder playerchunk = this.getVisibleChunkIfPresent(k);
+-
+- if (playerchunk == null) {
+- return null;
+- } else {
+- ichunkaccess = playerchunk.getChunkIfPresent(ChunkStatus.FULL);
+- if (ichunkaccess != null) {
+- this.storeInCache(k, ichunkaccess, ChunkStatus.FULL);
+- if (ichunkaccess instanceof LevelChunk) {
+- return (LevelChunk) ichunkaccess;
+- }
+- }
+-
+- return null;
+- }
++ return this.getChunkAtIfLoadedMainThread(chunkX, chunkZ); // Paper - Perf: Optimise getChunkAt calls for loaded chunks
+ }
+ }
+