Archiviert
13
0

Fire FoodLevelChangeEvent when eating cake. Fixes BUKKIT-2242

Dieser Commit ist enthalten in:
T00thpick1 2013-07-19 16:42:05 -04:00 committet von Nate Mortensen
Ursprung 3fb4ccb62c
Commit 6482b6f0bd

Datei anzeigen

@ -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) {