Paper/Spigot-Server-Patches/0286-Send-nearby-packets-from-world-player-list-not-serve.patch
Shane Freeder 48b6bfe2a6
Updated Upstream (Bukkit/CraftBukkit/Spigot)
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:
c987938a SPIGOT-5180: Add Villager#sleep() and #wakeup() methods

CraftBukkit Changes:
7f33c6a2 SPIGOT-5196: Restore previous version behaviour regarding cancelled BlockBreakEvent
6a5fc902 Improve diff in EntityHanging
c98d61bf SPIGOT-4712: Allow spawning of upwards or downwards facing item frames
db971477 SPIGOT-5199: Fix NPE if setting the book of the ItemMeta of a lectern
b0ef3996 SPIGOT-4679 Fix black lines after book paragraphs
1215188f SPIGOT-5180: Add Villager#sleep() and #wakeup() methods
c03b2bef SPIGOT-4975: NPE on WorldGenStronghold When Using Multiple Worlds
65ea162c Ensure Bukkit data pack is always up to date
0b107b8d MC-157395, SPIGOT-5193: Small armor stands do not drop loot
6da0abca SPIGOT-5195: Player loot table does not drop when keepInventory is on
8b09d983 SPIGOT-5190: Superfluous EntityCombustEvent called when using fire aspect sword

Spigot Changes:
1981d553 SPIGOT-5198: Catch more bad async operations
6a14ca46 Rebuild patches
2019-07-23 20:17:32 +01:00

86 lines
5.5 KiB
Diff

From 636d42b7fd0f59ebb3a211c26f1b2c060ce6f7f5 Mon Sep 17 00:00:00 2001
From: Mystiflow <mystiflow@gmail.com>
Date: Fri, 6 Jul 2018 13:21:30 +0100
Subject: [PATCH] Send nearby packets from world player list not server list
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 9e5cd22d7..049d702cb 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -922,8 +922,25 @@ public abstract class PlayerList {
}
public void sendPacketNearby(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, double d3, DimensionManager dimensionmanager, Packet<?> packet) {
- for (int i = 0; i < this.players.size(); ++i) {
- EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
+ // Paper start - Use world list instead of server list where preferable
+ sendPacketNearby(entityhuman, d0, d1, d2, d3, dimensionmanager, null, packet); // Retained for compatibility
+ }
+
+ public void sendPacketNearby(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, double d3, WorldServer world, Packet<?> packet) {
+ sendPacketNearby(entityhuman, d0, d1, d2, d3, world.worldProvider.getDimensionManager(), world, packet);
+ }
+
+ public void sendPacketNearby(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, double d3, DimensionManager dimensionmanager, @Nullable WorldServer world, Packet<?> packet) {
+ if (world == null && entityhuman != null && entityhuman.world instanceof WorldServer) {
+ 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 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())) {
@@ -931,7 +948,7 @@ public abstract class PlayerList {
}
// CraftBukkit end
- if (entityplayer != entityhuman && entityplayer.dimension == dimensionmanager) {
+ if (entityplayer != entityhuman && (world != null || entityplayer.dimension == dimensionmanager)) { // Paper
double d4 = d0 - entityplayer.locX;
double d5 = d1 - entityplayer.locY;
double d6 = d2 - entityplayer.locZ;
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 4b7104927..d8d4da7d1 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1185,7 +1185,7 @@ public class WorldServer extends World {
}
// CraftBukkit end
this.globalEntityList.add(entitylightning);
- this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entitylightning.locX, entitylightning.locY, entitylightning.locZ, 512.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutSpawnEntityWeather(entitylightning));
+ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entitylightning.locX, entitylightning.locY, entitylightning.locZ, 512.0D, this, new PacketPlayOutSpawnEntityWeather(entitylightning)); // Paper - use world instead of dimension
}
@Override
@@ -1317,7 +1317,7 @@ public class WorldServer extends World {
BlockActionData blockactiondata = (BlockActionData) this.I.removeFirst();
if (this.a(blockactiondata)) {
- this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d()));
+ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d()));
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index a4df908bb..9a7b0076f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1998,7 +1998,7 @@ public class CraftWorld implements World {
double z = loc.getZ();
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), SoundCategory.valueOf(category.name()), new Vec3D(x, y, z), volume, pitch);
- world.getMinecraftServer().getPlayerList().sendPacketNearby(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.getWorldProvider().getDimensionManager(), packet);
+ world.getMinecraftServer().getPlayerList().sendPacketNearby(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world, packet); // Paper - this.world.dimension -> this.world
}
private static Map<String, GameRules.GameRuleKey<?>> gamerules;
--
2.22.0