mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-03 05:26:50 +01:00
Fixed FoodLevelChange event adding too much to the food level.
This commit is contained in:
parent
a7717d4d79
commit
e08535d688
1 changed files with 3 additions and 2 deletions
|
@ -29,11 +29,12 @@ 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
|
||||||
FoodLevelChangeEvent event = new FoodLevelChangeEvent(entityhuman.getBukkitEntity(), Math.min(this.k() + entityhuman.foodData.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().a(event.getFoodLevel(), this.l());
|
entityhuman.getFoodData().foodLevel = event.getFoodLevel();
|
||||||
|
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue