コード例 #1
0
 @Override
 public void startExecuting() {
   if (attacker.getHealth() <= 150)
     attacker.getNavigator().setPath(entityPathEntity, speedTowardsTarget);
   else attacker.getNavigator().setPath(entityPathEntity, 0);
   findAttemptCount = 0;
 }
コード例 #2
0
  /** Updates the task */
  @Override
  public void updateTask() {
    double d = 25D; // 5 blocks away
    double d1 =
        entityHost.getDistanceSq(
            attackTarget.posX, attackTarget.boundingBox.minY, attackTarget.posZ);
    boolean flag = entityHost.getEntitySenses().canSee(attackTarget);

    if (flag) {
      stuckTime++;
    } else {
      stuckTime = 0;
    }

    if (d1 > d || stuckTime < 20) {
      entityHost.getNavigator().tryMoveToEntityLiving(attackTarget, moveSpeed);
    } else {
      entityHost.getNavigator().clearPathEntity();
    }

    entityHost.getLookHelper().setLookPositionWithEntity(attackTarget, 30F, 30F);
    rangedAttackTime = Math.max(rangedAttackTime - 1, 0);

    if (rangedAttackTime > 0) {
      return;
    }

    if (d1 > d || !flag) {
      return;
    } else {
      doRangedAttack();
      rangedAttackTime = maxRangedAttackTime;
      return;
    }
  }
コード例 #3
0
 public EntityAIAvoidEntity(
     EntityCreature par1EntityCreature, Class par2Class, float par3, double par4, double par6) {
   this.theEntity = par1EntityCreature;
   this.targetEntityClass = par2Class;
   this.distanceFromEntity = par3;
   this.farSpeed = par4;
   this.nearSpeed = par6;
   this.entityPathNavigate = par1EntityCreature.getNavigator();
   this.setMutexBits(1);
 }
コード例 #4
0
 @Override
 public boolean shouldExecute() {
   EntityLivingBase entitylivingbase = attacker.getAttackTarget();
   if (entitylivingbase == null) return false;
   else if (!entitylivingbase.isEntityAlive()) return false;
   else if (classTarget != null && !classTarget.isAssignableFrom(entitylivingbase.getClass()))
     return false;
   else if (--findAttemptCount <= 0) {
     entityPathEntity = attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
     findAttemptCount = 4 + attacker.getRNG().nextInt(7);
     return entityPathEntity != null;
   } else return true;
 }
コード例 #5
0
 @Override
 public boolean continueExecuting() {
   EntityLivingBase entitylivingbase = attacker.getAttackTarget();
   return entitylivingbase == null
       ? false
       : !entitylivingbase.isEntityAlive()
           ? false
           : !longMemory
               ? !attacker.getNavigator().noPath()
               : attacker.isWithinHomeDistance(
                   MathHelper.floor_double(entitylivingbase.posX),
                   MathHelper.floor_double(entitylivingbase.posY),
                   MathHelper.floor_double(entitylivingbase.posZ));
 }
コード例 #6
0
 /** Returns whether an in-progress EntityAIBase should continue executing */
 @Override
 public boolean continueExecuting() {
   return shouldExecute() || !entityHost.getNavigator().noPath();
 }
コード例 #7
0
  @Override
  public void updateTask() {
    EntityLivingBase entitylivingbase = attacker.getAttackTarget();
    attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
    if ((longMemory && attacker.getHealth() <= 150
            || attacker.getEntitySenses().canSee(entitylivingbase))
        && --findAttemptCount <= 0
        && attacker.getHealth() <= 150) {
      findAttemptCount = failedPathFindingPenalty + 4 + attacker.getRNG().nextInt(7);
      attacker.getNavigator().tryMoveToEntityLiving(entitylivingbase, speedTowardsTarget);
      if (attacker.getNavigator().getPath() != null) {
        PathPoint finalPathPoint = attacker.getNavigator().getPath().getFinalPathPoint();
        if (finalPathPoint != null
            && entitylivingbase.getDistanceSq(
                    finalPathPoint.xCoord, finalPathPoint.yCoord, finalPathPoint.zCoord)
                < 1D) failedPathFindingPenalty = 0;
        else failedPathFindingPenalty += 10;
      } else failedPathFindingPenalty += 10;
    }
    attackTick = Math.max(attackTick - 1, 0);
    double d0 = attacker.width * 1F * attacker.width * 1F + entitylivingbase.width;
    if (attacker.getDistanceSq(
            entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ)
        <= d0)
      if (attackTick <= 0) {
        attackTick = 10;
        attacker.attackEntityAsMob(entitylivingbase);
        entitylivingbase.attackEntityFrom(DamageSource.causeMobDamage(attacker), 4.0F);
        entitylivingbase.addVelocity(
            -MathHelper.sin(attacker.rotationYaw * 3.141593F / 180.0F) * 0.5F,
            0.1D,
            MathHelper.cos(attacker.rotationYaw * 3.141593F / 180.0F) * 0.5F);
      }

    if (attacker.getDistanceSq(
                entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ)
            > d0 + 1D
        && attacker.getDistanceSq(
                entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ)
            < d0 + 256.0D
        && attacker.getHealth() < 150)
      if (attackTick <= 0) {
        ++shouldDo;
        if (shouldDo == 1) attackTick = 40;
        else if (shouldDo <= 2) attackTick = 20;
        else {
          attackTick = 20;
          shouldDo = 0;
        }
        if (shouldDo == 1) {
          Vec3 look = attacker.getLookVec();
          double direction = Math.toRadians(attacker.renderYawOffset);
          EntityPoisonJet jet = new EntityPoisonJet(worldObj, attacker);
          jet.setPosition(
              attacker.posX + -Math.sin(direction) * 3.5D,
              attacker.posY + attacker.height * 0.5,
              attacker.posZ + Math.cos(direction) * 3.5D);
          jet.motionX = look.xCoord * 1.0;
          jet.motionY = look.yCoord * 2.2;
          jet.motionZ = look.zCoord * 1.0;
          worldObj.spawnEntityInWorld(jet);
        }
      }

    if (attacker.getDistanceSq(
                entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ)
            > d0 + 9D
        && attacker.getDistanceSq(
                entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ)
            < d0 + 256.0D
        && attacker.getHealth() > 150) {
      if (attackTick <= 0) {
        ++shouldDo;
        if (shouldDo == 1) attackTick = 200;
        else if (shouldDo <= 2) attackTick = 20;
        else {
          attackTick = 40;
          shouldDo = 0;
        }
        if (shouldDo == 1) {
          Vec3 look = attacker.getLookVec();
          double direction = Math.toRadians(attacker.renderYawOffset);
          EntityTarantulaEgg babyEgg = new EntityTarantulaEgg(worldObj, attacker);
          babyEgg.setPosition(
              attacker.posX + -Math.sin(direction) * 3.5D,
              attacker.posY + attacker.height,
              attacker.posZ + Math.cos(direction) * 3.5D);
          babyEgg.motionX = look.xCoord * 1.0;
          babyEgg.motionY = look.yCoord * 2.2;
          babyEgg.motionZ = look.zCoord * 1.0;
          worldObj.spawnEntityInWorld(babyEgg);
        }

        if (worldObj.rand.nextInt(3) == 1) {
          attackTick = 30;
          attacker.motionY = 0.61999998688697815D;
          jumpAttack = true;
        }
      }
      if (jumpAttack && attacker.motionY == -0.0784000015258789D) {
        areaOfEffect();
        ((EntityTarantulaMiniboss) attacker).spawnBlamParticles();
        jumpAttack = false;
      }
    }
  }
コード例 #8
0
 @Override
 public void resetTask() {
   attacker.getNavigator().clearPathEntity();
 }