Example #1
0
 private void initiateEntityPet() {
   this.resetEntitySize();
   this.fireProof = true;
   if (this.FIELD_JUMP == null) {
     try {
       this.FIELD_JUMP = EntityLiving.class.getDeclaredField("bc");
       this.FIELD_JUMP.setAccessible(true);
     } catch (NoSuchFieldException e) {
       e.printStackTrace();
     }
   }
   this.getBukkitEntity().setMaxHealth(pet.getPetType().getMaxHealth());
   this.setHealth((float) pet.getPetType().getMaxHealth());
   this.jumpHeight = EchoPet.getOptions().getRideJumpHeight(this.getPet().getPetType());
   this.rideSpeed = EchoPet.getOptions().getRideSpeed(this.getPet().getPetType());
   this.setPathfinding();
 }
Example #2
0
  public void onLive() {
    if (this.pet == null) {
      this.remove(false);
      return;
    }

    if (this.getPlayerOwner() == null || !this.getPlayerOwner().isOnline()) {
      EchoPet.getManager().removePet(this.getPet(), true);
      return;
    }

    if (pet.isOwnerRiding() && this.passenger == null && !pet.isOwnerInMountingProcess()) {
      pet.ownerRidePet(false);
    }

    if (!forceInvisible
        && ((CraftPlayer) this.getPlayerOwner()).getHandle().isInvisible() != this.isInvisible()
        && !this.shouldVanish) {
      this.setInvisible(!this.isInvisible());
    }

    if (((CraftPlayer) this.getPlayerOwner()).getHandle().isSneaking() != this.isSneaking()) {
      this.setSneaking(!this.isSneaking());
    }

    if (((CraftPlayer) this.getPlayerOwner()).getHandle().isSprinting() != this.isSprinting()) {
      this.setSprinting(!this.isSprinting());
    }

    if (this.getPet().isHat()) {
      this.lastYaw =
          this.yaw =
              (this.getPet().getPetType() == PetType.ENDERDRAGON
                  ? this.getPlayerOwner().getLocation().getYaw() - 180
                  : this.getPlayerOwner().getLocation().getYaw());
    }

    if (this.getPlayerOwner().isFlying()
        && EchoPet.getOptions().canFly(this.getPet().getPetType())) {
      Location petLoc = this.getLocation();
      Location ownerLoc = this.getPlayerOwner().getLocation();
      Vector v = ownerLoc.toVector().subtract(petLoc.toVector());

      double x = v.getX();
      double y = v.getY();
      double z = v.getZ();

      Vector vo = this.getPlayerOwner().getLocation().getDirection();
      if (vo.getX() > 0) {
        x -= 1.5;
      } else if (vo.getX() < 0) {
        x += 1.5;
      }
      if (vo.getZ() > 0) {
        z -= 1.5;
      } else if (vo.getZ() < 0) {
        z += 1.5;
      }

      this.setVelocity(new Vector(x, y, z).normalize().multiply(0.3F));
    }
  }
Example #3
0
 public Player getPlayerOwner() {
   return pet.getOwner();
 }