3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-17 13:30:06 +01:00

Fixed saturation handling for FoodLevelChange event.

Dieser Commit ist enthalten in:
EvilSeph 2011-09-26 14:17:32 -04:00
Ursprung 31eef6e001
Commit 484376bbac

Datei anzeigen

@ -29,12 +29,13 @@ public class ItemFood extends Item {
public ItemStack b(ItemStack itemstack, World world, EntityHuman entityhuman) { public ItemStack b(ItemStack itemstack, World world, EntityHuman entityhuman) {
--itemstack.count; --itemstack.count;
// CraftBukkit start // CraftBukkit start
int oldFoodLevel = entityhuman.getFoodData().foodLevel;
FoodLevelChangeEvent event = new FoodLevelChangeEvent(entityhuman.getBukkitEntity(), Math.min(this.k() + entityhuman.getFoodData().foodLevel, 20)); FoodLevelChangeEvent event = new FoodLevelChangeEvent(entityhuman.getBukkitEntity(), Math.min(this.k() + entityhuman.getFoodData().foodLevel, 20));
entityhuman.world.getServer().getPluginManager().callEvent(event); entityhuman.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
entityhuman.getFoodData().foodLevel = event.getFoodLevel(); entityhuman.getFoodData().a(event.getFoodLevel() - oldFoodLevel, this.l());
entityhuman.getFoodData().saturationLevel = Math.min(entityhuman.getFoodData().saturationLevel + (float) event.getFoodLevel() - entityhuman.getFoodData().foodLevel * this.l() * 2.0F, (float) entityhuman.getFoodData().foodLevel);
} }
// CraftBukkit end // CraftBukkit end