Beispiel #1
0
  public static void attack(EntityLiving handle, Entity target) {
    AttributeInstance attackDamage = handle.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE);
    float f = (float) (attackDamage == null ? 1 : attackDamage.getValue());
    int i = 0;

    if (target instanceof EntityLiving) {
      f += EnchantmentManager.a(handle.bA(), ((EntityLiving) target).getMonsterType());
      i += EnchantmentManager.a(handle);
    }

    boolean flag = target.damageEntity(DamageSource.mobAttack(handle), f);

    if (!flag) return;
    if (i > 0) {
      target.g(
          -Math.sin(handle.yaw * Math.PI / 180.0F) * i * 0.5F,
          0.1D,
          Math.cos(handle.yaw * Math.PI / 180.0F) * i * 0.5F);
      handle.motX *= 0.6D;
      handle.motZ *= 0.6D;
    }

    int fireAspectLevel = EnchantmentManager.getFireAspectEnchantmentLevel(handle);

    if (fireAspectLevel > 0) {
      target.setOnFire(fireAspectLevel * 4);
    }
  }
Beispiel #2
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;
  }
Beispiel #3
0
 public static void setHeadYaw(Entity en, float yaw) {
   if (!(en instanceof EntityLiving)) return;
   EntityLiving handle = (EntityLiving) en;
   yaw = clampYaw(yaw);
   handle.aK = yaw;
   if (!(handle instanceof EntityHuman)) handle.aI = yaw;
   handle.aL = yaw;
 }
Beispiel #4
0
  public void addPotionGraphicalEffect(CraftMyPet entity, int color, int duration) {
    final EntityLiving entityLiving = entity.getHandle();
    entityLiving.getDataWatcher().watch(7, new Integer(color));

    Bukkit.getScheduler()
        .scheduleSyncDelayedTask(
            MyPetPlugin.getPlugin(),
            new Runnable() {
              public void run() {
                int potionEffects = 0;
                if (!entityLiving.effects.isEmpty()) {
                  potionEffects = PotionBrewer.a(entityLiving.effects.values());
                }
                entityLiving.getDataWatcher().watch(7, new Integer(potionEffects));
              }
            },
            duration);
  }
Beispiel #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;
 }
Beispiel #6
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;
  }
Beispiel #7
0
 @Override
 public void tick() {
   this.petEntity.getControllerLook().a(targetEntity, 30.0F, 30.0F);
   if (--this.timeUntilNextNavigationUpdate <= 0) {
     this.timeUntilNextNavigationUpdate = (4 + this.petEntity.getRandom().nextInt(7));
     this.petEntity.getPetNavigation().navigateTo((LivingEntity) targetEntity.getBukkitEntity());
   }
   if (this.petEntity.f(targetEntity.locX, targetEntity.getBoundingBox().b, targetEntity.locZ)
               - (targetEntity.length * (2. / 3.))
           <= this.range
       && this.ticksUntilNextHitLeft-- <= 0) {
     if (this.petEntity.getEntitySenses().a(targetEntity)) {
       this.ticksUntilNextHitLeft = ticksUntilNextHit;
       if (this.petEntity instanceof MyPetEquipment) {
         if (((MyPetEquipment) this.petEntity).getEquipment(EquipmentSlot.MainHand) != null) {
           this.petEntity.bv(); // -> swingItem()
         }
       }
       this.petEntity.attack(targetEntity);
     }
   }
 }
Beispiel #8
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;
 }
Beispiel #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);
    }
  }
Beispiel #10
0
 public static void setVerticalMovement(org.bukkit.entity.Entity bukkitEntity, double d) {
   if (!bukkitEntity.getType().isAlive()) return;
   EntityLiving handle = NMS.getHandle((LivingEntity) bukkitEntity);
   handle.ba = (float) d;
 }
Beispiel #11
0
 public static void setStepHeight(EntityLiving entity, float height) {
   entity.S = height;
 }
Beispiel #12
0
  public static void flyingMoveLogic(EntityLiving entity, float f, float f1) {
    if (entity.bM()) {
      if (entity.V()) {
        double d0 = entity.locY;
        float f3 = 0.8F;
        float f4 = 0.02F;
        float f2 = EnchantmentManager.b(entity);
        if (f2 > 3.0F) {
          f2 = 3.0F;
        }

        if (!entity.onGround) {
          f2 *= 0.5F;
        }

        if (f2 > 0.0F) {
          f3 += (0.5460001F - f3) * f2 / 3.0F;
          f4 += (entity.bI() * 1.0F - f4) * f2 / 3.0F;
        }

        entity.a(f, f1, f4);
        entity.move(entity.motX, entity.motY, entity.motZ);
        entity.motX *= f3;
        entity.motY *= 0.800000011920929D;
        entity.motZ *= f3;
        entity.motY -= 0.02D;
        if ((entity.positionChanged)
            && (entity.c(
                entity.motX, entity.motY + 0.6000000238418579D - entity.locY + d0, entity.motZ)))
          entity.motY = 0.300000011920929D;
      } else if (entity.ab()) {
        double d0 = entity.locY;
        entity.a(f, f1, 0.02F);
        entity.move(entity.motX, entity.motY, entity.motZ);
        entity.motX *= 0.5D;
        entity.motY *= 0.5D;
        entity.motZ *= 0.5D;
        entity.motY -= 0.02D;
        if ((entity.positionChanged)
            && (entity.c(
                entity.motX, entity.motY + 0.6000000238418579D - entity.locY + d0, entity.motZ)))
          entity.motY = 0.300000011920929D;
      } else {
        float f5 = 0.91F;

        if (entity.onGround) {
          f5 =
              entity
                      .world
                      .getType(
                          new BlockPosition(
                              MathHelper.floor(entity.locX),
                              MathHelper.floor(entity.getBoundingBox().b) - 1,
                              MathHelper.floor(entity.locZ)))
                      .getBlock()
                      .frictionFactor
                  * 0.91F;
        }

        float f6 = 0.1627714F / (f5 * f5 * f5);
        float f3;
        if (entity.onGround) f3 = entity.bI() * f6;
        else {
          f3 = entity.aM;
        }

        entity.a(f, f1, f3);
        f5 = 0.91F;
        if (entity.onGround) {
          f5 =
              entity
                      .world
                      .getType(
                          new BlockPosition(
                              MathHelper.floor(entity.locX),
                              MathHelper.floor(entity.getBoundingBox().b) - 1,
                              MathHelper.floor(entity.locZ)))
                      .getBlock()
                      .frictionFactor
                  * 0.91F;
        }

        if (entity.k_()) {
          float f4 = 0.15F;
          entity.motX = MathHelper.a(entity.motX, -f4, f4);
          entity.motZ = MathHelper.a(entity.motZ, -f4, f4);
          entity.fallDistance = 0.0F;
          if (entity.motY < -0.15D) {
            entity.motY = -0.15D;
          }

          boolean flag = (entity.isSneaking()) && ((entity instanceof EntityHuman));

          if ((flag) && (entity.motY < 0.0D)) {
            entity.motY = 0.0D;
          }
        }

        entity.move(entity.motX, entity.motY, entity.motZ);
        if ((entity.positionChanged) && (entity.k_())) {
          entity.motY = 0.2D;
        }

        if ((entity.world.isClientSide)
            && ((!entity.world.isLoaded(new BlockPosition((int) entity.locX, 0, (int) entity.locZ)))
                || (!entity
                    .world
                    .getChunkAtWorldCoords(
                        new BlockPosition((int) entity.locX, 0, (int) entity.locZ))
                    .o()))) {
          if (entity.locY > 0.0D) entity.motY = -0.1D;
          else entity.motY = 0.0D;
        } else {
          entity.motY -= 0.08D;
        }

        entity.motY *= 0.9800000190734863D;
        entity.motX *= f5;
        entity.motZ *= f5;
      }
    }

    entity.aA = entity.aB;
    double d0 = entity.locX - entity.lastX;
    double d1 = entity.locZ - entity.lastZ;

    float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;
    if (f2 > 1.0F) {
      f2 = 1.0F;
    }

    entity.aB += (f2 - entity.aB) * 0.4F;
    entity.aC += entity.aB;
  }