Paper/Spigot-Server-Patches/0383-Fix-Sending-Chunks-to-Client.patch
Aikar 38f0f0b71a
Disable use of Locks on main thread for DataPaletteBlock
This should greatly improve performance by using a No Op lock
while on the main thread.

Vanilla always had a write lock on write operations, but we added
a Read Lock during Async Chunks to make concurrent writes non fatal
for Async Chunks.

This means we added on a bunch of over head to all chunk read operations.

This corrects that, as well as disabling the write lock while on main thread.

It is a general rule that you do not touch a chunk async once it is loaded
into the world, as we never had locks on the chunk before 1.13 even.

So once we are on main, we don't expect concurrent access to begin with,
so we don't need the write locks either.
2018-10-02 22:29:31 -04:00

67 lines
2.4 KiB
Diff

From 0270355d40dd0fcd9b6d326f6d0084d07d689e49 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
Vanilla has some screwy logic that doesn't send a chunk until
it has been post processed. This is an issue as post processing
doesn't occur until all neighbor chunks have been loaded.
This can reduce view distance while generating terrain, but also
cause bugs where chunks are never sent to the client.
This fix always sends chunks to the client, and simply updates
the client anytime post processing is triggered with the new chunk data.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 8da88e1c3a..64cec6d692 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -1213,7 +1213,7 @@ public class Chunk implements IChunkAccess {
}
public boolean isReady() {
- return this.C.a(ChunkStatus.POSTPROCESSED);
+ return true; // Paper - Always send chunks
}
public boolean v() {
@@ -1479,6 +1479,13 @@ public class Chunk implements IChunkAccess {
this.h.clear();
this.a(ChunkStatus.POSTPROCESSED);
this.m.a(this);
+ // Paper start - resend chunk after post process
+ PlayerChunk playerChunk = ((WorldServer) world).getPlayerChunkMap().getChunk(locX, locZ);
+ if (playerChunk != null) {
+ playerChunk.done = false;
+ playerChunk.sendAll();
+ }
+ // Paper end
}
}
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
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 {
private int dirtyCount;
private int h;
private long i;
- private boolean done;
+ boolean done; // Paper - package-private
// CraftBukkit start - add fields
// You know the drill, https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse
@@ -145,6 +145,7 @@ public class PlayerChunk {
}
}
+ public boolean sendAll() { return b(); } // Paper - OBFHELPER
public boolean b() {
if (this.done) {
return true;
--
2.19.0