From 5bc6a9053571dba9e4a871e4872ed43f5b82d95c Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Mon, 9 Sep 2024 21:04:38 +1000 Subject: [PATCH] SPIGOT-7894: NPE when sending tile entity update By: md_5 --- .../craftbukkit/block/CraftBlockEntityState.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java index daf6387d9f..fa2444a2aa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java @@ -115,6 +115,14 @@ public class CraftBlockEntityState extends CraftBlockState return nbt; } + // gets the packet data of the TileEntity represented by this block state + public NBTTagCompound getUpdateNBT() { + // update snapshot + applyTo(snapshot); + + return snapshot.getUpdateTag(getRegistryAccess()); + } + // copies the data of the given tile entity to this block state protected void load(T tileEntity) { if (tileEntity != null && tileEntity != snapshot) { @@ -156,8 +164,7 @@ public class CraftBlockEntityState extends CraftBlockState @Nullable public Packet getUpdatePacket(@NotNull Location location) { - T vanillaTileEntitiy = (T) TileEntity.loadStatic(CraftLocation.toBlockPosition(location), getHandle(), getSnapshotNBT(), getRegistryAccess()); - return PacketPlayOutTileEntityData.create(vanillaTileEntitiy); + return new PacketPlayOutTileEntityData(CraftLocation.toBlockPosition(location), snapshot.getType(), getUpdateNBT()); } @Override