Optimize sending packets to nearby locations (sounds/effects)

Instead of using the entire world or player list, use the distance
maps to only iterate players who are even seeing the chunk the packet
is originating from.

This will drastically cut down on packet sending cost for worlds with
lots of players in them.

Closes #3437
This commit is contained in:
Aikar
2020-05-23 17:15:40 -04:00
parent 4ec22a4736
commit bfb789c862
3 changed files with 65 additions and 0 deletions

View File

@@ -3004,6 +3004,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void b(PacketDataSerializer packetdataserializer) {
this.a();
packetdataserializer.writeByte(this.i);
diff --git a/src/main/java/net/minecraft/server/DimensionManager.java b/src/main/java/net/minecraft/server/DimensionManager.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/DimensionManager.java
+++ b/src/main/java/net/minecraft/server/DimensionManager.java
@@ -0,0 +0,0 @@ public class DimensionManager implements MinecraftSerializable {
return this.folder.isEmpty() ? file : new File(file, this.folder);
}
+ public WorldServer world; // Paper - store ref to world this manager is for
public WorldProvider getWorldProvider(World world) {
+ if (this.world == null) this.world = (WorldServer) world; // Paper
return (WorldProvider) this.providerFactory.apply(world, this);
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/Entity.java