summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/minecraft')
-rw-r--r--src/main/java/net/minecraft/server/BlockCake.java12
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) {