Interface MobTargetEvent

All Superinterfaces:
Cancellable, Event, MobEvent

public interface MobTargetEvent extends MobEvent, Cancellable
Fired when a mob is about to take a new target: one it noticed, one that hurt it, or one a plugin gave it.

It does not fire when the mob keeps its target, nor when it gives up on one. Cancelling it leaves the mob with its previous target; the mob may try again later, firing the event anew. Setting the target of the mob from a listener fires a nested event.

Since:
0.1.0
  • Method Details

    • previousTarget

      @Nullable LivingEntity previousTarget()
      Returns the target the mob had, null for none.
      Returns:
      the target the mob had, null for none
      Since:
      0.1.0
    • target

      Returns the target the mob is about to take, null if a listener took it away.
      Returns:
      the target the mob is about to take, null if a listener took it away
      Since:
      0.1.0
    • setTarget

      void setTarget(@Nullable LivingEntity target)
      Gives the mob another target instead.
      Parameters:
      target - the new target; null to leave the mob without any
      Since:
      0.1.0