mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
4af62f6d1d
Upstream has released updates that appear 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: 2d009e64 Update SnakeYAML javadoc link b4fd213c Switch Player#updateInventory deprecation for internal API annotation CraftBukkit Changes: f3b2b2210 SPIGOT-7376: Exception with getBlockData when hasBlockData is false 725545630 SPIGOT-7375: Fix crash breeding certain entities b9873b0d4 Update Brigadier version with fix 68b320562 SPIGOT-7266: Found typo in CraftBukkit package 98b4d2ff8 SPIGOT-7372, SPIGOT-7373: Signs can't be edited, issues with SignChangeEvent 5f7bd4d78 SPIGOT-7371: Sign does not open edit text on placement b4cf99d24 SPIGOT-7371: Fix editing signs with API a2b6c2744 PR-1200: Implement open sign by side a345bb940 SPIGOT-7368: Downgrade SpecialSource version Spigot Changes: 723951c3 Rebuild patches b655c57d Drop old collision API deprecated since 1.9.4 55b0fed4 Rebuild patches
107 lines
6.3 KiB
Diff
107 lines
6.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
|
Date: Wed, 7 Dec 2022 17:25:19 -0500
|
|
Subject: [PATCH] Properly resend entities
|
|
|
|
This resolves some issues which caused entities to not be resent correctly.
|
|
Entities that are interacted with need to be resent to the client, so we resend all the entity
|
|
data to the player whilst making sure not to clear dirty entries from the tracker. This makes
|
|
sure that values will be correctly updated to other players.
|
|
|
|
See: https://github.com/PaperMC/Paper/pull/1896
|
|
|
|
== AT ==
|
|
public net.minecraft.server.level.ChunkMap$TrackedEntity serverEntity
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
|
|
index d088479d160dbd2fc90b48a30553be141db8eef2..9e7a9e2fc19a0ac7a80a07efacf9cd2366826fa3 100644
|
|
--- a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
|
|
+++ b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
|
|
@@ -253,14 +253,46 @@ public class SynchedEntityData {
|
|
// CraftBukkit start
|
|
public void refresh(ServerPlayer to) {
|
|
if (!this.isEmpty()) {
|
|
- List<SynchedEntityData.DataValue<?>> list = this.getNonDefaultValues();
|
|
+ List<SynchedEntityData.DataValue<?>> list = this.packAll(); // Paper - Update EVERYTHING not just not default
|
|
|
|
if (list != null) {
|
|
+ if (to.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper
|
|
to.connection.send(new ClientboundSetEntityDataPacket(this.entity.getId(), list));
|
|
+ } // Paper
|
|
}
|
|
}
|
|
}
|
|
// CraftBukkit end
|
|
+ // Paper start
|
|
+ // We need to pack all as we cannot rely on "non default values" or "dirty" ones.
|
|
+ // Because these values can possibly be desynced on the client.
|
|
+ @Nullable
|
|
+ private List<SynchedEntityData.DataValue<?>> packAll() {
|
|
+ if (this.isEmpty()) {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ List<SynchedEntityData.DataValue<?>> list = new ArrayList<>();
|
|
+ for (DataItem<?> dataItem : this.itemsById.values()) {
|
|
+ list.add(dataItem.value());
|
|
+ }
|
|
+
|
|
+ return list;
|
|
+ }
|
|
+
|
|
+ // This method should only be used if the data of an entity could have became desynced
|
|
+ // due to interactions on the client.
|
|
+ public void resendPossiblyDesyncedEntity(ServerPlayer player) {
|
|
+ if (this.entity.tracker == null) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ net.minecraft.server.level.ServerEntity serverEntity = this.entity.tracker.serverEntity;
|
|
+ if (player.getBukkitEntity().canSee(entity.getBukkitEntity())) {
|
|
+ serverEntity.sendPairingData(player.connection::send, player);
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
|
|
public static class DataItem<T> {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index f52b01bca1b4221b389b2e980f2f75b0f1eca077..9b00b18e5c80c69b0c44299b48cef1937168f38a 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -2795,7 +2795,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
// Entity in bucket - SPIGOT-4048 and SPIGOT-6859a
|
|
if ((entity instanceof Bucketable && entity instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) {
|
|
- ServerGamePacketListenerImpl.this.send(new ClientboundAddEntityPacket(entity));
|
|
+ entity.getEntityData().resendPossiblyDesyncedEntity(player); // Paper - The entire mob gets deleted, so resend it.
|
|
player.containerMenu.sendAllDataToRemote();
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index f937dbd6a19b595e3660e598e52bf37f8cc72d13..d3e259eb22202133d54c4be58c5121735fe412ed 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -371,7 +371,7 @@ public abstract class PlayerList {
|
|
((ServerLevel)player.level()).getChunkSource().chunkMap.addEntity(player); // Paper - track entity now
|
|
// CraftBukkit end
|
|
|
|
- player.getEntityData().refresh(player); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn
|
|
+ //player.getEntityData().refresh(player); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn Paper - THIS IS NOT NEEDED ANYMORE
|
|
|
|
this.sendLevelInfo(player, worldserver1);
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bucketable.java b/src/main/java/net/minecraft/world/entity/animal/Bucketable.java
|
|
index 37596c7b65f280be00e8e59ae18bd1aceae21080..eca18540aeb0b0d4098477d73b14c78a7bf9f455 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Bucketable.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Bucketable.java
|
|
@@ -109,8 +109,7 @@ public interface Bucketable {
|
|
itemstack1 = CraftItemStack.asNMSCopy(playerBucketFishEvent.getEntityBucket());
|
|
if (playerBucketFishEvent.isCancelled()) {
|
|
((ServerPlayer) player).containerMenu.sendAllDataToRemote(); // We need to update inventory to resync client's bucket
|
|
- ((ServerPlayer) player).connection.send(new ClientboundAddEntityPacket(entity)); // We need to play out these packets as the client assumes the fish is gone
|
|
- entity.getEntityData().refresh((ServerPlayer) player); // Need to send data such as the display name to client
|
|
+ entity.getEntityData().resendPossiblyDesyncedEntity((ServerPlayer) player); // Paper
|
|
return Optional.of(InteractionResult.FAIL);
|
|
}
|
|
entity.playSound(((Bucketable) entity).getPickupSound(), 1.0F, 1.0F);
|