Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double maxVelocity = 0.05D;
- if(entity instanceof EntityPlayer)
- {
- if(((EntityPlayer) entity).isSprinting())
- {
- maxVelocity = 0.1D;
- }
- }
- double maxVelocitySq = maxVelocity * maxVelocity;
- double currVelocity = entity.motionX * entity.motionX + entity.motionY * entity.motionY + entity.motionZ * entity.motionZ;
- if(currVelocity > maxVelocitySq)
- {
- if(entity.motionX < 0.0D)
- {
- entity.motionX = MathHelper.clamp_double(entity.motionX, -maxVelocity, 0.0D);
- }
- else
- {
- entity.motionX = MathHelper.clamp_double(entity.motionX, 0.0D, maxVelocity);
- }
- if(entity.motionY < 0.0D)
- {
- entity.motionY = MathHelper.clamp_double(entity.motionY, -maxVelocity, 0.0D);
- }
- else
- {
- entity.motionY = MathHelper.clamp_double(entity.motionY, 0.0D, maxVelocity);
- }
- if(entity.motionZ < 0.0D)
- {
- entity.motionZ = MathHelper.clamp_double(entity.motionZ, -maxVelocity, 0.0D);
- }
- else
- {
- entity.motionZ = MathHelper.clamp_double(entity.motionZ, 0.0D, maxVelocity);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement