PaperMC/paper-server/nms-patches/net/minecraft/world/level/block/BlockCake.patch

23 lines
1 KiB
Diff
Raw Normal View History

2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/level/block/BlockCake.java
+++ b/net/minecraft/world/level/block/BlockCake.java
@@ -86,7 +86,18 @@
return EnumInteractionResult.PASS;
} 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);
+ }
+
2021-03-15 23:00:00 +01:00
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate();
+ // CraftBukkit end
int i = (Integer) iblockdata.get(BlockCake.BITES);
generatoraccess.a((Entity) entityhuman, GameEvent.EAT, blockposition);