Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1.         double maxVelocity = 0.05D;
  2.             if(entity instanceof EntityPlayer)
  3.             {
  4.                 if(((EntityPlayer) entity).isSprinting())
  5.                 {
  6.                     maxVelocity = 0.1D;
  7.                 }
  8.             }
  9.         double maxVelocitySq = maxVelocity * maxVelocity;
  10.         double currVelocity = entity.motionX * entity.motionX + entity.motionY * entity.motionY + entity.motionZ * entity.motionZ;
  11.        
  12.         if(currVelocity > maxVelocitySq)
  13.         {
  14.             if(entity.motionX < 0.0D)
  15.             {
  16.                 entity.motionX = MathHelper.clamp_double(entity.motionX, -maxVelocity, 0.0D);
  17.             }
  18.             else
  19.             {
  20.                 entity.motionX = MathHelper.clamp_double(entity.motionX, 0.0D, maxVelocity);
  21.             }
  22.            
  23.             if(entity.motionY < 0.0D)
  24.             {
  25.                 entity.motionY = MathHelper.clamp_double(entity.motionY, -maxVelocity, 0.0D);
  26.             }
  27.             else
  28.             {
  29.                 entity.motionY = MathHelper.clamp_double(entity.motionY, 0.0D, maxVelocity);
  30.             }
  31.            
  32.             if(entity.motionZ < 0.0D)
  33.             {
  34.                 entity.motionZ = MathHelper.clamp_double(entity.motionZ, -maxVelocity, 0.0D);
  35.             }
  36.             else
  37.             {
  38.                 entity.motionZ = MathHelper.clamp_double(entity.motionZ, 0.0D, maxVelocity);
  39.             }
  40.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement