mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 02:25:28 +01:00
SPIGOT-5034: FoodLevelChangeEvent add getItem method
This commit is contained in:
parent
4090d01f6d
commit
43431ba65b
@ -27,7 +27,7 @@
|
||||
+ int oldFoodLevel = foodLevel;
|
||||
|
||||
- this.eat(foodinfo.getNutrition(), foodinfo.getSaturationModifier());
|
||||
+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, foodinfo.getNutrition() + oldFoodLevel);
|
||||
+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, foodinfo.getNutrition() + oldFoodLevel, itemstack);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.eat(event.getFoodLevel() - oldFoodLevel, foodinfo.getSaturationModifier());
|
||||
|
@ -980,7 +980,11 @@ public class CraftEventFactory {
|
||||
}
|
||||
|
||||
public static FoodLevelChangeEvent callFoodLevelChangeEvent(EntityHuman entity, int level) {
|
||||
FoodLevelChangeEvent event = new FoodLevelChangeEvent(entity.getBukkitEntity(), level);
|
||||
return callFoodLevelChangeEvent(entity, level, null);
|
||||
}
|
||||
|
||||
public static FoodLevelChangeEvent callFoodLevelChangeEvent(EntityHuman entity, int level, ItemStack item) {
|
||||
FoodLevelChangeEvent event = new FoodLevelChangeEvent(entity.getBukkitEntity(), level, (item == null) ? null : CraftItemStack.asBukkitCopy(item));
|
||||
entity.getBukkitEntity().getServer().getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user