コード例 #1
0
  @Override
  public boolean update() {
    EntityLiving entity = this.getEntityHandle();
    NMSUtil.getControllerLook(entity).a(this.m_target, 30, 30);
    if ((this.m_ignoreSight || NMSUtil.getEntitySenses(entity).canSee(this.m_target))
        && --this.m_moveTick <= 0) {
      this.m_moveTick = 4 + entity.aC().nextInt(7);
      this.getRemoteEntity()
          .move(
              (LivingEntity) this.m_target.getBukkitEntity(),
              (this.m_speed == -1 ? this.getRemoteEntity().getSpeed() : this.m_speed));
    }

    this.m_attackTick = Math.max(this.m_attackTick - 1, 0);
    double minDist = entity.width * 2 * entity.width * 2;
    if (this.m_attackTick <= 0
        && entity.e(this.m_target.locX, this.m_target.boundingBox.b, this.m_target.locZ)
            <= minDist) {
      this.m_attackTick = 20;
      if (entity.aY() != null) this.getEntityHandle().aR();

      this.attack(this.m_target.getBukkitEntity());
    }
    return true;
  }
コード例 #2
0
  @Override
  public boolean shouldExecute() {
    if (this.getEntityHandle() == null) return false;

    EntityLiving entityTarget = NMSUtil.getGoalTarget(this.getEntityHandle());

    if (entityTarget == null) return false;
    else if (this.m_toAttack != null && !this.m_toAttack.isAssignableFrom(entityTarget.getClass()))
      return false;
    else {
      this.m_target = entityTarget;
      this.m_path = this.getNavigation().a(this.m_target);
      return this.m_path != null;
    }
  }