private void l() {
   this.d.f(new BlockPosition(0, 128, 0));
   EntityEnderDragon var1 = new EntityEnderDragon(this.d);
   var1.setPositionRotation(0.0D, 128.0D, 0.0D, this.d.random.nextFloat() * 360.0F, 0.0F);
   this.d.addEntity((Entity) var1);
   this.m = var1.getUniqueId();
 }
  public void b() {
    this.c.c(!this.k);
    if (++this.j >= 20) {
      this.i();
      this.j = 0;
    }

    if (!this.c.c().isEmpty()) {
      List var1;
      if (this.n) {
        a.info("Scanning for legacy world dragon fight...");
        this.h();
        this.n = false;
        if (this.f()) {
          a.info("Found that the dragon has been killed in this world already.");
          this.l = true;
        } else {
          a.info("Found that the dragon has not yet been killed in this world.");
          this.l = false;
        }

        var1 =
            this.d.getEntities(
                (Class) EntityEnderDragon.class, (Predicate) IEntitySelector.IS_ALIVE);
        if (!var1.isEmpty()) {
          EntityEnderDragon var2 = (EntityEnderDragon) var1.get(0);
          this.m = var2.getUniqueId();
          a.info("Found that there\'s a dragon still alive (" + var2 + ")");
          this.k = false;
        } else {
          this.k = true;
        }

        if (!this.l && this.k) {
          this.k = false;
        }
      }

      if (!this.k) {
        if (this.m == null || ++this.g >= 1200) {
          this.h();
          var1 =
              this.d.getEntities(
                  (Class) EntityEnderDragon.class, (Predicate) IEntitySelector.IS_ALIVE);
          if (!var1.isEmpty()) {
            this.m = ((EntityEnderDragon) var1.get(0)).getUniqueId();
          } else {
            this.l();
          }

          this.g = 0;
        }

        if (++this.i >= 100) {
          this.j();
          this.i = 0;
        }
      }
    }
  }
 public void a(EntityEnderCrystal var1, DamageSource var2) {
   this.j();
   Entity var3 = this.d.getEntityByUUID(this.m);
   if (var3 instanceof EntityEnderDragon) {
     ((EntityEnderDragon) var3).a(new BlockPosition(var1), var2);
   }
 }
 public void a(EntityEnderDragon var1) {
   if (var1.getUniqueId().equals(this.m)) {
     this.l = true;
     this.k = true;
     this.c.a(0.0F);
     this.c.c(false);
     this.a(true);
     this.k();
   }
 }
 public void b(EntityEnderDragon var1) {
   if (var1.getUniqueId().equals(this.m)) {
     this.c.a(var1.getHealth() / var1.getMaxHealth());
     this.g = 0;
   }
 }