summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockCake.patch
blob: 8824ae28a4acb5ad2593eaf06dd50eb9ad05961e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--- /home/matt/mc-dev-private//net/minecraft/server/BlockCake.java	2015-02-26 22:40:22.047608145 +0000
+++ src/main/java/net/minecraft/server/BlockCake.java	2015-02-26 22:40:22.047608145 +0000
@@ -55,7 +55,18 @@
     private void b(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
         if (entityhuman.j(false)) {
             entityhuman.b(StatisticList.H);
-            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).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel));
+            // CraftBukkit end
             int i = ((Integer) iblockdata.get(BlockCake.BITES)).intValue();
 
             if (i < 6) {