예제 #1
0
  @Override
  public boolean shouldStart() {
    if (myPet.getRangedDamage() <= 0) {
      return false;
    }
    if (!entityMyPet.canMove()) {
      return false;
    }
    if (!entityMyPet.hasTarget()) {
      return false;
    }

    EntityLiving target = ((CraftLivingEntity) this.entityMyPet.getTarget()).getHandle();

    if (target instanceof EntityArmorStand) {
      return false;
    }
    double meleeDamage = myPet.getDamage();
    if (meleeDamage > 0
        && this.entityMyPet.f(target.locX, target.getBoundingBox().b, target.locZ) < 4) {
      if (meleeDamage > rangedSkill.getDamage()) {
        return false;
      }
    }
    this.target = target;
    return true;
  }
예제 #2
0
 public RangedAttack(EntityMyPet entityMyPet, float walkSpeedModifier, float range) {
   this.entityMyPet = entityMyPet;
   this.myPet = entityMyPet.getMyPet();
   this.shootTimer = -1;
   this.lastSeenTimer = 0;
   this.walkSpeedModifier = walkSpeedModifier;
   this.range = range;
   rangedSkill = entityMyPet.getMyPet().getSkills().getSkill(Ranged.class);
 }
예제 #3
0
 private Projectiles getProjectile() {
   Skills skills = entityMyPet.getMyPet().getSkills();
   if (skills.isSkillActive(Ranged.class)) {
     return skills.getSkill(Ranged.class).getProjectile();
   }
   return Projectiles.Arrow;
 }
예제 #4
0
 public MeleeAttack(
     EntityMyPet petEntity, float walkSpeedModifier, double range, int ticksUntilNextHit) {
   this.petEntity = petEntity;
   this.myPet = petEntity.getMyPet();
   this.walkSpeedModifier = walkSpeedModifier;
   this.range = range;
   this.ticksUntilNextHit = ticksUntilNextHit;
 }
예제 #5
0
 @Override
 public boolean shouldFinish() {
   if (entityMyPet.getTarget() == null
       || !target.isAlive()
       || myPet.getRangedDamage() <= 0
       || !entityMyPet.canMove()) {
     return true;
   }
   if (this.target.getBukkitEntity() != this.myPet.getEntity().getTarget()) {
     return true;
   }
   double meleeDamage = myPet.getDamage();
   if (meleeDamage > 0
       && this.entityMyPet.f(target.locX, target.getBoundingBox().b, target.locZ) < 4) {
     if (meleeDamage > rangedSkill.getDamage()) {
       return true;
     }
   }
   return false;
 }
예제 #6
0
 @Override
 public boolean shouldFinish() {
   if (!this.petEntity.hasTarget() || !this.petEntity.canMove()) {
     return true;
   } else if (this.targetEntity.getBukkitEntity() != this.petEntity.getTarget()) {
     return true;
   }
   if (petEntity.getMyPet().getRangedDamage() > 0
       && this.petEntity.f(targetEntity.locX, targetEntity.getBoundingBox().b, targetEntity.locZ)
           >= 20) {
     return true;
   }
   return false;
 }
예제 #7
0
  public void onLivingUpdate() {
    super.onLivingUpdate();

    if (!this.onGround && this.motY < 0.0D) {
      this.motY *= 0.6D;
    }

    if (Configuration.MyPet.Chicken.CAN_LAY_EGGS && canUseItem() && --nextEggTimer <= 0) {
      world.makeSound(
          this, "mob.chicken.plop", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
      a(Items.EGG, 1);
      nextEggTimer = random.nextInt(6000) + 6000;
    }
  }
예제 #8
0
  @Override
  public boolean shouldStart() {
    if (myPet.getDamage() <= 0) {
      return false;
    }
    if (!this.petEntity.hasTarget()) {
      return false;
    }
    EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle();

    if (targetEntity instanceof EntityArmorStand) {
      return false;
    }
    if (petEntity.getMyPet().getRangedDamage() > 0
        && this.petEntity.f(targetEntity.locX, targetEntity.getBoundingBox().b, targetEntity.locZ)
            >= 20) {
      return false;
    }
    this.targetEntity = targetEntity;
    return true;
  }
예제 #9
0
  public void shootProjectile(EntityLiving target, float damage, Projectiles projectile) {
    World world = target.world;

    if (projectile == Projectiles.Arrow) {
      EntityArrow arrow = new MyPetArrow(world, entityMyPet, target, 1.6F, 1);
      arrow.b(damage);
      arrow.setCritical(false);
      entityMyPet.makeSound(
          "random.bow", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
      world.addEntity(arrow);
    } else if (projectile == Projectiles.Snowball) {
      MyPetSnowball snowball = new MyPetSnowball(world, entityMyPet);
      double distanceX = target.locX - entityMyPet.locX;
      double distanceY = target.locY + target.getHeadHeight() - 1.100000023841858D - snowball.locY;
      double distanceZ = target.locZ - entityMyPet.locZ;
      float distance20percent =
          MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F;
      snowball.setDamage(damage);
      snowball.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
      entityMyPet.makeSound(
          "random.bow", 0.5F, 0.4F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
      world.addEntity(snowball);
    } else if (projectile == Projectiles.Egg) {
      MyPetEgg egg = new MyPetEgg(world, entityMyPet);
      double distanceX = target.locX - entityMyPet.locX;
      double distanceY = target.locY + target.getHeadHeight() - 1.100000023841858D - egg.locY;
      double distanceZ = target.locZ - entityMyPet.locZ;
      float distance20percent =
          MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F;
      egg.setDamage(damage);
      egg.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
      entityMyPet.makeSound(
          "random.bow", 0.5F, 0.4F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
      world.addEntity(egg);
    } else if (projectile == Projectiles.LargeFireball) {
      double distanceX = this.target.locX - entityMyPet.locX;
      double distanceY =
          this.target.getBoundingBox().b
              + (double) (this.target.length / 2.0F)
              - (0.5D + entityMyPet.locY + (double) (entityMyPet.length / 2.0F));
      double distanceZ = this.target.locZ - entityMyPet.locZ;
      MyPetLargeFireball largeFireball =
          new MyPetLargeFireball(world, entityMyPet, distanceX, distanceY, distanceZ);
      largeFireball.locY = (entityMyPet.locY + entityMyPet.length / 2.0F + 0.5D);
      largeFireball.setDamage(damage);
      world.addEntity(largeFireball);
      world.makeSound(
          entityMyPet.locX + 0.5D,
          entityMyPet.locY + 0.5D,
          entityMyPet.locZ + 0.5D,
          "mob.ghast.fireball",
          1.0F + entityMyPet.getRandom().nextFloat(),
          entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
    } else if (projectile == Projectiles.SmallFireball) {
      double distanceX = this.target.locX - entityMyPet.locX;
      double distanceY =
          this.target.getBoundingBox().b
              + (this.target.length / 2.0F)
              - (0.5D + entityMyPet.locY + (entityMyPet.length / 2.0F));
      double distanceZ = this.target.locZ - entityMyPet.locZ;
      MyPetSmallFireball smallFireball =
          new MyPetSmallFireball(world, entityMyPet, distanceX, distanceY, distanceZ);
      smallFireball.locY = (entityMyPet.locY + entityMyPet.length / 2.0F + 0.5D);
      smallFireball.setDamage(damage);
      world.addEntity(smallFireball);
      world.makeSound(
          entityMyPet.locX + 0.5D,
          entityMyPet.locY + 0.5D,
          entityMyPet.locZ + 0.5D,
          "mob.ghast.fireball",
          1.0F + entityMyPet.getRandom().nextFloat(),
          entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
    } else if (projectile == Projectiles.WitherSkull) {
      double distanceX = this.target.locX - entityMyPet.locX;
      double distanceY =
          this.target.getBoundingBox().b
              + (double) (this.target.length / 2.0F)
              - (0.5D + entityMyPet.locY + (double) (entityMyPet.length / 2.0F));
      double distanceZ = this.target.locZ - entityMyPet.locZ;
      MyPetWitherSkull witherSkull =
          new MyPetWitherSkull(world, entityMyPet, distanceX, distanceY, distanceZ);
      witherSkull.locY = (entityMyPet.locY + entityMyPet.length / 2.0F + 0.5D);
      witherSkull.setDamage(damage);
      world.addEntity(witherSkull);
      world.makeSound(
          entityMyPet.locX + 0.5D,
          entityMyPet.locY + 0.5D,
          entityMyPet.locZ + 0.5D,
          "mob.wither.shoot",
          1.0F + entityMyPet.getRandom().nextFloat(),
          entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
    }
  }
예제 #10
0
 protected void initDatawatcher() {
   super.initDatawatcher();
   this.datawatcher.a(12, new Byte((byte) 0)); // age
 }