Class LivingChangeTargetEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.event.entity.living.LivingEvent
net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent
All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent

public class LivingChangeTargetEvent extends LivingEvent implements net.neoforged.bus.api.ICancellableEvent
This event allows you to change what target an entity is about to have.

This event is fired via the CommonHooks.onLivingChangeTarget(LivingEntity, LivingEntity, ILivingTargetType)

This event is ICancellableEvent.

If you cancel this event, the target will stay the same to what the entity already is targeting and not be changed.

This event is fired on the NeoForge.EVENT_BUS.

  • Field Details

  • Constructor Details

  • Method Details

    • getNewAboutToBeSetTarget

      public @Nullable LivingEntity getNewAboutToBeSetTarget()
      Returns the new target that this entity will begin to track..
      Returns:
      the new target that this entity will begin to track.
    • setNewAboutToBeSetTarget

      public void setNewAboutToBeSetTarget(@Nullable LivingEntity newAboutToBeSetTarget)
      Sets the new target this entity shall have.
      Parameters:
      newAboutToBeSetTarget - The new target that this entity will begin to track
    • getTargetType

      Returns the living target type..
      Returns:
      the living target type.
    • getOriginalAboutToBeSetTarget

      public @Nullable LivingEntity getOriginalAboutToBeSetTarget()
      Returns the original entity MC intended to use as a target before firing this event..
      Returns:
      the original entity MC intended to use as a target before firing this event.