Fire FoodLevelChangeEvent when eating cake. Fixes BUKKIT-2242

This commit is contained in:
T00thpick1 2013-07-19 16:42:05 -04:00 committed by Nate Mortensen
parent 3fb4ccb62c
commit 6482b6f0bd

View File

@ -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) {