Program: 109826
Project: 109826
Buggy source:
@Override public void onLivingUpdate(){
  super.onLivingUpdate();
  if (this instanceof IPredatorDiet && world.getDifficulty().equals(EnumDifficulty.PEACEFUL)) {
    boolean hasPlayer=false;
    Class[] prey=((IPredatorDiet)this).getPreyClasses();
    for (    Class c : prey) {
      if (c.getName().equals(EntityPlayer.class.getName())) {
        hasPlayer=true;
        break;
      }
    }
    if (hasPlayer) {
      this.setDead();
    }
  }
  if (world.isRemote) {
    this.rotationPitch=-this.swimPitch;
    this.rotationYaw=-this.swimYaw;
    this.rotationYawHead=-this.swimYaw;
    this.prevRotationYawHead=-this.prevSwimYaw;
    this.renderYawOffset=0;
    this.cameraPitch=-this.swimPitch;
    this.prevRotationPitch=-this.prevSwimPitch;
    this.prevRotationYaw=-this.prevSwimYaw;
    this.prevSwimYaw=this.swimYaw;
    this.swimYaw=this.getDataManager().get(SWIMYAW);
    this.prevSwimPitch=this.swimPitch;
    this.swimPitch=this.getDataManager().get(SWIMPITCH);
    return;
  }
  if (this.isInWater()) {
    this.outOfWaterTime=0;
    BlockPos bp=new BlockPos((int)posX,(int)posY - 2,(int)posZ);
    bp=new BlockPos((int)posX,(int)posY + 1,(int)posZ);
    if (!this.world.getBlockState(bp).getMaterial().isLiquid()) {
      if (this.swimPitch > 0f) {
        Vec3d angle=this.getHeading();
        double frontDist=5f;
        Vec3d diff=new Vec3d(posX + (angle.xCoord * frontDist),posY + angle.yCoord,posZ + (angle.zCoord * frontDist));
        this.isPanicking=false;
        this.setTargetHeading(diff.xCoord,posY - 2,diff.zCoord,true);
      }
    }
    if (rand.nextInt(20) == 0) {
      this.setRandomTargetHeading();
    }
    if (canAggress) {
      if (this.ticksExisted % 200 == 0 && this.aggressTarget == null || !world.getLoadedEntityList().contains(aggressTarget)) {
        List<Entity> list=world.getEntitiesInAABBexcluding(this,this.getEntityBoundingBox().expand(20D,20D,20D).offset(0.0D,-8.0D,0.0D),EntitySelectors.IS_ALIVE);
        if (list.size() > 0) {
          Entity ent=list.get(rand.nextInt(list.size()));
          boolean skip=false;
          if (ent.equals(this))           skip=true;
          if (ent.getClass().getName().equals(this.getClass().getName()))           skip=true;
          if (this instanceof IPredatorDiet) {
            Class[] prey=((IPredatorDiet)this).getPreyClasses();
            boolean contains=false;
            for (int i=0; i < prey.length; i++) {
              if (prey[i].getName().equals(ent.getClass().getName())) {
                contains=true;
              }
            }
            if (!contains) {
              skip=true;
            }
          }
          if (!ent.isInWater())           skip=true;
          if (!this.canEntityBeSeen(ent))           skip=true;
          if (!skip) {
            if (ent instanceof EntityLivingBase) {
              if (((EntityLivingBase)ent).isInWater()) {
                this.aggressTarget=ent;
              }
            }
          }
        }
      }
      if (rand.nextInt(200) == 0) {
        this.aggressTarget=null;
        this.setRandomTargetHeading();
      }
    }
    if (this.ticksExisted % 80 == 0) {
      Vec3d angle=this.getHeading();
      double frontDist=2f;
      double behindDist=8f;
      Vec3d diff=new Vec3d(posX + (angle.xCoord * frontDist),posY + angle.yCoord,posZ + (angle.zCoord * frontDist));
      bp=new BlockPos((int)diff.xCoord,(int)posY,(int)diff.zCoord);
      if (!this.world.getBlockState(bp).getMaterial().isLiquid()) {
        Vec3d behind=new Vec3d(posX - (angle.xCoord * behindDist),posY + angle.yCoord,posZ - (angle.zCoord * behindDist));
        this.setTargetHeading(behind.xCoord,posY + 5,behind.zCoord,true);
      }
    }
    if (this.fleeFromPlayers && ticksExisted % 80 == 0) {
      EntityPlayer closest=world.getClosestPlayerToEntity(this,this.fleeDistance);
      if (closest != null) {
        if (closest.isInWater()) {
          this.fleeEntity(closest);
          this.isPanicking=true;
        }
      }
 else {
        this.isPanicking=false;
      }
    }
 else {
      this.isPanicking=false;
    }
    if (this.canSchool) {
      if (!isLeader && leader == null) {
        List<Entity> ents=world.getLoadedEntityList();
        for (int i=0; i < ents.size(); i++) {
          if (ents.get(i) instanceof EntityTropicraftWaterBase) {
            EntityTropicraftWaterBase f=((EntityTropicraftWaterBase)ents.get(i));
            if (f.getClass().getName().equals(this.getClass().getName())) {
              if (f instanceof IAtlasFish && this instanceof IAtlasFish) {
                int slot=((IAtlasFish)f).getAtlasSlot();
                if (((IAtlasFish)this).getAtlasSlot() != slot) {
                  continue;
                }
              }
              if (f.isLeader) {
                this.leader=f;
              }
            }
          }
        }
        if (this.ticksExisted > 200 && leader == null) {
          this.markAsLeader();
        }
      }
      if (this.ticksExisted > 200 && leader == null) {
        this.markAsLeader();
      }
    }
    if (this.aggressTarget != null) {
      if (this.getDistanceSqToEntity(this.aggressTarget) < 1.2f) {
        if (this.aggressTarget instanceof EntityLivingBase)         ((EntityLivingBase)this.aggressTarget).attackEntityFrom(DamageSource.cactus,1);
        this.setRandomTargetHeading();
      }
 else {
        if (this.canEntityBeSeen(this.aggressTarget) && this.ticksExisted % 5 == 0) {
          this.setTargetHeading(this.aggressTarget.posX,this.aggressTarget.posY,this.aggressTarget.posZ,true);
        }
      }
      if (this.aggressTarget != null) {
        if (!this.aggressTarget.isInWater()) {
          this.aggressTarget=null;
          this.setRandomTargetHeading();
        }
      }
    }
    if (!this.isAggressing && this.ticksExisted % 80 == 0) {
      List<Entity> ents=world.getLoadedEntityList();
      for (int i=0; i < ents.size(); i++) {
        if (ents.get(i) instanceof EntityTropicraftWaterBase) {
          EntityTropicraftWaterBase f=((EntityTropicraftWaterBase)ents.get(i));
          if (this.canEntityBeSeen(f) && this.getDistanceSqToEntity(f) < 2D)           if (f.aggressTarget != null)           if (f.aggressTarget.equals(this)) {
            this.fleeEntity(f);
            this.isPanicking=true;
            break;
          }
        }
      }
    }
    bp=new BlockPos((int)posX,(int)posY - 2,(int)posZ);
    if (!this.world.getBlockState(bp).getMaterial().isLiquid()) {
      if (this.swimPitch < 0f) {
        this.swimPitch+=2f;
      }
    }
    if (this.canSchool) {
      if (this.leader != null && !isLeader) {
        this.setTargetHeading(this.leader.posX,this.leader.posY - 5 + rand.nextInt(10),this.leader.posZ,true);
        if (leader.aggressTarget != null) {
          this.aggressTarget=leader.aggressTarget;
        }
      }
    }
    float swimSpeedTurn=this.swimSpeedTurn;
    if (this.targetVectorHeading != null) {
      this.swimYaw=lerp(this.swimYaw,-this.targetVectorHeading.x,swimSpeedTurn * 2f);
      this.swimPitch=lerp(this.swimPitch,-this.targetVectorHeading.y,swimSpeedTurn * 2f);
    }
  }
  if (!this.isInWater()) {
    this.outOfWaterTime++;
    this.setTargetHeading(posX,posY - 1,posZ,false);
  }
  float currentSpeed=this.swimSpeedCurrent;
  float desiredSpeed=this.swimSpeedDefault;
  if (this.aggressTarget != null) {
    if (this.getDistanceSqToEntity(this.aggressTarget) < 10f) {
      desiredSpeed=this.swimSpeedCharging;
    }
 else {
      desiredSpeed=this.swimSpeedChasing;
    }
    if (!world.getLoadedEntityList().contains(this.aggressTarget) || this.aggressTarget.isDead) {
      this.aggressTarget=null;
      this.setRandomTargetHeading();
    }
  }
  if (this.isPanicking) {
    desiredSpeed=this.swimSpeedPanic;
  }
  if (this.swimSpeedCurrent < desiredSpeed) {
    this.swimSpeedCurrent+=this.swimAccelRate;
  }
  if (this.swimSpeedCurrent > desiredSpeed) {
    this.swimSpeedCurrent-=this.swimDecelRate;
  }
  currentSpeed*=0.1f;
  if (this.isInWater()) {
    motionX=currentSpeed * Math.sin(this.swimYaw * (Math.PI / 180.0));
    motionZ=currentSpeed * Math.cos(this.swimYaw * (Math.PI / 180.0));
    motionY=(currentSpeed) * Math.sin((this.swimPitch) * (Math.PI / 180.0));
    fallVelocity=0f;
  }
  if (!this.isInWater()) {
    if (this.onGround) {
      if (rand.nextInt(6) == 0) {
        this.motionX+=rand.nextBoolean() ? rand.nextFloat() / 8 : -rand.nextFloat() / 8;
        this.motionZ+=rand.nextBoolean() ? rand.nextFloat() / 8 : -rand.nextFloat() / 8;
      }
      this.motionX*=0.5f;
      this.motionZ*=0.5f;
      if (this.ticksExisted % 4 == 0)       this.fallVelocity=-.02f;
      if (rand.nextInt(20) == 0 || this.hurtTime > 0) {
        this.fallVelocity=-.03f;
        this.swimPitch=25f;
      }
    }
    if (this.swimPitch > 0f) {
      this.swimPitch-=5f;
    }
    if (this.ticksExisted % 20 == 0) {
      this.outOfWaterAngle=rand.nextInt(360);
    }
    float turnSpeed=5f;
    if (this.hurtTime > 0) {
      turnSpeed=15f;
    }
    if (this.swimYaw > this.outOfWaterAngle) {
      this.swimYaw-=turnSpeed;
    }
    if (this.swimYaw < this.outOfWaterAngle) {
      this.swimYaw+=turnSpeed;
    }
    this.motionY-=this.fallVelocity;
    this.fallVelocity+=(this.fallGravity / 10);
  }
  if (swimPitch > 45f) {
    swimPitch=45f;
  }
  syncSwimAngles();
  prevSwimPitch=swimPitch;
  prevSwimYaw=swimYaw;
}

Fixed version (ground truth):
@Override public void onLivingUpdate(){
  super.onLivingUpdate();
  if (this instanceof IPredatorDiet && world.getDifficulty().equals(EnumDifficulty.PEACEFUL)) {
    boolean hasPlayer=false;
    Class[] prey=((IPredatorDiet)this).getPreyClasses();
    for (    Class c : prey) {
      if (c.getName().equals(EntityPlayer.class.getName())) {
        hasPlayer=true;
        break;
      }
    }
    if (hasPlayer) {
      this.setDead();
    }
  }
  if (world.isRemote) {
    this.rotationPitch=-this.swimPitch;
    this.rotationYaw=-this.swimYaw;
    this.rotationYawHead=-this.swimYaw;
    this.prevRotationYawHead=-this.prevSwimYaw;
    this.renderYawOffset=0;
    this.cameraPitch=-this.swimPitch;
    this.prevRotationPitch=-this.prevSwimPitch;
    this.prevRotationYaw=-this.prevSwimYaw;
    this.prevSwimYaw=this.swimYaw;
    this.swimYaw=this.getDataManager().get(SWIMYAW);
    this.prevSwimPitch=this.swimPitch;
    this.swimPitch=this.getDataManager().get(SWIMPITCH);
    return;
  }
  if (this.isInWater()) {
    this.outOfWaterTime=0;
    BlockPos bp=new BlockPos((int)posX,(int)posY - 2,(int)posZ);
    bp=new BlockPos((int)posX,(int)posY + 1,(int)posZ);
    if (!this.world.getBlockState(bp).getMaterial().isLiquid()) {
      if (this.swimPitch > 0f) {
        Vec3d angle=this.getHeading();
        double frontDist=5f;
        Vec3d diff=new Vec3d(posX + (angle.xCoord * frontDist),posY + angle.yCoord,posZ + (angle.zCoord * frontDist));
        this.isPanicking=false;
        this.setTargetHeading(diff.xCoord,posY - 2,diff.zCoord,true);
      }
    }
    if (rand.nextInt(20) == 0) {
      this.setRandomTargetHeading();
    }
    if (canAggress) {
      if (this.ticksExisted % 200 == 0 && this.aggressTarget == null || !world.loadedEntityList.contains(aggressTarget)) {
        List<Entity> list=world.getEntitiesInAABBexcluding(this,this.getEntityBoundingBox().expand(20D,20D,20D).offset(0.0D,-8.0D,0.0D),EntitySelectors.IS_ALIVE);
        if (list.size() > 0) {
          Entity ent=list.get(rand.nextInt(list.size()));
          boolean skip=false;
          if (ent.equals(this))           skip=true;
          if (ent.getClass().getName().equals(this.getClass().getName()))           skip=true;
          if (this instanceof IPredatorDiet) {
            Class[] prey=((IPredatorDiet)this).getPreyClasses();
            boolean contains=false;
            for (int i=0; i < prey.length; i++) {
              if (prey[i].getName().equals(ent.getClass().getName())) {
                contains=true;
              }
            }
            if (!contains) {
              skip=true;
            }
          }
          if (!ent.isInWater())           skip=true;
          if (!this.canEntityBeSeen(ent))           skip=true;
          if (!skip) {
            if (ent instanceof EntityLivingBase) {
              if (((EntityLivingBase)ent).isInWater()) {
                this.aggressTarget=ent;
              }
            }
          }
        }
      }
      if (rand.nextInt(200) == 0) {
        this.aggressTarget=null;
        this.setRandomTargetHeading();
      }
    }
    if (this.ticksExisted % 80 == 0) {
      Vec3d angle=this.getHeading();
      double frontDist=2f;
      double behindDist=8f;
      Vec3d diff=new Vec3d(posX + (angle.xCoord * frontDist),posY + angle.yCoord,posZ + (angle.zCoord * frontDist));
      bp=new BlockPos((int)diff.xCoord,(int)posY,(int)diff.zCoord);
      if (!this.world.getBlockState(bp).getMaterial().isLiquid()) {
        Vec3d behind=new Vec3d(posX - (angle.xCoord * behindDist),posY + angle.yCoord,posZ - (angle.zCoord * behindDist));
        this.setTargetHeading(behind.xCoord,posY + 5,behind.zCoord,true);
      }
    }
    if (this.fleeFromPlayers && ticksExisted % 80 == 0) {
      EntityPlayer closest=world.getClosestPlayerToEntity(this,this.fleeDistance);
      if (closest != null) {
        if (closest.isInWater()) {
          this.fleeEntity(closest);
          this.isPanicking=true;
        }
      }
 else {
        this.isPanicking=false;
      }
    }
 else {
      this.isPanicking=false;
    }
    if (this.canSchool) {
      if (!isLeader && leader == null) {
        List<Entity> ents=world.loadedEntityList;
        for (int i=0; i < ents.size(); i++) {
          if (ents.get(i) instanceof EntityTropicraftWaterBase) {
            EntityTropicraftWaterBase f=((EntityTropicraftWaterBase)ents.get(i));
            if (f.getClass().getName().equals(this.getClass().getName())) {
              if (f instanceof IAtlasFish && this instanceof IAtlasFish) {
                int slot=((IAtlasFish)f).getAtlasSlot();
                if (((IAtlasFish)this).getAtlasSlot() != slot) {
                  continue;
                }
              }
              if (f.isLeader) {
                this.leader=f;
              }
            }
          }
        }
        if (this.ticksExisted > 200 && leader == null) {
          this.markAsLeader();
        }
      }
      if (this.ticksExisted > 200 && leader == null) {
        this.markAsLeader();
      }
    }
    if (this.aggressTarget != null) {
      if (this.getDistanceSqToEntity(this.aggressTarget) < 1.2f) {
        if (this.aggressTarget instanceof EntityLivingBase)         ((EntityLivingBase)this.aggressTarget).attackEntityFrom(DamageSource.cactus,1);
        this.setRandomTargetHeading();
      }
 else {
        if (this.canEntityBeSeen(this.aggressTarget) && this.ticksExisted % 5 == 0) {
          this.setTargetHeading(this.aggressTarget.posX,this.aggressTarget.posY,this.aggressTarget.posZ,true);
        }
      }
      if (this.aggressTarget != null) {
        if (!this.aggressTarget.isInWater()) {
          this.aggressTarget=null;
          this.setRandomTargetHeading();
        }
      }
    }
    if (!this.isAggressing && this.ticksExisted % 80 == 0) {
      List<Entity> ents=world.loadedEntityList;
      for (int i=0; i < ents.size(); i++) {
        if (ents.get(i) instanceof EntityTropicraftWaterBase) {
          EntityTropicraftWaterBase f=((EntityTropicraftWaterBase)ents.get(i));
          if (this.canEntityBeSeen(f) && this.getDistanceSqToEntity(f) < 2D)           if (f.aggressTarget != null)           if (f.aggressTarget.equals(this)) {
            this.fleeEntity(f);
            this.isPanicking=true;
            break;
          }
        }
      }
    }
    bp=new BlockPos((int)posX,(int)posY - 2,(int)posZ);
    if (!this.world.getBlockState(bp).getMaterial().isLiquid()) {
      if (this.swimPitch < 0f) {
        this.swimPitch+=2f;
      }
    }
    if (this.canSchool) {
      if (this.leader != null && !isLeader) {
        this.setTargetHeading(this.leader.posX,this.leader.posY - 5 + rand.nextInt(10),this.leader.posZ,true);
        if (leader.aggressTarget != null) {
          this.aggressTarget=leader.aggressTarget;
        }
      }
    }
    float swimSpeedTurn=this.swimSpeedTurn;
    if (this.targetVectorHeading != null) {
      this.swimYaw=lerp(this.swimYaw,-this.targetVectorHeading.x,swimSpeedTurn * 2f);
      this.swimPitch=lerp(this.swimPitch,-this.targetVectorHeading.y,swimSpeedTurn * 2f);
    }
  }
  if (!this.isInWater()) {
    this.outOfWaterTime++;
    this.setTargetHeading(posX,posY - 1,posZ,false);
  }
  float currentSpeed=this.swimSpeedCurrent;
  float desiredSpeed=this.swimSpeedDefault;
  if (this.aggressTarget != null) {
    if (this.getDistanceSqToEntity(this.aggressTarget) < 10f) {
      desiredSpeed=this.swimSpeedCharging;
    }
 else {
      desiredSpeed=this.swimSpeedChasing;
    }
    if (!world.loadedEntityList.contains(this.aggressTarget) || this.aggressTarget.isDead) {
      this.aggressTarget=null;
      this.setRandomTargetHeading();
    }
  }
  if (this.isPanicking) {
    desiredSpeed=this.swimSpeedPanic;
  }
  if (this.swimSpeedCurrent < desiredSpeed) {
    this.swimSpeedCurrent+=this.swimAccelRate;
  }
  if (this.swimSpeedCurrent > desiredSpeed) {
    this.swimSpeedCurrent-=this.swimDecelRate;
  }
  currentSpeed*=0.1f;
  if (this.isInWater()) {
    motionX=currentSpeed * Math.sin(this.swimYaw * (Math.PI / 180.0));
    motionZ=currentSpeed * Math.cos(this.swimYaw * (Math.PI / 180.0));
    motionY=(currentSpeed) * Math.sin((this.swimPitch) * (Math.PI / 180.0));
    fallVelocity=0f;
  }
  if (!this.isInWater()) {
    if (this.onGround) {
      if (rand.nextInt(6) == 0) {
        this.motionX+=rand.nextBoolean() ? rand.nextFloat() / 8 : -rand.nextFloat() / 8;
        this.motionZ+=rand.nextBoolean() ? rand.nextFloat() / 8 : -rand.nextFloat() / 8;
      }
      this.motionX*=0.5f;
      this.motionZ*=0.5f;
      if (this.ticksExisted % 4 == 0)       this.fallVelocity=-.02f;
      if (rand.nextInt(20) == 0 || this.hurtTime > 0) {
        this.fallVelocity=-.03f;
        this.swimPitch=25f;
      }
    }
    if (this.swimPitch > 0f) {
      this.swimPitch-=5f;
    }
    if (this.ticksExisted % 20 == 0) {
      this.outOfWaterAngle=rand.nextInt(360);
    }
    float turnSpeed=5f;
    if (this.hurtTime > 0) {
      turnSpeed=15f;
    }
    if (this.swimYaw > this.outOfWaterAngle) {
      this.swimYaw-=turnSpeed;
    }
    if (this.swimYaw < this.outOfWaterAngle) {
      this.swimYaw+=turnSpeed;
    }
    this.motionY-=this.fallVelocity;
    this.fallVelocity+=(this.fallGravity / 10);
  }
  if (swimPitch > 45f) {
    swimPitch=45f;
  }
  syncSwimAngles();
  prevSwimPitch=swimPitch;
  prevSwimYaw=swimYaw;
}