summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockCake.patch
blob: cb5c7675a42803c7141d8669819f52a8d9a4984e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--- a/net/minecraft/server/BlockCake.java
+++ b/net/minecraft/server/BlockCake.java
@@ -33,7 +33,18 @@
             return false;
         } else {
             entityhuman.a(StatisticList.EAT_CAKE_SLICE);
-            entityhuman.getFoodData().eat(2, 0.1F);
+            // CraftBukkit start
+            // entityhuman.getFoodData().eat(2, 0.1F);
+            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).getBukkitEntity().sendHealthUpdate();
+            // CraftBukkit end
             int i = (Integer) iblockdata.get(BlockCake.BITES);
 
             if (i < 6) {