0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-22 10:06:16 +00:00
craftbukkit/nms-patches/net/minecraft/world/level/block/BlockCake.patch
2024-10-23 02:15:00 +11:00

23 lines
1.1 KiB
Diff

--- a/net/minecraft/world/level/block/BlockCake.java
+++ b/net/minecraft/world/level/block/BlockCake.java
@@ -98,7 +98,18 @@
return EnumInteractionResult.PASS;
} else {
entityhuman.awardStat(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);
+ }
+
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate();
+ // CraftBukkit end
int i = (Integer) iblockdata.getValue(BlockCake.BITES);
generatoraccess.gameEvent((Entity) entityhuman, (Holder) GameEvent.EAT, blockposition);