diff --git a/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java index 221cf69837..7f4c5ea860 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java @@ -3,7 +3,9 @@ package org.bukkit.event.entity; import org.bukkit.entity.HumanEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a human entity's food level changes @@ -12,10 +14,16 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private int level; + private final ItemStack item; public FoodLevelChangeEvent(@NotNull final HumanEntity what, final int level) { + this(what, level, null); + } + + public FoodLevelChangeEvent(@NotNull final HumanEntity what, final int level, @Nullable final ItemStack item) { super(what); this.level = level; + this.item = item; } @NotNull @@ -24,6 +32,16 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { return (HumanEntity) entity; } + /** + * Gets the item that triggered this event, if any. + * + * @return an ItemStack for the item being consumed + */ + @Nullable + public ItemStack getItem() { + return (item == null) ? null : item.clone(); + } + /** * Gets the resultant food level that the entity involved in this event * should be set to.