geforkt von Mirrors/Paper
c29c36e782
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 3284612a SPIGOT-5853: Add DragonBattle#generateEndPortal() e4db04ae SPIGOT-5841: New map colours broken CraftBukkit Changes:d4243510
SPIGOT-5853: DragonBattle#getEndPortalLocation() throws NPE on new world1601ec31
SPIGOT-5845: ChatColor.RESET does not work in ItemMeta to reset italics4d92db6f
CraftChatMessageTest does not need AbstractTestingBase71045d3d
SPIGOT-5828: Unlock worlds on unloaddbc347b9
SPIGOT-5841: New map colours broken14053c70
SPIGOT-5847: BlockFadeEvent cannot be triggered asynchronously from another thread Spigot Changes: 6f4ff1b6 SPIGOT-5851: ChatColor (HEX) doesn't appear correctly in the ActionBar d94a518a SPIGOT-5848: PlayerSpawnLocationEvent throws NPE when setting a location of another world
64 Zeilen
3.5 KiB
Diff
64 Zeilen
3.5 KiB
Diff
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 8490376b014ac26bda473ea1e0c7a1063c9c70d2..35d7ac60f61ffb493fe4f32b63511b2b86805243 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
|
@@ -1063,16 +1063,40 @@ public abstract class PlayerList {
|
|
}
|
|
|
|
public void sendPacketNearby(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, double d3, ResourceKey<World> resourcekey, Packet<?> packet) {
|
|
- for (int i = 0; i < this.players.size(); ++i) {
|
|
- EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
|
|
+ WorldServer world = null;
|
|
+ if (entityhuman != null && entityhuman.world instanceof WorldServer) {
|
|
+ world = (WorldServer) entityhuman.world;
|
|
+ }
|
|
|
|
- // CraftBukkit start - Test if player receiving packet can see the source of the packet
|
|
- if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
|
|
- continue;
|
|
+ // Paper start
|
|
+ if (world == null) {
|
|
+ world = server.getWorldServer(resourcekey);
|
|
+ }
|
|
+ PlayerChunkMap chunkMap = world != null ? world.getChunkProvider().playerChunkMap : null;
|
|
+ Object[] backingSet;
|
|
+ if (chunkMap == null) {
|
|
+ // Really shouldn't happen...
|
|
+ backingSet = world != null ? world.players.toArray() : players.toArray();
|
|
+ } else {
|
|
+ com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<EntityPlayer> nearbyPlayers = chunkMap.playerViewDistanceBroadcastMap.getObjectsInRange(MCUtil.fastFloor(d0) >> 4, MCUtil.fastFloor(d2) >> 4);
|
|
+ if (nearbyPlayers == null) {
|
|
+ return;
|
|
}
|
|
+ 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
|
|
+ //if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) { // Paper
|
|
+ //continue; // Paper
|
|
+ //} // Paper
|
|
// CraftBukkit end
|
|
|
|
- if (entityplayer != entityhuman && entityplayer.world.getDimensionKey() == resourcekey) {
|
|
+ if (entityplayer != entityhuman && entityplayer.world.getDimensionKey() == resourcekey && (!(entityhuman instanceof EntityPlayer) || entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity()))) { // Paper
|
|
double d4 = d0 - entityplayer.locX();
|
|
double d5 = d1 - entityplayer.locY();
|
|
double d6 = d2 - entityplayer.locZ();
|