Class PetFeedEvent

All Implemented Interfaces:
Cancellable

public class PetFeedEvent extends PetInteractEvent
Fired when an owner right-clicks a pet with a food ItemStack. Subclass of PetInteractEvent — extends the right-click hook with food-specific fields.

Fires from Pet#mobInteract on player-pet right-click and from the self-feed branch when the pet auto-eats a held item.

Cancellable (inherited): cancellation suppresses the feed action entirely — no saturation gain, no item consumption, no heal.

Mutable fields:

  • Constructor Details

    • PetFeedEvent

      public PetFeedEvent(Pet pet, ItemStack item, double saturation, PetFeedEvent.Result result)
      Creates the event for a pet about to be fed.
      Parameters:
      pet - the pet being fed
      item - the food item
      saturation - the saturation the feed restores
      result - the reaction to play
  • Method Details

    • getHandlerList

      public static HandlerList getHandlerList()
      Returns the handler list for this event type.
      Returns:
      the shared HandlerList every PetFeedEvent is dispatched through
    • getHandlers

      public @NonNull HandlerList getHandlers()
      Overrides:
      getHandlers in class PetInteractEvent
    • setSaturation

      public void setSaturation(double saturation)
      The saturation this feed restores. Defaults to the food item's vanilla saturation value.
      Parameters:
      saturation - the value to set
    • setResult

      public void setResult(PetFeedEvent.Result result)
      The reaction the pet plays for this feed.
      Parameters:
      result - the value to set
    • getSaturation

      public double getSaturation()
      The saturation this feed restores. Defaults to the food item's vanilla saturation value.
      Returns:
      the saturation this feed restores
    • getResult

      public PetFeedEvent.Result getResult()
      The reaction the pet plays for this feed.
      Returns:
      the reaction the pet plays