Class MeleeAttackExecutor

java.lang.Object
cn.nukkit.entity.ai.executor.MeleeAttackExecutor
All Implemented Interfaces:
EntityControl, IBehaviorExecutor
Direct Known Subclasses:
WolfAttackExecutor

@PowerNukkitXOnly @Since("1.6.0.0-PNX") public class MeleeAttackExecutor extends Object implements EntityControl, IBehaviorExecutor
通用近战攻击执行器.

Universal melee attack actuator.

  • Field Details

    • memory

      protected MemoryType<? extends Entity> memory
    • speed

      protected float speed
    • maxSenseRangeSquared

      protected int maxSenseRangeSquared
    • clearDataWhenLose

      protected boolean clearDataWhenLose
    • coolDown

      protected int coolDown
    • attackTick

      protected int attackTick
    • oldTarget

      protected Vector3 oldTarget
    • target

      @Since("1.19.30-r1") protected Entity target
      用来指定特定的攻击目标.

      Used to specify a specific attack target.

    • lookTarget

      @Since("1.19.30-r1") protected Vector3 lookTarget
      用来指定特定的视线目标

      Used to specify a specific look target.

    • effects

      @Since("1.19.63-r2") protected Effect[] effects
      给予目标药水效果

      Give target potion effect

  • Constructor Details

    • MeleeAttackExecutor

      public MeleeAttackExecutor(MemoryType<? extends Entity> memory, float speed, int maxSenseRange, boolean clearDataWhenLose, int coolDown)
    • MeleeAttackExecutor

      public MeleeAttackExecutor(MemoryType<? extends Entity> memory, float speed, int maxSenseRange, boolean clearDataWhenLose, int coolDown, Effect... effects)
      近战攻击执行器
      Parameters:
      memory - 用于读取攻击目标的记忆
      Used to read the memory of the attack target
      speed - 移动向攻击目标的速度
      The speed of movement towards the attacking target
      maxSenseRange - 最大获取攻击目标范围
      The maximum range of attack targets
      clearDataWhenLose - 失去目标时清空记忆
      Clear your memory when you lose your target
      coolDown - 攻击冷却时间(单位tick)
      Attack cooldown (in tick)
      effects - 给予目标药水效果
      Give the target potion effect
  • Method Details

    • execute

      public boolean execute(EntityIntelligent entity)
      Description copied from interface: IBehaviorExecutor
      调度器将会持续执行此执行器,直到返回false,或者执行器被中断
      此方法每gt都会调用

      The scheduler will continue to execute this executor until it returns false or the executor is interrupted
      This method will be called every gt

      Specified by:
      execute in interface IBehaviorExecutor
      Parameters:
      entity - 执行目标实体
      Returns:
      boolean
    • onStop

      public void onStop(EntityIntelligent entity)
      Description copied from interface: IBehaviorExecutor
      行为正常结束时(execute()方法返回false)调用

      Called when the behavior ends normally (the execute() method returns false)

      Specified by:
      onStop in interface IBehaviorExecutor
      Parameters:
      entity - 目标实体
    • onInterrupt

      public void onInterrupt(EntityIntelligent entity)
      Description copied from interface: IBehaviorExecutor
      行为非正常中断时(例如被更高级行为覆盖)调用

      Called when behavior breaks abnormally (e.g. overridden by higher-level behavior)

      Specified by:
      onInterrupt in interface IBehaviorExecutor
      Parameters:
      entity - 目标实体
    • playAttackAnimation

      protected void playAttackAnimation(EntityIntelligent entity)