Skip to content

Dig animation details

Goodlyay edited this page Aug 18, 2017 · 1 revision

Found by looking at the decompiled Minecraft Classic source code in ClassiCube client.

Note: All variable names were made up in the process of deobfuscating the code.

Relevant variables starting values: bool applyBreakAnim = false; int breakAnimTicks = 7; //how many ticks it takes for the block break animation to complete. Never changes int breakTimer = 0;

EVERY TICK:

Add 1 to breakTimer
If breakTimer is equal to breakAnimTicks, set applyBreakAnim to false and set breakTimer to 0.

EVERY TIME YOU CLICK TO START THE ANIMATION (checked on tick): breakTimer = -1 applyBreakAnim = true;

EVERY FRAME:

if applyBreakAnim is true...

creates an elapsedTicks, which is the current breakTimer plus delta

creates lerp, which is elapsedTicks divided by breakAnimTicks

creates sinHalfCircle, which is sin(lerp * PI)

creates sqrtLerpPI, which is the square root(lerp) * PI.

Then, moves the block on...
X by -sin(sqrtLerpPI) * 0.4

Y by sin(sqrtLerpPI * 2) * 0.2

Z by -sinHalfCircle * 0.2
Note: Z should be forward/back in this case, if it isn't already in CS

end if.

Intermission: SET HELD BLOCK POSITION AT THIS POINT

if applyBreakAnim is true...

(There will be variable re-use from the first if statement in here.)
						
creates sinHalfCircleWeird, which is sin(lerp * lerp * PI)

rotates on Y axis by sin(sqrtLerpPI) * 80

rotates on X axis by -sinHalfCircleWeird * 20

end if.

If it's not your hand, scale down by 0.4

If it's your hand, set hand position here.