Back to 9Minecraft
Wiki 9Minecraft Wiki 9Minecraft
Player Animation Library Wiki › Guides › Using MoLang Expressions to Make Animations React to Player State

Using MoLang Expressions to Make Animations React to Player State

What MoLang gives you

MoLang is the expression language the library uses inside animation files to decide values at runtime instead of baking them in. Instead of a bone always rotating a fixed amount, you write an expression that reads player state — health, speed, whether they are on the ground, whether they are sneaking — and outputs a number.

This is how you make one animation file cover many situations: a walk cycle that speeds up with movement, an idle that changes when the player is hurt, or a head that tracks pitch.

Writing a state-driven expression

Inside your animation JSON, find the channel you want to drive (rotation, position, scale) and replace the constant value with a MoLang expression. Reference the query functions the library exposes for player data, and combine them with arithmetic or conditionals.

Keep expressions small and test them one at a time. If a bone snaps to a weird pose, the expression is likely returning an unexpected value — log it or temporarily replace it with a constant to isolate the problem. Remember that MoLang runs every frame, so avoid heavy nested logic; simple comparisons and multipliers are enough for most reactive animations.