Exemplo n.º 1
0
 public void onLivingUpdate() {
   if (flyToggleTimer > 0) {
     flyToggleTimer--;
   }
   if (worldObj.difficultySetting == 0
       && getEntityHealth() < getMaxHealth()
       && (ticksExisted % 20) * 12 == 0) {
     heal(1);
   }
   inventory.decrementAnimations();
   prevCameraYaw = cameraYaw;
   super.onLivingUpdate();
   landMovementFactor = speedOnGround;
   jumpMovementFactor = speedInAir;
   if (isSprinting()) {
     landMovementFactor += (double) speedOnGround * 0.29999999999999999D;
     jumpMovementFactor += (double) speedInAir * 0.29999999999999999D;
   }
   float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
   float f1 = (float) Math.atan(-motionY * 0.20000000298023224D) * 15F;
   if (f > 0.1F) {
     f = 0.1F;
   }
   if (!onGround || getEntityHealth() <= 0) {
     f = 0.0F;
   }
   if (onGround || getEntityHealth() <= 0) {
     f1 = 0.0F;
   }
   cameraYaw += (f - cameraYaw) * 0.4F;
   cameraPitch += (f1 - cameraPitch) * 0.8F;
   if (getEntityHealth() > 0) {
     List list =
         worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(1.0D, 0.0D, 1.0D));
     if (list != null) {
       for (int i = 0; i < list.size(); i++) {
         Entity entity = (Entity) list.get(i);
         if (!entity.isDead) {
           collideWithPlayer(entity);
         }
       }
     }
   }
 }