2013-07-02 05:03:56 +02:00
From 9007f313ede8a4a7711890086191f20e8c6b14f8 Mon Sep 17 00:00:00 2001
2013-01-18 12:27:42 +01:00
From: Ammar Askar <ammar@ammaraskar.com>
Date: Fri, 18 Jan 2013 16:20:01 +0500
2013-06-11 06:11:48 +02:00
Subject: [PATCH] Optimize Chunk Unload Packet
2013-01-18 12:27:42 +01:00
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.
diff --git a/src/main/java/net/minecraft/server/Packet51MapChunk.java b/src/main/java/net/minecraft/server/Packet51MapChunk.java
2013-05-14 04:08:11 +02:00
index 3c3bdbf..d11c0ea 100644
2013-01-18 12:27:42 +01:00
--- 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
2013-07-02 05:03:56 +02:00
index 81d66e4..c4a6724 100644
2013-01-18 12:27:42 +01:00
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
2013-07-02 05:03:56 +02:00
@@ -56,9 +56,9 @@ class PlayerChunk {
2013-01-18 12:27:42 +01:00
public void b(EntityPlayer entityplayer) {
if (this.b.contains(entityplayer)) {
2013-07-02 05:03:56 +02:00
- Chunk chunk = PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z);
+ // Chunk chunk = PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z);
- entityplayer.playerConnection.sendPacket(new Packet51MapChunk(chunk, true, 0));
2013-01-18 12:27:42 +01:00
+ 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()) {
--
2013-06-02 07:15:15 +02:00
1.8.1.2
2013-01-18 12:27:42 +01:00