mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 04:09:54 +01:00
Fire FoodLevelChangeEvent when eating cake. Fixes BUKKIT-2242
This commit is contained in:
parent
3fb4ccb62c
commit
6482b6f0bd
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user