类 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
所有已实现的接口:
net.neoforged.bus.api.ICancellableEvent

public class LivingChangeTargetEvent extends LivingEvent implements net.neoforged.bus.api.ICancellableEvent
This event allows you to change the target an entity has.
This event is fired before
引用无效
LivingSetAttackTargetEvent
.

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

getOriginalAboutToBeSetTarget() returns the target that should originally be set. The return value cannot be affected by calling setNewAboutToBeSetTarget(LivingEntity).
getNewAboutToBeSetTarget() returns the new target that this entity will have. The return value can be affected by calling setNewAboutToBeSetTarget(LivingEntity).
getTargetType() returns the target type that caused the change of targets.

This event is ICancellableEvent.

If you cancel this event, the target will not be changed and it will stay the same. Cancelling this event will prevent
引用无效
LivingSetAttackTargetEvent
from being posted.

This event does not have a result.
引用无效
Event.HasResult


This event is fired on the NeoForge.EVENT_BUS.
  • 字段详细资料

  • 构造器详细资料

  • 方法详细资料

    • getNewAboutToBeSetTarget

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

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

      返回 the living target type.。
      返回:
      the living target type.
    • getOriginalAboutToBeSetTarget

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