13
0
geforkt von Mirrors/Paper

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
Dieser Commit ist enthalten in:
Aikar 2020-05-23 17:15:40 -04:00
Ursprung 4ec22a4736
Commit bfb789c862
3 geänderte Dateien mit 65 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -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

Datei anzeigen

@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 23 May 2020 17:03:41 -0400
Subject: [PATCH] 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.
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -0,0 +0,0 @@ public abstract class PlayerList {
world = (WorldServer) entityhuman.world;
}
- List<? extends EntityHuman> players1 = world == null ? players : world.players;
- for (int j = 0; j < players1.size(); ++j) {
- EntityHuman entity = players1.get(j);
- if (!(entity instanceof EntityPlayer)) continue;
- EntityPlayer entityplayer = (EntityPlayer) entity;
+ // Paper start
+ if (world == null && dimensionmanager != null) {
+ world = dimensionmanager.world;
+ }
+ if (world == null) {
+ LOGGER.error("Sending packet to invalid world" + entityhuman + " " + dimensionmanager + " - " + packet.getClass().getName(), new Throwable());
+ return; // ??? shouldn't happen...
+ }
+ com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<EntityPlayer> nearbyPlayers = world.getChunkProvider().playerChunkMap.playerViewDistanceBroadcastMap.getObjectsInRange(MCUtil.fastFloor(d0) >> 4, MCUtil.fastFloor(d2) >> 4);
+ if (nearbyPlayers == null) {
+ return;
+ }
+ Object[] backingSet = nearbyPlayers.getBackingSet();
+ for (Object object : backingSet) {
+ if (!(object instanceof EntityPlayer)) continue;
+ EntityPlayer entityplayer = (EntityPlayer) object;
// Paper end
// CraftBukkit start - Test if player receiving packet can see the source of the packet

7
paper
Datei anzeigen

@ -68,6 +68,13 @@ case "$1" in
ls -la Paper-Server/target/paper*.jar
) || failed=1
;;
"pc" | "paperclip")
(
set -e
cd "$basedir"
scripts/paperclip.sh "$basedir" || exit 1
) || failed=1
;;
"make")
(
if [[ "$2" = "bacon" ]] ; then