diff options
author | T00thpick1 <t00thpick1dirko@gmail.com> | 2013-07-19 16:42:05 -0400 |
---|---|---|
committer | Nate Mortensen <nate.richard.mortensen@gmail.com> | 2013-08-15 11:59:47 -0600 |
commit | 6482b6f0bd30c2330e38e8f722921af066a6fc12 (patch) | |
tree | 082bd243d3738f512ff033feda1563864afa6d66 /src | |
parent | 3fb4ccb62c1f355a0b26240dd2be4260dde3aa43 (diff) | |
download | craftbukkit-6482b6f0bd30c2330e38e8f722921af066a6fc12.tar craftbukkit-6482b6f0bd30c2330e38e8f722921af066a6fc12.tar.gz craftbukkit-6482b6f0bd30c2330e38e8f722921af066a6fc12.tar.lz craftbukkit-6482b6f0bd30c2330e38e8f722921af066a6fc12.tar.xz craftbukkit-6482b6f0bd30c2330e38e8f722921af066a6fc12.zip |
Fire FoodLevelChangeEvent when eating cake. Fixes BUKKIT-2242
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/minecraft/server/BlockCake.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/BlockCake.java b/src/main/java/net/minecraft/server/BlockCake.java index 65cc2865..2c850b8a 100644 --- a/src/main/java/net/minecraft/server/BlockCake.java +++ b/src/main/java/net/minecraft/server/BlockCake.java @@ -53,7 +53,17 @@ public class BlockCake extends Block { private void b(World world, int i, int j, int k, EntityHuman entityhuman) { if (entityhuman.g(false)) { - entityhuman.getFoodData().eat(2, 0.1F); + // CraftBukkit start + int oldFoodLevel = entityhuman.getFoodData().foodLevel; + + org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, 2 + oldFoodLevel); + + if (!event.isCancelled()) { + entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 0.1F); + } + + ((EntityPlayer) entityhuman).playerConnection.sendPacket(new Packet8UpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); + // CraftBukkit end int l = world.getData(i, j, k) + 1; if (l >= 6) { |