45 Strafe

45° Strafe is a technique that grants more speed than regular movement.

It can be done by strafing and turning 45° degrees (hence the name).


45° Strafe can be performed by either:

  • Turning 45° left and Strafing right.
  • Turning 45° right and Strafing left.


The turning must be quick (< 1tick) and precise (±10°), so it's difficult to perform consistently.

Some jumps require the use of 45° strafe, such as 1bm 4.375b.


Effect on Movement

On every tick, the Player gains some acceleration depending on inputs and other factors.

  • When moving forward (without strafing), the acceleration gained is scaled by  
  • When strafing, the acceleration is scaled by  

Therefore, 45° Strafe is up to   the speed of regular movement (up to 2% faster).


Special case: 45° Sneak

  • When sneaking forward (without strafing), the acceleration gained is scaled by  
  • When strafing while sneaking, the acceleration gained is scaled by   (≈ 1.386)

45° Sneak is used for no-momentum jumps (example). Outside of parkour, it's notably used for bridging.


Explanation

The origin of the 45° strafe mechainic is hard to pinpoint in the game's code: It's the result of incoherent design, chaotic function calls, and nonsensical calculations. Below is a simplified version of the horizontal movement source code.

 1 /* 
 2  * Code from Entity and EntityLivingBase
 3  * Unnecessary or unrelated code is stripped out
 4  */
 5 
 6 public void onLivingUpdate()
 7 {
 8     /* 
 9      * moveStrafing and moveForward represent relative movement.
10      * moveStrafing = 1.0 if moving left, -1.0 if moving right, else 0.0
11      * moveForward = 1.0 if moving forward, -1.0 if moving backward, else 0.0
12      *
13      * Furthermore, moveStrafing and moveForward *= 0.3 if the player is sneaking.
14      */
15 
16     this.moveStrafing *= 0.98F; /* why? */
17     this.moveForward *= 0.98F;  /* why? */
18     this.moveEntityWithHeading(this.moveStrafing, this.moveForward);
19 }
20 
21 
22 
23 public void moveEntityWithHeading(float strafe, float forward)
24 {
25     /* inertia determines how much speed is conserved on the next tick */
26     float inertia = 0.91F;
27     if (this.onGround)
28     {
29         inertia = this.worldObj.getBlockState(new BlockPos(MathHelper.floor(this.posX), MathHelper.floor(this.getEntityBoundingBox().minY) - 1, MathHelper.floor(this.posZ))).getBlock().slipperiness * 0.91F;
30     }
31 
32     /* acceleration = (0.6*0.91)^3 / (slipperiness*0.91)^3) -> redundant calculations... */
33     float acceleration = 0.16277136F / (inertia * inertia * inertia);
34 
35     float movementFactor;
36     if (this.onGround)
37         movementFactor = this.landMovementFactor * acceleration;
38         /* base: 0.1; x1.3 if sprinting, affected by potion effects. */
39 
40     else
41         movementFactor = this.airMovementFactor; 
42         /* base: 0.02; x1.3 if sprinting */
43 
44     this.updateMotionXZ(strafe, forward, movementFactor); /* add relative movement to motion */
45     this.moveEntity(this.motionX, this.motionY, this.motionZ);
46 
47     this.motionY -= 0.08D; /* gravity */
48     this.motionY *= 0.98D; /* drag */
49 
50     this.motionX *= inertia;
51     this.motionZ *= inertia;
52 }
53 
54 
55 
56 public void updateMotionXZ(float strafe, float forward, float movementFactor)
57 {
58     /*
59      * This function is extremely weird, and is solely responsible for the existence of 45° strafe
60      * Also note that:
61      *     - Sprint boost is contained within "movementFactor"
62      *     - Sneak slowdown is contained within "strafe" and "forward"
63      */
64     float distance = strafe * strafe + forward * forward;
65 
66     if (distance >= 1.0E-4F)
67     {
68         distance = MathHelper.sqrt_float(distance);
69             
70         if (distance < 1.0F)
71             distance = 1.0F;
72 
73         distance = movementFactor / distance;
74         strafe = strafe * distance;
75         forward = forward * distance;
76         float sinYaw = MathHelper.sin(this.rotationYaw * Math.PI / 180.0F);
77         float cosYaw = MathHelper.cos(this.rotationYaw * Math.PI / 180.0F);
78         this.motionX += strafe * cosYaw - forward * sinYaw;
79         this.motionZ += forward * cosYaw + strafe * sinYaw;
80     }
81 }