SPIGOT-1341: Cancelled cake interact decreases client hunger

This commit is contained in:
md_5
2016-07-01 11:20:31 +10:00
parent 8db0dbfc44
commit 45038571f9
4 changed files with 16 additions and 9 deletions

View File

@@ -52,7 +52,7 @@
if (this.isCreative()) {
if (!this.world.douseFire((EntityHuman) null, blockposition, enumdirection)) {
this.breakBlock(blockposition);
@@ -127,14 +147,48 @@
@@ -127,15 +147,49 @@
}
}
@@ -87,22 +87,23 @@
+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
+ }
+ return;
}
+ }
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.player.inventory.getItemInHand(), f >= 1.0f);
+
+ if (blockEvent.isCancelled()) {
+ // Let the client know the block still exists
+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
+ return;
+ }
+
}
+ if (blockEvent.getInstaBreak()) {
+ f = 2.0f;
+ }
+ // CraftBukkit end
+
if (iblockdata.getMaterial() != Material.AIR && f >= 1.0F) {
this.breakBlock(blockposition);
} else {
@@ -152,6 +206,7 @@
public void a(BlockPosition blockposition) {
@@ -227,7 +228,7 @@
if (this.gamemode == EnumGamemode.SPECTATOR) {
TileEntity tileentity = world.getTileEntity(blockposition);
@@ -340,6 +474,72 @@
@@ -340,6 +474,74 @@
}
}
}
@@ -255,6 +256,8 @@
+ if (blockdata.getBlock() instanceof BlockDoor) {
+ boolean bottom = blockdata.get(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER;
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down()));
+ } else if (blockdata.getBlock() instanceof BlockCake) {
+ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake
+ }
+ result = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
+ } else if (this.gamemode == EnumGamemode.SPECTATOR) {