Class PetInteractEvent

All Implemented Interfaces:
Cancellable
Direct Known Subclasses:
PetFeedEvent, PetSitEvent

public class PetInteractEvent extends CancellablePetEvent
Base class for pet right-click interaction events. Used directly only as a type for listeners that want to catch any interaction; the built-in firing sites all dispatch concrete subclasses.

Listeners receive instances via subclasses: PetFeedEvent (right-click with food) and PetSitEvent (right-click with the sit-toggle item). Listening for PetInteractEvent is equivalent to listening for both subclasses.

Cancellable: cancellation suppresses the interaction; the concrete subclass defines what that means in detail.

Item: getItem() is the ItemStack the player was holding when the interaction fired. May be null for interactions that aren't item-driven — PetSitEvent (sit-toggle is non-item) is the built-in example.

  • Constructor Details

    • PetInteractEvent

      public PetInteractEvent(Pet pet, ItemStack item)
      Creates the event for a right-click on a pet.
      Parameters:
      pet - the pet being interacted with
      item - the held item, or null if the interaction is not item-driven
  • Method Details

    • getHandlerList

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

      public @NonNull HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getPet

      public Pet getPet()
      The pet being interacted with.
      Specified by:
      getPet in class PetEvent
      Returns:
      the pet being interacted with
    • getItem

      public ItemStack getItem()
      The item the player was holding, or null for an interaction that is not item-driven (PetSitEvent is the built-in example).
      Returns:
      the held item, or null when the interaction is not item-driven