Program: 117146
Project: 117146
Buggy source:
@Override public void onLivingUpdate(){
  if (ticksExisted % 20 == 0 && !worldObj.isRemote) {
    LogHelper.dev("String_Node_Str" + this.getEntityString());
    LogHelper.dev("String_Node_Str" + this.isDead);
    LogHelper.dev("String_Node_Str" + this.isRiding());
  }
  if (!homeSet) {
    homeX=(int)posX;
    homeY=(int)posY;
    homeZ=(int)posZ;
    targetX=homeX;
    targetZ=homeZ;
    homeSet=true;
  }
  if (crystals == null)   updateCrystals();
  float f;
  float f1;
  float moveSpeedMultiplier=behaviour.dragonSpeed;
  if (this.worldObj.isRemote) {
    f=MathHelper.cos(this.animTime * (float)Math.PI * 2.0F);
    f1=MathHelper.cos(this.prevAnimTime * (float)Math.PI * 2.0F);
    if (f1 <= -0.3F && f >= -0.3F) {
      if (deathTicks <= 0) {
        this.worldObj.playSound(this.posX,this.posY,this.posZ,SoundEvents.ENTITY_ENDERDRAGON_FLAP,SoundCategory.HOSTILE,5.0F,0.8F + this.rand.nextFloat() * 0.3F,false);
      }
    }
  }
  this.prevAnimTime=this.animTime;
  float f2;
  if (!worldObj.isRemote) {
    updateTarget();
    if (worldObj.getClosestPlayer(posX,posY,posZ,500,true) == null && getDistance(homeX,homeY,homeZ) < 100) {
      DragonChunkLoader.stopLoading(this);
    }
 else {
      if (getHealth() > 0) {
        DragonChunkLoader.updateLoaded(this);
      }
    }
    if (deathTicks > 0) {
      DragonChunkLoader.stopLoading(this);
    }
    customAIUpdate();
    if (behaviour == EnumBehaviour.FIREBOMB && Utils.getDistanceAtoB(posX,posY,posZ,homeX,homeY + 30,homeZ) <= 3) {
      moveSpeedMultiplier=0;
    }
  }
  if (this.getHealth() <= 0.0F) {
    behaviour=EnumBehaviour.DEAD;
    f=(this.rand.nextFloat() - 0.5F) * 8.0F;
    f1=(this.rand.nextFloat() - 0.5F) * 4.0F;
    f2=(this.rand.nextFloat() - 0.5F) * 8.0F;
    worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE,this.posX + (double)f,this.posY + 2.0D + (double)f1,this.posZ + (double)f2,0.0D,0.0D,0.0D);
  }
  this.updateDragonEnderCrystal();
  f=0.2F / (MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F);
  f*=moveSpeedMultiplier == 0 ? 1 : moveSpeedMultiplier;
  f*=(float)Math.pow(2.0D,this.motionY);
  if (this.slowed) {
    this.animTime+=f * 0.5F;
  }
 else {
    this.animTime+=f;
  }
  this.rotationYaw=MathHelper.wrapDegrees(this.rotationYaw);
  if (this.ringBufferIndex < 0) {
    for (int i=0; i < this.ringBuffer.length; ++i) {
      this.ringBuffer[i][0]=(double)this.rotationYaw;
      this.ringBuffer[i][1]=this.posY;
    }
  }
  if (++this.ringBufferIndex == this.ringBuffer.length) {
    this.ringBufferIndex=0;
  }
  this.ringBuffer[this.ringBufferIndex][0]=(double)this.rotationYaw;
  this.ringBuffer[this.ringBufferIndex][1]=this.posY;
  double d0;
  double d1;
  double d2;
  double d10;
  float f12;
  if (this.worldObj.isRemote) {
    if (this.newPosRotationIncrements > 0) {
      d10=this.posX + (this.interpTargetX - this.posX) / (double)this.newPosRotationIncrements;
      d0=this.posY + (this.interpTargetY - this.posY) / (double)this.newPosRotationIncrements;
      d1=this.posZ + (this.interpTargetZ - this.posZ) / (double)this.newPosRotationIncrements;
      d2=MathHelper.wrapDegrees(this.interpTargetYaw - (double)this.rotationYaw);
      this.rotationYaw=(float)((double)this.rotationYaw + d2 / (double)this.newPosRotationIncrements);
      this.rotationPitch=(float)((double)this.rotationPitch + (this.interpTargetPitch - (double)this.rotationPitch) / (double)this.newPosRotationIncrements);
      --this.newPosRotationIncrements;
      this.setPosition(d10,d0,d1);
      this.setRotation(this.rotationYaw,this.rotationPitch);
    }
  }
 else {
    if (target != null && (target.isDead || !target.isEntityAlive() || target.getDistance(posX,posY,posZ) > 300)) {
      target=null;
    }
    d10=this.targetX - this.posX;
    d0=this.targetY - this.posY;
    d1=this.targetZ - this.posZ;
    d2=d10 * d10 + d0 * d0 + d1 * d1;
    if (this.target != null) {
      if (behaviour == EnumBehaviour.CIRCLE_PLAYER) {
        this.targetX=this.target.posX + (int)(Math.cos(circlePosition) * 60);
        this.targetZ=this.target.posZ + (int)(Math.sin(circlePosition) * 60);
        moveSpeedMultiplier=1F + Math.min(((float)Utils.getDistanceAtoB(targetX,targetZ,posX,posZ) / 50) * 3F,3F);
      }
 else {
        this.targetX=this.target.posX;
        this.targetZ=this.target.posZ;
      }
      double d3=this.targetX - this.posX;
      double d5=this.targetZ - this.posZ;
      double d7=Math.sqrt(d3 * d3 + d5 * d5);
      double d8=0.4000000059604645D + d7 / 80.0D - 1.0D;
      if (d8 > 10.0D) {
        d8=10.0D;
      }
      this.targetY=this.target.getEntityBoundingBox().minY + d8 + (behaviour == EnumBehaviour.CIRCLE_PLAYER ? 25 : 0);
    }
 else     if (behaviour != EnumBehaviour.FIREBOMB) {
      this.targetX+=this.rand.nextGaussian() * 2.0D;
      this.targetZ+=this.rand.nextGaussian() * 2.0D;
    }
    if (this.forceNewTarget || d2 < 100.0D || d2 > 22500.0D || this.isCollidedHorizontally || this.isCollidedVertically) {
      this.setNewTarget();
    }
    d0/=(double)MathHelper.sqrt_double(d10 * d10 + d1 * d1);
    f12=0.6F;
    if (d0 < (double)(-f12)) {
      d0=(double)(-f12);
    }
    if (d0 > (double)f12) {
      d0=(double)f12;
    }
    this.motionY+=d0 * 0.10000000149011612D;
    this.rotationYaw=MathHelper.wrapDegrees(this.rotationYaw);
    double d4=180.0D - Math.atan2(d10,d1) * 180.0D / Math.PI;
    double d6=MathHelper.wrapDegrees(d4 - (double)this.rotationYaw);
    if (d6 > 50.0D) {
      d6=50.0D;
    }
    if (d6 < -50.0D) {
      d6=-50.0D;
    }
    Vec3d vec3=new Vec3d(this.targetX - this.posX,this.targetY - this.posY,this.targetZ - this.posZ).normalize();
    Vec3d vec32=new Vec3d((double)MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F),this.motionY,(double)(-MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F))).normalize();
    float f5=(float)(vec32.dotProduct(vec3) + 0.5D) / 1.5F;
    if (f5 < 0.0F) {
      f5=0.0F;
    }
    this.randomYawVelocity*=0.8F;
    float f6=MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0F + 1.0F;
    double d9=Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0D + 1.0D;
    if (d9 > 40.0D) {
      d9=40.0D;
    }
    this.randomYawVelocity=(float)((double)this.randomYawVelocity + d6 * (0.699999988079071D / d9 / (double)f6));
    this.rotationYaw+=this.randomYawVelocity * 0.1F;
    float f7=(float)(2.0D / (d9 + 1.0D));
    float f8=0.06F;
    this.moveRelative(0.0F,-1.0F,f8 * (f5 * f7 + (1.0F - f7)));
    if (this.slowed) {
      this.moveEntity(this.motionX * 0.800000011920929D * moveSpeedMultiplier,this.motionY * 0.800000011920929D * moveSpeedMultiplier,this.motionZ * 0.800000011920929D * moveSpeedMultiplier);
    }
 else {
      this.moveEntity(this.motionX * moveSpeedMultiplier,this.motionY * moveSpeedMultiplier,this.motionZ * moveSpeedMultiplier);
    }
    Vec3d vec31=new Vec3d(this.motionX,this.motionY,this.motionZ).normalize();
    float f9=(float)(vec31.dotProduct(vec32) + 1.0D) / 2.0F;
    f9=0.8F + 0.15F * f9;
    this.motionX*=(double)f9;
    this.motionZ*=(double)f9;
    this.motionY*=0.9100000262260437D;
  }
  this.renderYawOffset=this.rotationYaw;
  this.dragonPartHead.width=this.dragonPartHead.height=3.0F;
  this.dragonPartTail1.width=this.dragonPartTail1.height=2.0F;
  this.dragonPartTail2.width=this.dragonPartTail2.height=2.0F;
  this.dragonPartTail3.width=this.dragonPartTail3.height=2.0F;
  this.dragonPartBody.height=3.0F;
  this.dragonPartBody.width=5.0F;
  this.dragonPartWing1.height=2.0F;
  this.dragonPartWing1.width=4.0F;
  this.dragonPartWing2.height=3.0F;
  this.dragonPartWing2.width=4.0F;
  f1=(float)(this.getMovementOffsets(5,1.0F)[1] - this.getMovementOffsets(10,1.0F)[1]) * 10.0F / 180.0F * (float)Math.PI;
  f2=MathHelper.cos(f1);
  float f10=-MathHelper.sin(f1);
  float f3=this.rotationYaw * (float)Math.PI / 180.0F;
  float f11=MathHelper.sin(f3);
  float f4=MathHelper.cos(f3);
  this.dragonPartBody.onUpdate();
  this.dragonPartBody.setLocationAndAngles(this.posX + (double)(f11 * 0.5F),this.posY,this.posZ - (double)(f4 * 0.5F),0.0F,0.0F);
  this.dragonPartWing1.onUpdate();
  this.dragonPartWing1.setLocationAndAngles(this.posX + (double)(f4 * 4.5F),this.posY + 2.0D,this.posZ + (double)(f11 * 4.5F),0.0F,0.0F);
  this.dragonPartWing2.onUpdate();
  this.dragonPartWing2.setLocationAndAngles(this.posX - (double)(f4 * 4.5F),this.posY + 2.0D,this.posZ - (double)(f11 * 4.5F),0.0F,0.0F);
  if (!this.worldObj.isRemote && this.hurtTime == 0) {
    this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this,this.dragonPartWing1.getEntityBoundingBox().expand(4.0D,2.0D,4.0D).offset(0.0D,-2.0D,0.0D)));
    this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this,this.dragonPartWing2.getEntityBoundingBox().expand(4.0D,2.0D,4.0D).offset(0.0D,-2.0D,0.0D)));
    this.attackEntitiesInList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this,this.dragonPartHead.getEntityBoundingBox().expand(1.0D,1.0D,1.0D)));
  }
  double[] adouble1=this.getMovementOffsets(5,1.0F);
  double[] adouble=this.getMovementOffsets(0,1.0F);
  f12=MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F - this.randomYawVelocity * 0.01F);
  float f13=MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F - this.randomYawVelocity * 0.01F);
  this.dragonPartHead.onUpdate();
  this.dragonPartHead.setLocationAndAngles(this.posX + (double)(f12 * 5.5F * f2),this.posY + (adouble[1] - adouble1[1]) * 1.0D + (double)(f10 * 5.5F),this.posZ - (double)(f13 * 5.5F * f2),0.0F,0.0F);
  for (int j=0; j < 3; ++j) {
    EntityDragonPart entitydragonpart=null;
    if (j == 0) {
      entitydragonpart=this.dragonPartTail1;
    }
    if (j == 1) {
      entitydragonpart=this.dragonPartTail2;
    }
    if (j == 2) {
      entitydragonpart=this.dragonPartTail3;
    }
    double[] adouble2=this.getMovementOffsets(12 + j * 2,1.0F);
    float f14=this.rotationYaw * (float)Math.PI / 180.0F + this.simplifyAngle(adouble2[0] - adouble1[0]) * (float)Math.PI / 180.0F * 1.0F;
    float f15=MathHelper.sin(f14);
    float f16=MathHelper.cos(f14);
    float f17=1.5F;
    float f18=(float)(j + 1) * 2.0F;
    entitydragonpart.onUpdate();
    entitydragonpart.setLocationAndAngles(this.posX - (double)((f11 * f17 + f15 * f18) * f2),this.posY + (adouble2[1] - adouble1[1]) * 1.0D - (double)((f18 + f17) * f10) + 1.5D,this.posZ + (double)((f4 * f17 + f16 * f18) * f2),0.0F,0.0F);
  }
  if (!this.worldObj.isRemote) {
    this.slowed=this.destroyBlocksInAABB(this.dragonPartHead.getEntityBoundingBox()) | this.destroyBlocksInAABB(this.dragonPartBody.getEntityBoundingBox());
  }
}

Fixed version (ground truth):
@Override public void onLivingUpdate(){
  if (ticksExisted % 20 == 0 && !worldObj.isRemote) {
    LogHelper.dev("String_Node_Str" + this.getEntityString());
    LogHelper.dev("String_Node_Str" + this.isDead);
    LogHelper.dev("String_Node_Str" + this.isRiding());
  }
  if (!homeSet) {
    homeX=(int)posX;
    homeY=(int)posY;
    homeZ=(int)posZ;
    targetX=homeX;
    targetZ=homeZ;
    homeSet=true;
  }
  if (crystals == null)   updateCrystals();
  float f;
  float f1;
  float moveSpeedMultiplier=behaviour.dragonSpeed;
  if (this.worldObj.isRemote) {
    f=MathHelper.cos(this.animTime * (float)Math.PI * 2.0F);
    f1=MathHelper.cos(this.prevAnimTime * (float)Math.PI * 2.0F);
    if (f1 <= -0.3F && f >= -0.3F) {
      if (deathTicks <= 0) {
        this.worldObj.playSound(this.posX,this.posY,this.posZ,SoundEvents.ENTITY_ENDERDRAGON_FLAP,SoundCategory.HOSTILE,5.0F,0.8F + this.rand.nextFloat() * 0.3F,false);
      }
    }
  }
  this.prevAnimTime=this.animTime;
  float f2;
  if (!worldObj.isRemote) {
    updateTarget();
    if (worldObj.getClosestPlayer(posX,posY,posZ,500,true) == null && getDistance(homeX,homeY,homeZ) < 100) {
      LogHelper.dev("String_Node_Str");
      DragonChunkLoader.updateLoaded(this);
      double posX=this.posX - (this.posX % 16) + 8;
      double posZ=this.posZ - (this.posZ % 16) + 8;
      setPosition(posX,posY,posZ);
      behaviour=EnumBehaviour.ROAMING;
      motionX=motionY=motionZ=0;
      DragonChunkLoader.stopLoading(this);
      LogHelper.dev("String_Node_Str");
      return;
    }
 else {
      if (getHealth() > 0) {
        DragonChunkLoader.updateLoaded(this);
      }
    }
    if (deathTicks > 0) {
      DragonChunkLoader.stopLoading(this);
    }
    customAIUpdate();
    if (behaviour == EnumBehaviour.FIREBOMB && Utils.getDistanceAtoB(posX,posY,posZ,homeX,homeY + 30,homeZ) <= 3) {
      moveSpeedMultiplier=0;
    }
  }
  if (this.getHealth() <= 0.0F) {
    behaviour=EnumBehaviour.DEAD;
    f=(this.rand.nextFloat() - 0.5F) * 8.0F;
    f1=(this.rand.nextFloat() - 0.5F) * 4.0F;
    f2=(this.rand.nextFloat() - 0.5F) * 8.0F;
    worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE,this.posX + (double)f,this.posY + 2.0D + (double)f1,this.posZ + (double)f2,0.0D,0.0D,0.0D);
  }
  this.updateDragonEnderCrystal();
  f=0.2F / (MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F);
  f*=moveSpeedMultiplier == 0 ? 1 : moveSpeedMultiplier;
  f*=(float)Math.pow(2.0D,this.motionY);
  if (this.slowed) {
    this.animTime+=f * 0.5F;
  }
 else {
    this.animTime+=f;
  }
  this.rotationYaw=MathHelper.wrapDegrees(this.rotationYaw);
  if (this.ringBufferIndex < 0) {
    for (int i=0; i < this.ringBuffer.length; ++i) {
      this.ringBuffer[i][0]=(double)this.rotationYaw;
      this.ringBuffer[i][1]=this.posY;
    }
  }
  if (++this.ringBufferIndex == this.ringBuffer.length) {
    this.ringBufferIndex=0;
  }
  this.ringBuffer[this.ringBufferIndex][0]=(double)this.rotationYaw;
  this.ringBuffer[this.ringBufferIndex][1]=this.posY;
  double d0;
  double d1;
  double d2;
  double d10;
  float f12;
  if (this.worldObj.isRemote) {
    if (this.newPosRotationIncrements > 0) {
      d10=this.posX + (this.interpTargetX - this.posX) / (double)this.newPosRotationIncrements;
      d0=this.posY + (this.interpTargetY - this.posY) / (double)this.newPosRotationIncrements;
      d1=this.posZ + (this.interpTargetZ - this.posZ) / (double)this.newPosRotationIncrements;
      d2=MathHelper.wrapDegrees(this.interpTargetYaw - (double)this.rotationYaw);
      this.rotationYaw=(float)((double)this.rotationYaw + d2 / (double)this.newPosRotationIncrements);
      this.rotationPitch=(float)((double)this.rotationPitch + (this.interpTargetPitch - (double)this.rotationPitch) / (double)this.newPosRotationIncrements);
      --this.newPosRotationIncrements;
      this.setPosition(d10,d0,d1);
      this.setRotation(this.rotationYaw,this.rotationPitch);
    }
  }
 else {
    if (target != null && (target.isDead || !target.isEntityAlive() || target.getDistance(posX,posY,posZ) > 300)) {
      target=null;
    }
    d10=this.targetX - this.posX;
    d0=this.targetY - this.posY;
    d1=this.targetZ - this.posZ;
    d2=d10 * d10 + d0 * d0 + d1 * d1;
    if (this.target != null) {
      if (behaviour == EnumBehaviour.CIRCLE_PLAYER) {
        this.targetX=this.target.posX + (int)(Math.cos(circlePosition) * 60);
        this.targetZ=this.target.posZ + (int)(Math.sin(circlePosition) * 60);
        moveSpeedMultiplier=1F + Math.min(((float)Utils.getDistanceAtoB(targetX,targetZ,posX,posZ) / 50) * 3F,3F);
      }
 else {
        this.targetX=this.target.posX;
        this.targetZ=this.target.posZ;
      }
      double d3=this.targetX - this.posX;
      double d5=this.targetZ - this.posZ;
      double d7=Math.sqrt(d3 * d3 + d5 * d5);
      double d8=0.4000000059604645D + d7 / 80.0D - 1.0D;
      if (d8 > 10.0D) {
        d8=10.0D;
      }
      this.targetY=this.target.getEntityBoundingBox().minY + d8 + (behaviour == EnumBehaviour.CIRCLE_PLAYER ? 25 : 0);
    }
 else     if (behaviour != EnumBehaviour.FIREBOMB) {
      this.targetX+=this.rand.nextGaussian() * 2.0D;
      this.targetZ+=this.rand.nextGaussian() * 2.0D;
    }
    if (this.forceNewTarget || d2 < 100.0D || d2 > 22500.0D || this.isCollidedHorizontally || this.isCollidedVertically) {
      this.setNewTarget();
    }
    d0/=(double)MathHelper.sqrt_double(d10 * d10 + d1 * d1);
    f12=0.6F;
    if (d0 < (double)(-f12)) {
      d0=(double)(-f12);
    }
    if (d0 > (double)f12) {
      d0=(double)f12;
    }
    this.motionY+=d0 * 0.10000000149011612D;
    this.rotationYaw=MathHelper.wrapDegrees(this.rotationYaw);
    double d4=180.0D - Math.atan2(d10,d1) * 180.0D / Math.PI;
    double d6=MathHelper.wrapDegrees(d4 - (double)this.rotationYaw);
    if (d6 > 50.0D) {
      d6=50.0D;
    }
    if (d6 < -50.0D) {
      d6=-50.0D;
    }
    Vec3d vec3=new Vec3d(this.targetX - this.posX,this.targetY - this.posY,this.targetZ - this.posZ).normalize();
    Vec3d vec32=new Vec3d((double)MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F),this.motionY,(double)(-MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F))).normalize();
    float f5=(float)(vec32.dotProduct(vec3) + 0.5D) / 1.5F;
    if (f5 < 0.0F) {
      f5=0.0F;
    }
    this.randomYawVelocity*=0.8F;
    float f6=MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0F + 1.0F;
    double d9=Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0D + 1.0D;
    if (d9 > 40.0D) {
      d9=40.0D;
    }
    this.randomYawVelocity=(float)((double)this.randomYawVelocity + d6 * (0.699999988079071D / d9 / (double)f6));
    this.rotationYaw+=this.randomYawVelocity * 0.1F;
    float f7=(float)(2.0D / (d9 + 1.0D));
    float f8=0.06F;
    this.moveRelative(0.0F,-1.0F,f8 * (f5 * f7 + (1.0F - f7)));
    if (this.slowed) {
      this.moveEntity(this.motionX * 0.800000011920929D * moveSpeedMultiplier,this.motionY * 0.800000011920929D * moveSpeedMultiplier,this.motionZ * 0.800000011920929D * moveSpeedMultiplier);
    }
 else {
      this.moveEntity(this.motionX * moveSpeedMultiplier,this.motionY * moveSpeedMultiplier,this.motionZ * moveSpeedMultiplier);
    }
    Vec3d vec31=new Vec3d(this.motionX,this.motionY,this.motionZ).normalize();
    float f9=(float)(vec31.dotProduct(vec32) + 1.0D) / 2.0F;
    f9=0.8F + 0.15F * f9;
    this.motionX*=(double)f9;
    this.motionZ*=(double)f9;
    this.motionY*=0.9100000262260437D;
  }
  this.renderYawOffset=this.rotationYaw;
  this.dragonPartHead.width=this.dragonPartHead.height=3.0F;
  this.dragonPartTail1.width=this.dragonPartTail1.height=2.0F;
  this.dragonPartTail2.width=this.dragonPartTail2.height=2.0F;
  this.dragonPartTail3.width=this.dragonPartTail3.height=2.0F;
  this.dragonPartBody.height=3.0F;
  this.dragonPartBody.width=5.0F;
  this.dragonPartWing1.height=2.0F;
  this.dragonPartWing1.width=4.0F;
  this.dragonPartWing2.height=3.0F;
  this.dragonPartWing2.width=4.0F;
  f1=(float)(this.getMovementOffsets(5,1.0F)[1] - this.getMovementOffsets(10,1.0F)[1]) * 10.0F / 180.0F * (float)Math.PI;
  f2=MathHelper.cos(f1);
  float f10=-MathHelper.sin(f1);
  float f3=this.rotationYaw * (float)Math.PI / 180.0F;
  float f11=MathHelper.sin(f3);
  float f4=MathHelper.cos(f3);
  this.dragonPartBody.onUpdate();
  this.dragonPartBody.setLocationAndAngles(this.posX + (double)(f11 * 0.5F),this.posY,this.posZ - (double)(f4 * 0.5F),0.0F,0.0F);
  this.dragonPartWing1.onUpdate();
  this.dragonPartWing1.setLocationAndAngles(this.posX + (double)(f4 * 4.5F),this.posY + 2.0D,this.posZ + (double)(f11 * 4.5F),0.0F,0.0F);
  this.dragonPartWing2.onUpdate();
  this.dragonPartWing2.setLocationAndAngles(this.posX - (double)(f4 * 4.5F),this.posY + 2.0D,this.posZ - (double)(f11 * 4.5F),0.0F,0.0F);
  if (!this.worldObj.isRemote && this.hurtTime == 0) {
    this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this,this.dragonPartWing1.getEntityBoundingBox().expand(4.0D,2.0D,4.0D).offset(0.0D,-2.0D,0.0D)));
    this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this,this.dragonPartWing2.getEntityBoundingBox().expand(4.0D,2.0D,4.0D).offset(0.0D,-2.0D,0.0D)));
    this.attackEntitiesInList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this,this.dragonPartHead.getEntityBoundingBox().expand(1.0D,1.0D,1.0D)));
  }
  double[] adouble1=this.getMovementOffsets(5,1.0F);
  double[] adouble=this.getMovementOffsets(0,1.0F);
  f12=MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F - this.randomYawVelocity * 0.01F);
  float f13=MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F - this.randomYawVelocity * 0.01F);
  this.dragonPartHead.onUpdate();
  this.dragonPartHead.setLocationAndAngles(this.posX + (double)(f12 * 5.5F * f2),this.posY + (adouble[1] - adouble1[1]) * 1.0D + (double)(f10 * 5.5F),this.posZ - (double)(f13 * 5.5F * f2),0.0F,0.0F);
  for (int j=0; j < 3; ++j) {
    EntityDragonPart entitydragonpart=null;
    if (j == 0) {
      entitydragonpart=this.dragonPartTail1;
    }
    if (j == 1) {
      entitydragonpart=this.dragonPartTail2;
    }
    if (j == 2) {
      entitydragonpart=this.dragonPartTail3;
    }
    double[] adouble2=this.getMovementOffsets(12 + j * 2,1.0F);
    float f14=this.rotationYaw * (float)Math.PI / 180.0F + this.simplifyAngle(adouble2[0] - adouble1[0]) * (float)Math.PI / 180.0F * 1.0F;
    float f15=MathHelper.sin(f14);
    float f16=MathHelper.cos(f14);
    float f17=1.5F;
    float f18=(float)(j + 1) * 2.0F;
    entitydragonpart.onUpdate();
    entitydragonpart.setLocationAndAngles(this.posX - (double)((f11 * f17 + f15 * f18) * f2),this.posY + (adouble2[1] - adouble1[1]) * 1.0D - (double)((f18 + f17) * f10) + 1.5D,this.posZ + (double)((f4 * f17 + f16 * f18) * f2),0.0F,0.0F);
  }
  if (!this.worldObj.isRemote) {
    this.slowed=this.destroyBlocksInAABB(this.dragonPartHead.getEntityBoundingBox()) | this.destroyBlocksInAABB(this.dragonPartBody.getEntityBoundingBox());
  }
}