From d08ee17352868dc52d58403b8ae97cd05d5e0723 Mon Sep 17 00:00:00 2001 From: Erik Broes Date: Wed, 23 Mar 2011 18:29:43 +0100 Subject: [PATCH] Fix doors not updating after opening has been denied --- .../minecraft/server/ItemInWorldManager.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/minecraft/server/ItemInWorldManager.java b/src/main/java/net/minecraft/server/ItemInWorldManager.java index 52acfd3a57..d21130f882 100644 --- a/src/main/java/net/minecraft/server/ItemInWorldManager.java +++ b/src/main/java/net/minecraft/server/ItemInWorldManager.java @@ -64,7 +64,15 @@ public class ItemInWorldManager { PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.a, Action.LEFT_CLICK_BLOCK , i, j, k, -1, this.a.inventory.b()); - if (event.useInteractedBlock() != Event.Result.DENY) { + if (event.useInteractedBlock() == Event.Result.DENY) { + // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. + if (l == Block.WOODEN_DOOR.id) { + // For some reason *BOTH* the bottom/top part have to be marked updated. + boolean bottom = (this.b.getData(i, j, k) & 8) == 0; + ((EntityPlayer) this.a).a.b((Packet) (new Packet53BlockChange(i, j, k, this.b))); + ((EntityPlayer) this.a).a.b((Packet) (new Packet53BlockChange(i, j + (bottom ? 1 : -1), k, this.b))); + } + } else { Block.byId[l].b(this.b, i, j, k, this.a); } @@ -187,7 +195,13 @@ public class ItemInWorldManager { boolean result = false; if (i1 > 0) { PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, i, j, k, l, itemstack); - if (event.useInteractedBlock() != Event.Result.DENY) { + if (event.useInteractedBlock() == Event.Result.DENY) { + // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. + if (i1 == Block.WOODEN_DOOR.id) { + boolean bottom = (world.getData(i, j, k) & 8) == 0; + ((EntityPlayer) entityhuman).a.b((Packet) (new Packet53BlockChange(i, j + (bottom ? 1 : -1), k, world))); + } + } else { result = Block.byId[i1].a(world, i, j, k, entityhuman); } if (itemstack != null && event.useItemInHand() != Event.Result.DENY && (!result || event.useItemInHand() == Event.Result.ALLOW)) {