Skip to main content
Version: 26.1+

MoLang

MoLang is a small expression language that Minecraft uses on Bedrock Edition for animations. Palladium uses it wherever a value has to be calculated while the game runs: a condition that checks if the player is on the ground, a number that rises with the player's speed, or an arm rotation that follows the head. You write a short formula as a string, and Palladium evaluates it every time it is needed.

query.is_on_ground && query.is_sprinting

Where MoLang Works​

PlaceWhat the expression does
ConditionsA plain string in any condition field is read as MoLang. The condition passes when the result is not 0.
Animation controller transitionsSame as conditions. Decides when the controller switches states.
Keyframes in player animationsAny number in an animation file can be an expression, like "-22.5 * !q.is_on_ground".
modify on valuesChanges a number value. The original value is available as this.
overrides on the default render layerChanges the position, rotation or scale of a model part. The current value is available as this.

The Basics​

Queries read information from the game. They start with a namespace, then a dot, then the query name: query.health. The list below shows everything that is available.

Booleans are numbers. true is 1, false is 0. That is why -22.5 * !query.is_on_ground works: in the air !query.is_on_ground is 1 and the result is -22.5, on the ground it is 0 and the result is 0.

Operators work like in most languages: + - * /, comparisons with == != < > <= >=, logic with && || !, and parentheses. condition ? a : b picks one of two values.

Parentheses on queries are optional when the query takes no arguments. query.is_on_ground and query.is_on_ground() mean the same. Queries with arguments need them, with text in single quotes: palladium.get_animation_timer_eased('mypack:hero#transform').

Math functions live in the math namespace, for example math.abs, math.clamp, math.lerp, math.mod, math.sin and math.cos.

Namespaces​

  • query (short: q) holds the general queries that are known from Bedrock Edition: health, movement, rotations, time and so on.
  • palladium holds Palladium's own queries for flight, web swinging, abilities and attack animations.
  • math holds the math functions.

Inside the keyframes of player animations, the query namespace is provided by Player Animation Library instead of Palladium. It contains the same queries listed below plus two more: query.anim_time (seconds since the animation started) and query.controller_speed. The palladium namespace works there too.

Query Reference​

query​

QueryReturnsDescription
query.actor_countNumber
Always 1. Exists for compatibility with Bedrock animations.
query.blockingBoolean
Whether the entity is blocking with a shield.
query.body_x_rotationNumber
The entity's pitch in degrees.
query.body_y_rotationNumber
The body yaw in degrees. For entities without a separate body rotation this is the view yaw.
query.cardinal_facingNumber
The direction the entity faces as a number: 0 down, 1 up, 2 north, 3 south, 4 west, 5 east.
query.cardinal_facing_2dNumber
Like cardinal_facing, but up and down are reported as 6, so only the four horizontal directions remain.
query.cardinal_player_facingNumber
The direction the entity faces, using the same numbers as cardinal_facing.
query.dayNumber
The number of in-game days that have passed, with the time of day as the fraction.
query.death_ticksNumber
Ticks since the entity died. 0 while alive.
query.distance_from_cameraNumber
Always 0. Exists for compatibility with Bedrock animations.
query.equipment_countNumber
How many armor slots are filled.
query.frame_alphaNumber
The progress between the last and the next tick, from 0 to 1. Useful for smooth motion.
query.get_actor_info_idNumber
The entity's numeric ID in the current world.
query.ground_speedNumber
The horizontal speed in blocks per tick.
query.has_capeBoolean
Whether the player has a cape that is visible.
query.has_collisionBoolean
Whether the entity collides with blocks.
query.has_gravityBoolean
Whether the entity is affected by gravity.
query.has_head_gearBoolean
Whether something is worn in the head slot.
query.has_ownerBoolean
Whether the entity is tamed or otherwise owned.
query.has_player_riderBoolean
Whether a player is riding the entity.
query.has_riderBoolean
Whether anything is riding the entity.
query.head_x_rotationNumber
The head pitch in degrees. Negative when looking up.
query.head_y_rotationNumber
The head yaw in degrees, in world space.
query.healthNumber
The current health.
query.hurt_timeNumber
Counts down from 10 after the entity took damage. 0 when not hurt.
query.invulnerable_ticksNumber
Remaining ticks of damage immunity after getting hurt.
query.is_aliveBoolean
Whether the entity is alive.
query.is_angryBoolean
Whether a neutral mob, like a wolf or enderman, is angry.
query.is_babyBoolean
Whether the entity is a baby.
query.is_breathingBoolean
Whether the entity's air supply is full.
query.is_fire_immuneBoolean
Whether the entity type is immune to fire.
query.is_first_personBoolean
Whether the entity is the local player viewed in first person.
query.is_in_contact_with_waterBoolean
Whether the entity is in water or standing in rain.
query.is_in_lavaBoolean
Whether the entity is in lava.
query.is_in_waterBoolean
Whether the entity is in water.
query.is_in_water_or_rainBoolean
Whether the entity is in water or standing in rain.
query.is_invisibleBoolean
Whether the entity is invisible.
query.is_leashedBoolean
Whether the entity is on a lead.
query.is_movingBoolean
Whether the entity moved since the last tick.
query.is_on_fireBoolean
Whether the entity is burning.
query.is_on_groundBoolean
Whether the entity stands on the ground.
query.is_ridingBoolean
Whether the entity is riding something.
query.is_saddledBoolean
Whether the entity wears a saddle.
query.is_silentBoolean
Whether the entity is silent.
query.is_sleepingBoolean
Whether the entity is sleeping in a bed.
query.is_sneakingBoolean
Whether the entity is crouching.
query.is_sprintingBoolean
Whether the entity is sprinting.
query.is_swimmingBoolean
Whether the entity is swimming.
query.is_using_itemBoolean
Whether the entity is using an item, like eating or drawing a bow.
query.is_wall_climbingBoolean
Whether the entity is on a ladder, vine or another climbable block. For Palladium's wall climbing ability use palladium.is_wall_climbing.
query.life_timeNumber
Always 0. Exists for compatibility with Bedrock animations.
query.limb_swingNumber
How far the legs have swung in the walking animation. Grows continuously while walking.
query.limb_swing_amountNumber
How strongly the walking animation plays, from 0 when standing still to about 1 when running.
query.main_hand_item_max_durationNumber
How many ticks the item in the main hand can be used for, like a bow's draw time.
query.main_hand_item_use_durationNumber
How long the item in the main hand has been used, in seconds. 0 when it is not being used.
query.max_healthNumber
The maximum health.
query.moon_brightnessNumber
The current brightness of the stars, from 0 during the day to 1 at night.
query.moon_phaseNumber
The moon phase, from 0 (full moon) to 7.
query.movement_directionNumber
The direction the entity is moving in, using the same numbers as cardinal_facing. 6 when not moving.
query.player_levelNumber
The player's experience level. 0 for other entities.
query.rider_body_x_rotationNumber
The pitch of the first rider in degrees. 0 without a rider.
query.rider_body_y_rotationNumber
The body yaw of the first rider in degrees. 0 without a rider.
query.rider_head_x_rotationNumber
The head pitch of the first rider in degrees. 0 without a rider.
query.rider_head_y_rotationNumber
The head yaw of the first rider in degrees. 0 without a rider.
query.scaleNumber
The entity's scale, for example from the scale attribute. 1 by default.
query.sleep_rotationNumber
The yaw of the bed the entity sleeps in, in degrees. 0 when not sleeping.
query.time_of_dayNumber
The time of day from 0 to 1. 0 is sunrise, 0.25 noon, 0.5 sunset and 0.75 midnight.
query.time_stampNumber
The total game time in ticks.
query.vertical_speedNumber
The vertical speed in blocks per tick. Positive when moving up.
query.yaw_speedNumber
How far the yaw changed since the last tick, in degrees.

palladium​

QueryReturnsDescription
palladium.any_animation_finishedBoolean
Whether the animation of the current animation controller state has finished. Only works in animation controller transitions.
palladium.attack_body_yawNumber
The body twist in degrees during the vanilla attack swing.
palladium.attack_on_left_armBoolean
Whether an attack swing is playing and the left arm is the main arm.
palladium.attack_on_right_armBoolean
Whether an attack swing is playing and the right arm is the main arm.
palladium.attack_swing_xNumber
The X rotation in degrees the attacking arm gets in the vanilla swing animation. Lets animations recreate the swing.
palladium.attack_swing_yNumber
The Y rotation in degrees the attacking arm gets in the vanilla swing animation.
palladium.attack_swing_zNumber
The Z rotation in degrees the attacking arm gets in the vanilla swing animation.
palladium.attack_timeNumber
Progress of the current attack swing, from 0 to 1. 0 when not attacking.
palladium.cape_x_rotationNumber
The X rotation in degrees that the vanilla cape physics add on top of a cape bone. Subtract it in an animation to take full control of the cape.
palladium.flight_limb_pitchNumber
The pitch the arms and legs should follow during flight, in degrees.
palladium.flight_limb_rollNumber
The roll the arms and legs should follow during flight, in degrees.
palladium.flight_phaseNumber
The phase of the active flight type. Default flight: 0 none, 1 hovering, 2 moving, 3 propelled, 4 descending, 5 landing. Swinging: 0 none, 1 launching, 2 swinging, 3 released, 4 diving, 5 landing.
palladium.flight_pitchNumber
The pitch of the current flight animation, in degrees. 0 when not flying.
palladium.flight_propulsion_scaleNumber
How far the propelled (fast) flight pose is blended in, from 0 to 1.
palladium.flight_rollNumber
The roll of the current flight animation, in degrees. 0 when not flying.
palladium.flight_speed_forwardNumber
Forward speed during flight relative to the flight speed, from -1 (backwards) to 1.
palladium.flight_speed_sidewaysNumber
Sideways speed during flight relative to the flight speed, from -1 to 1.
palladium.flight_yawNumber
The yaw of the current flight animation, in degrees. 0 when not flying.
palladium.flight_yaw_deltaNumber
How fast the flying entity is turning, smoothed. Useful to lean into curves.
palladium.get_animation_timer_eased(ability)Number
The eased animation timer of an ability, from 0 to 1. 0 if the ability is not found.
  • ability (String): Ability reference in the form "namespace:power#ability".
palladium.gliding_tick_countNumber
Ticks spent gliding with an elytra. 0 when not gliding.
palladium.grapple_distanceNumber
The distance from the entity's shoulders to its grappling hook, in blocks. 0 without a hook.
palladium.grapple_pitchNumber
The pitch from the entity's shoulders to its grappling hook, in degrees. Positive when the hook is above. 0 without a hook.
palladium.grapple_stateNumber
The state of the entity's active grappling hook: 0 none, 1 flying out, 2 pulling the entity towards a block, 3 reeling in a hooked entity.
palladium.grapple_yawNumber
The yaw from the entity's body to its grappling hook, in degrees from -180 to 180. Positive when the hook is to the right. 0 without a hook.
palladium.head_x_rotationNumber
The head pitch in degrees. Negative when looking up.
palladium.head_y_rotationNumber
The head yaw relative to the body, in degrees from -180 to 180. Unlike query.head_y_rotation this is 0 when the player looks straight ahead, which is what a head bone in an animation needs.
palladium.horizontal_speedNumber
The horizontal distance the entity moved since the last tick, in blocks. Vertical movement is ignored.
palladium.is_wall_climbingBoolean
Whether the player is climbing a wall with Palladium's wall climbing ability.
palladium.model_property(part, property)Number
A value of a model part. Only works inside the overrides of a render layer, returns 0 everywhere else.
  • part (String): Name of the model part, like "head" or "right_arm".
  • property (String): One of x, y, z, x_rot, y_rot, z_rot (radians), x_rot_degrees, y_rot_degrees, z_rot_degrees, x_scale, y_scale, z_scale.
palladium.pos_xNumber
The entity's X position in the world, smoothed between ticks.
palladium.pos_yNumber
The entity's Y position in the world, smoothed between ticks.
palladium.pos_zNumber
The entity's Z position in the world, smoothed between ticks.
palladium.swinging_is_hangingBoolean
Whether the player hangs still on a web line.
palladium.swinging_left_arm_pitchNumber
A physics based pitch for the left arm while swinging, in degrees. Points up at the anchor when the arm holds the line.
palladium.swinging_limb_velNumber
How fast the swinging limbs are currently moving. Useful for secondary motion like legs trailing behind.
palladium.swinging_on_left_armBoolean
Whether the current web line is attached to the left arm.
palladium.swinging_on_right_armBoolean
Whether the current web line is attached to the right arm.
palladium.swinging_right_arm_pitchNumber
A physics based pitch for the right arm while swinging, in degrees. Points up at the anchor when the arm holds the line.
palladium.tick_countNumber
The entity's age in ticks, including the progress to the next tick for smooth motion.

Examples​

Condition as a string​

A power renderer that shows a render layer only while the player is sprinting on the ground:

assets/mypack/palladium/power_renderers/hero.json (excerpt)
"render_layers": {
"mypack:speed_lines": "query.is_sprinting && query.is_on_ground"
}

Turning a value into frame numbers​

modify on an integer value, cycling through 1, 2 and 3 once per second. Used as a dynamic texture variable, this switches between three texture files:

"FRAME": {
"type": "palladium:entity_tick_count",
"modify": "math.mod(this / 20, 3) + 1"
}

Animation controller transitions​

Switching between idle, running and jumping based on movement:

assets/mypack/palladium/animation_controllers/hero_movement.json
{
"initial_state": "idle",
"states": {
"idle": {
"transitions": {
"jumping": "!query.is_on_ground && query.vertical_speed > 0",
"running": "query.is_sprinting && query.is_on_ground"
}
},
"running": {
"animation": "mypack:hero_run",
"transitions": {
"idle": "!query.is_sprinting || !query.is_on_ground"
}
},
"jumping": {
"animation": "mypack:hero_jump",
"transitions": {
"idle": "query.is_on_ground"
}
}
}
}

Head that follows the camera in an animation​

In a player animation, the head bone can keep following where the player looks while the rest of the body is animated. palladium.head_y_rotation is relative to the body, which is exactly what a bone rotation needs:

assets/mypack/player_animations/hero_run.json (excerpt)
"head": {
"rotation": ["palladium.head_x_rotation - 17.5", "palladium.head_y_rotation", 0]
}

Leaning into turns while flying​

A keyframe expression on the body that tilts the player sideways when they turn during flight. The value is clamped so it never goes past 30 degrees:

assets/mypack/player_animations/hero_flight.json (excerpt)
"body": {
"rotation": [0, 0, "math.clamp(palladium.flight_yaw_delta * 2, -30, 30)"]
}