aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0338-Update-entity-Metadata-for-all-tracked-players.patch
blob: 7f634c91d1ddf15989789e721b422c8fb8577ba1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AgentTroll <woodyc40@gmail.com>
Date: Fri, 22 Mar 2019 22:24:03 -0700
Subject: [PATCH] Update entity Metadata for all tracked players


diff --git a/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java
index e3cdea3c85d762af6984f3dbe544fdfe101f6ff6..6110d7723b70df5380338a42b5cbff3446294bac 100644
--- a/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java
@@ -421,6 +421,12 @@ public class EntityTrackerEntry {
         return PacketPlayOutEntity.a(this.xLoc, this.yLoc, this.zLoc);
     }
 
+    // Paper start - Add broadcast method
+    void broadcast(Packet<?> packet) {
+        this.getPacketConsumer().accept(packet);
+    }
+    // Paper end
+
     private void broadcastIncludingSelf(Packet<?> packet) {
         this.f.accept(packet);
         if (this.tracker instanceof EntityPlayer) {
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
index 8f442eae6519c3d0658e6ed77ecfa7aa8161a0f2..5d4ab95ca7498671888580f68382667c2282d604 100644
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
@@ -2285,7 +2285,14 @@ public class PlayerConnection implements PacketListenerPlayIn {
 
                     if (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != origItem) {
                         // Refresh the current entity metadata
-                        this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), true));
+                        // Paper start - update entity for all players
+                        PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), true);
+                        if (entity.tracker != null) {
+                            entity.tracker.broadcast(packet);
+                        } else {
+                            this.sendPacket(packet);
+                        }
+                        // Paper end
                     }
 
                     if (event.isCancelled()) {