geforkt von Mirrors/Paper
c0d07c1b67
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: f009c3dd SPIGOT-5810, SPIGOT-5835: 'Better' handling of Player.isOnGround e677c370 Update ECJ version 5058a35d SPIGOT-5860: Item.setItemStack should be NotNull CraftBukkit Changes:d77f4d9b
SPIGOT-5810, SPIGOT-5835: 'Better' handling of Player.isOnGround53c95627
SPIGOT-5865: Piglin does not trigger EntityPickupItemEvent2ab04d24
Update ECJ version7884e079
SPIGOT-5868: Blocks do not tick in custom nether / end2a848286
SPIGOT-5863: Don't check colour in scoreboard length validationf2cbce30
SPIGOT-5866: Beehive unknown TargetReason Spigot Changes: ad703da0 SPIGOT-5870: /plugins "website" field shows "version" 1a27cfd8 #98: Improve output of /plugins command using text components 732d5bab Disable checkstyle in Spigot blocks 0199a9a6 #97: Add Memory Usage to Ticks Per Second Command. 33ea98fc SPIGOT-5858: NPE: Joining the server with an invalid dimension
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 09d7435ed4e5a00f8215aceedf26033fc703d659..0c0c285364ab919cb92b9c7db085672cb6165dff 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();
|