Class EntityIntelligent

All Implemented Interfaces:
EntityControlUtils, LogicalUtils, EntityAgeable, EntityAsyncPrepare, EntityDamageable, EntityNameable, Metadatable, Cloneable
Direct Known Subclasses:
EntityAnimal, EntityIntelligentHuman, EntityMob

@PowerNukkitXOnly @Since("1.6.0.0-PNX") public abstract class EntityIntelligent extends EntityPhysical implements LogicalUtils, EntityControlUtils
EntityIntelligent抽象了一个具有行为组IBehaviorGroup(也就是具有AI)的实体
  • Field Details

    • EMPTY_BEHAVIOR_GROUP

      public static final IBehaviorGroup EMPTY_BEHAVIOR_GROUP
    • behaviorGroup

      @Since("1.19.60-r1") protected IBehaviorGroup behaviorGroup
    • isActive

      protected boolean isActive
      是否为活跃实体,如果实体不活跃,就应当降低AI运行频率
  • Constructor Details

  • Method Details

    • initEntity

      protected void initEntity()
      Description copied from class: Entity
      实体初始化顺序,先初始化Entity类字段->Entity构造函数->进入init方法->调用initEntity方法->子类字段初始化->子类构造函数

      用于初始化实体的NBT和实体字段的方法

      Entity initialization order, first initialize the Entity class field->Entity constructor->Enter the init method->Call the init Entity method-> subclass field initialization-> subclass constructor

      The method used to initialize the NBT and entity fields of the entity

      Overrides:
      initEntity in class EntityLiving
    • getBehaviorGroup

      public IBehaviorGroup getBehaviorGroup()
      返回此实体持有的行为组IBehaviorGroup
      默认实现只会返回一个空行为EmptyBehaviorGroup常量,若你想让实体具有AI,你需要覆写此方法
      Returns:
      此实体持有的行为组
    • requireBehaviorGroup

      @Since("1.19.60-r1") protected IBehaviorGroup requireBehaviorGroup()
      请求一个行为组实例,此方法在实体初始化行为组时调用
      Returns:
      新创建的行为组
    • asyncPrepare

      public void asyncPrepare(int currentTick)
      Description copied from interface: EntityAsyncPrepare
      该方法将被并行执行,每一刻都执行一次,并保证每一次onUpdate之前都执行完毕
      Specified by:
      asyncPrepare in interface EntityAsyncPrepare
      Overrides:
      asyncPrepare in class EntityPhysical
      Parameters:
      currentTick - 当前游戏刻
    • saveNBT

      public void saveNBT()
      Overrides:
      saveNBT in class EntityLiving
    • attack

      public boolean attack(EntityDamageEvent source)
      Description copied from class: Entity
      当一个实体被攻击时(即接受一个实体伤害事件 这个事件可以是由其他实体攻击导致,也可能是自然伤害)调用.

      Called when an entity is attacked (i.e. receives an entity damage event. This event can be caused by an attack by another entity, or it can be a natural damage).

      Overrides:
      attack in class EntityLiving
      Parameters:
      source - 记录伤害源的事件
      Record the event of the source of the attack
      Returns:
      是否攻击成功
      Whether the attack was successful
    • onInteract

      public boolean onInteract(Player player, Item item, Vector3 clickedPos)
      Specified by:
      onInteract in interface EntityNameable
      Overrides:
      onInteract in class EntityCreature
    • getMemoryStorage

      public IMemoryStorage getMemoryStorage()
      Specified by:
      getMemoryStorage in interface EntityControlUtils
    • getJumpingMotion

      public double getJumpingMotion(double jumpY)
      返回实体在跳跃时要增加的motion y
      Parameters:
      jumpY - 跳跃的高度
      Returns:
      实体要增加的motion y
    • enableHeadYaw

      public boolean enableHeadYaw()
      Overrides:
      enableHeadYaw in class Entity
    • isActive

      public boolean isActive()
      是否为活跃实体,如果实体不活跃,就应当降低AI运行频率