mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 14:35:11 +01:00
Add experimental patch to unload chunks more efficiently from the client by not grabbing them and compressing, instead just sending some predefined bytes
This commit is contained in:
parent
c63672c098
commit
c45ba0bcd8
1 changed files with 56 additions and 0 deletions
|
@ -0,0 +1,56 @@
|
|||
From 1581cbd0691eea89081a0a9e387ee70821f09485 Mon Sep 17 00:00:00 2001
|
||||
From: Ammar Askar <ammar@ammaraskar.com>
|
||||
Date: Fri, 18 Jan 2013 16:20:01 +0500
|
||||
Subject: [PATCH 16/16] Optimize packet used to unload chunks for the client
|
||||
|
||||
At the moment telling a client to unload a chunk involves calling the entire chunk from memory, deflating it and then sending it through the pipes even though the client ignores it and based on the bitmap simply unloads the chunk, and to add the cherry on top, this is done on the main server thread.
|
||||
---
|
||||
src/main/java/net/minecraft/server/Packet51MapChunk.java | 13 +++++++++++++
|
||||
src/main/java/net/minecraft/server/PlayerChunk.java | 2 +-
|
||||
2 files changed, 14 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Packet51MapChunk.java b/src/main/java/net/minecraft/server/Packet51MapChunk.java
|
||||
index ee179be..b51d90c 100644
|
||||
--- a/src/main/java/net/minecraft/server/Packet51MapChunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Packet51MapChunk.java
|
||||
@@ -18,11 +18,24 @@ public class Packet51MapChunk extends Packet {
|
||||
public boolean e;
|
||||
private int size;
|
||||
private static byte[] buildBuffer = new byte[196864];
|
||||
+ private static final byte[] unloadSequence = new byte[]{0x78, (byte) 0x9C, 0x63, 0x64, 0x1C, (byte) 0xD9, 0x00, 0x00, (byte) 0x81, (byte) 0x80, 0x01, 0x01}; // Spigot
|
||||
|
||||
public Packet51MapChunk() {
|
||||
this.lowPriority = true;
|
||||
}
|
||||
|
||||
+ // Spigot start - add constructor for chunk removals for the client
|
||||
+ public Packet51MapChunk(int x, int z) {
|
||||
+ this.a = x;
|
||||
+ this.b = z;
|
||||
+ this.e = true;
|
||||
+ this.c = 0;
|
||||
+ this.d = 0;
|
||||
+ this.size = unloadSequence.length;
|
||||
+ this.buffer = unloadSequence;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
+
|
||||
public Packet51MapChunk(Chunk chunk, boolean flag, int i) {
|
||||
this.lowPriority = true;
|
||||
this.a = chunk.x;
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
index 5350644..185a609 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
@@ -51,7 +51,7 @@ class PlayerChunk {
|
||||
|
||||
public void b(EntityPlayer entityplayer) {
|
||||
if (this.b.contains(entityplayer)) {
|
||||
- entityplayer.playerConnection.sendPacket(new Packet51MapChunk(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z), true, 0));
|
||||
+ entityplayer.playerConnection.sendPacket(new Packet51MapChunk(this.location.x, this.location.z)); // Spigot - remove chunk load call just to unload in favour of specialized constructor
|
||||
this.b.remove(entityplayer);
|
||||
entityplayer.chunkCoordIntPairQueue.remove(this.location);
|
||||
if (this.b.isEmpty()) {
|
||||
--
|
||||
1.8.1-rc2
|
||||
|
Loading…
Reference in a new issue