From e1afee008feae398d48edcb2b2a3c45640e16271 Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Wed, 14 Nov 2012 20:03:58 -0600 Subject: [PATCH] Update tile entity on client on cancelled block break. Fixes BUKKIT-2935 When a client tries to break a block it assumes it has done so unless told otherwise by the server. This means the client also wipes out any tile entity data it has for the block as well. We do not send this data when updating the client so clients lose things like text on signs, skull type, etc when they aren't allowed to break the block. --- src/main/java/net/minecraft/server/ItemInWorldManager.java | 5 +++++ src/main/java/net/minecraft/server/NetServerHandler.java | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/ItemInWorldManager.java b/src/main/java/net/minecraft/server/ItemInWorldManager.java index 771c05f0e2..3baef72e21 100644 --- a/src/main/java/net/minecraft/server/ItemInWorldManager.java +++ b/src/main/java/net/minecraft/server/ItemInWorldManager.java @@ -279,6 +279,11 @@ public class ItemInWorldManager { if (event.isCancelled()) { // Let the client know the block still exists ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world)); + // Update any tile entity data for this block + TileEntity tileentity = this.world.getTileEntity(i, j, k); + if (tileentity != null) { + this.player.netServerHandler.sendPacket(tileentity.getUpdatePacket()); + } return false; } } diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 7f672c6cc9..c05c9c5f7b 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -542,8 +542,13 @@ public class NetServerHandler extends NetHandler { // CraftBukkit start if (i1 < this.server.getSpawnRadius() && !flag) { CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, i, j, k, l, this.player.inventory.getItemInHand()); - // CraftBukkit end this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver)); + // Update any tile entity data for this block + TileEntity tileentity = worldserver.getTileEntity(i, j, k); + if (tileentity != null) { + this.player.netServerHandler.sendPacket(tileentity.getUpdatePacket()); + } + // CraftBukkit end } else { this.player.itemInWorldManager.dig(i, j, k, packet14blockdig.face); }