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
| Place | What the expression does |
|---|---|
| Conditions | A plain string in any condition field is read as MoLang. The condition passes when the result is not 0. |
| Animation controller transitions | Same as conditions. Decides when the controller switches states. |
| Keyframes in player animations | Any number in an animation file can be an expression, like "-22.5 * !q.is_on_ground". |
modify on values | Changes a number value. The original value is available as this. |
overrides on the default render layer | Changes 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.palladiumholds Palladium's own queries for flight, web swinging, abilities and attack animations.mathholds 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
| Query | Returns | Description |
|---|---|---|
query.actor_count | Number | Always 1. Exists for compatibility with Bedrock animations. |
query.blocking | Boolean | Whether the entity is blocking with a shield. |
query.body_x_rotation | Number | The entity's pitch in degrees. |
query.body_y_rotation | Number | The body yaw in degrees. For entities without a separate body rotation this is the view yaw. |
query.cardinal_facing | Number | The direction the entity faces as a number: 0 down, 1 up, 2 north, 3 south, 4 west, 5 east. |
query.cardinal_facing_2d | Number | Like cardinal_facing, but up and down are reported as 6, so only the four horizontal directions remain. |
query.cardinal_player_facing | Number | The direction the entity faces, using the same numbers as cardinal_facing. |
query.day | Number | The number of in-game days that have passed, with the time of day as the fraction. |
query.death_ticks | Number | Ticks since the entity died. 0 while alive. |
query.distance_from_camera | Number | Always 0. Exists for compatibility with Bedrock animations. |
query.equipment_count | Number | How many armor slots are filled. |
query.frame_alpha | Number | The progress between the last and the next tick, from 0 to 1. Useful for smooth motion. |
query.get_actor_info_id | Number | The entity's numeric ID in the current world. |
query.ground_speed | Number | The horizontal speed in blocks per tick. |
query.has_cape | Boolean | Whether the player has a cape that is visible. |
query.has_collision | Boolean | Whether the entity collides with blocks. |
query.has_gravity | Boolean | Whether the entity is affected by gravity. |
query.has_head_gear | Boolean | Whether something is worn in the head slot. |
query.has_owner | Boolean | Whether the entity is tamed or otherwise owned. |
query.has_player_rider | Boolean | Whether a player is riding the entity. |
query.has_rider | Boolean | Whether anything is riding the entity. |
query.head_x_rotation | Number | The head pitch in degrees. Negative when looking up. |
query.head_y_rotation | Number | The head yaw in degrees, in world space. |
query.health | Number | The current health. |
query.hurt_time | Number | Counts down from 10 after the entity took damage. 0 when not hurt. |
query.invulnerable_ticks | Number | Remaining ticks of damage immunity after getting hurt. |
query.is_alive | Boolean | Whether the entity is alive. |
query.is_angry | Boolean | Whether a neutral mob, like a wolf or enderman, is angry. |
query.is_baby | Boolean | Whether the entity is a baby. |
query.is_breathing | Boolean | Whether the entity's air supply is full. |
query.is_fire_immune | Boolean | Whether the entity type is immune to fire. |
query.is_first_person | Boolean | Whether the entity is the local player viewed in first person. |
query.is_in_contact_with_water | Boolean | Whether the entity is in water or standing in rain. |
query.is_in_lava | Boolean | Whether the entity is in lava. |
query.is_in_water | Boolean | Whether the entity is in water. |
query.is_in_water_or_rain | Boolean | Whether the entity is in water or standing in rain. |
query.is_invisible | Boolean | Whether the entity is invisible. |
query.is_leashed | Boolean | Whether the entity is on a lead. |
query.is_moving | Boolean | Whether the entity moved since the last tick. |
query.is_on_fire | Boolean | Whether the entity is burning. |
query.is_on_ground | Boolean | Whether the entity stands on the ground. |
query.is_riding | Boolean | Whether the entity is riding something. |
query.is_saddled | Boolean | Whether the entity wears a saddle. |
query.is_silent | Boolean | Whether the entity is silent. |
query.is_sleeping | Boolean | Whether the entity is sleeping in a bed. |
query.is_sneaking | Boolean | Whether the entity is crouching. |
query.is_sprinting | Boolean | Whether the entity is sprinting. |
query.is_swimming | Boolean | Whether the entity is swimming. |
query.is_using_item | Boolean | Whether the entity is using an item, like eating or drawing a bow. |
query.is_wall_climbing | Boolean | 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_time | Number | Always 0. Exists for compatibility with Bedrock animations. |
query.limb_swing | Number | How far the legs have swung in the walking animation. Grows continuously while walking. |
query.limb_swing_amount | Number | How strongly the walking animation plays, from 0 when standing still to about 1 when running. |
query.main_hand_item_max_duration | Number | How many ticks the item in the main hand can be used for, like a bow's draw time. |
query.main_hand_item_use_duration | Number | How long the item in the main hand has been used, in seconds. 0 when it is not being used. |
query.max_health | Number | The maximum health. |
query.moon_brightness | Number | The current brightness of the stars, from 0 during the day to 1 at night. |
query.moon_phase | Number | The moon phase, from 0 (full moon) to 7. |
query.movement_direction | Number | The direction the entity is moving in, using the same numbers as cardinal_facing. 6 when not moving. |
query.player_level | Number | The player's experience level. 0 for other entities. |
query.rider_body_x_rotation | Number | The pitch of the first rider in degrees. 0 without a rider. |
query.rider_body_y_rotation | Number | The body yaw of the first rider in degrees. 0 without a rider. |
query.rider_head_x_rotation | Number | The head pitch of the first rider in degrees. 0 without a rider. |
query.rider_head_y_rotation | Number | The head yaw of the first rider in degrees. 0 without a rider. |
query.scale | Number | The entity's scale, for example from the scale attribute. 1 by default. |
query.sleep_rotation | Number | The yaw of the bed the entity sleeps in, in degrees. 0 when not sleeping. |
query.time_of_day | Number | The time of day from 0 to 1. 0 is sunrise, 0.25 noon, 0.5 sunset and 0.75 midnight. |
query.time_stamp | Number | The total game time in ticks. |
query.vertical_speed | Number | The vertical speed in blocks per tick. Positive when moving up. |
query.yaw_speed | Number | How far the yaw changed since the last tick, in degrees. |
palladium
| Query | Returns | Description |
|---|---|---|
palladium.any_animation_finished | Boolean | Whether the animation of the current animation controller state has finished. Only works in animation controller transitions. |
palladium.attack_body_yaw | Number | The body twist in degrees during the vanilla attack swing. |
palladium.attack_on_left_arm | Boolean | Whether an attack swing is playing and the left arm is the main arm. |
palladium.attack_on_right_arm | Boolean | Whether an attack swing is playing and the right arm is the main arm. |
palladium.attack_swing_x | Number | The X rotation in degrees the attacking arm gets in the vanilla swing animation. Lets animations recreate the swing. |
palladium.attack_swing_y | Number | The Y rotation in degrees the attacking arm gets in the vanilla swing animation. |
palladium.attack_swing_z | Number | The Z rotation in degrees the attacking arm gets in the vanilla swing animation. |
palladium.attack_time | Number | Progress of the current attack swing, from 0 to 1. 0 when not attacking. |
palladium.cape_x_rotation | Number | 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_pitch | Number | The pitch the arms and legs should follow during flight, in degrees. |
palladium.flight_limb_roll | Number | The roll the arms and legs should follow during flight, in degrees. |
palladium.flight_phase | Number | 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_pitch | Number | The pitch of the current flight animation, in degrees. 0 when not flying. |
palladium.flight_propulsion_scale | Number | How far the propelled (fast) flight pose is blended in, from 0 to 1. |
palladium.flight_roll | Number | The roll of the current flight animation, in degrees. 0 when not flying. |
palladium.flight_speed_forward | Number | Forward speed during flight relative to the flight speed, from -1 (backwards) to 1. |
palladium.flight_speed_sideways | Number | Sideways speed during flight relative to the flight speed, from -1 to 1. |
palladium.flight_yaw | Number | The yaw of the current flight animation, in degrees. 0 when not flying. |
palladium.flight_yaw_delta | Number | 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.
|
palladium.gliding_tick_count | Number | Ticks spent gliding with an elytra. 0 when not gliding. |
palladium.grapple_distance | Number | The distance from the entity's shoulders to its grappling hook, in blocks. 0 without a hook. |
palladium.grapple_pitch | Number | 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_state | Number | 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_yaw | Number | 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_rotation | Number | The head pitch in degrees. Negative when looking up. |
palladium.head_y_rotation | Number | 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_speed | Number | The horizontal distance the entity moved since the last tick, in blocks. Vertical movement is ignored. |
palladium.is_wall_climbing | Boolean | 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.
|
palladium.pos_x | Number | The entity's X position in the world, smoothed between ticks. |
palladium.pos_y | Number | The entity's Y position in the world, smoothed between ticks. |
palladium.pos_z | Number | The entity's Z position in the world, smoothed between ticks. |
palladium.swinging_is_hanging | Boolean | Whether the player hangs still on a web line. |
palladium.swinging_left_arm_pitch | Number | 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_vel | Number | How fast the swinging limbs are currently moving. Useful for secondary motion like legs trailing behind. |
palladium.swinging_on_left_arm | Boolean | Whether the current web line is attached to the left arm. |
palladium.swinging_on_right_arm | Boolean | Whether the current web line is attached to the right arm. |
palladium.swinging_right_arm_pitch | Number | 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_count | Number | 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:
"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:
{
"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:
"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:
"body": {
"rotation": [0, 0, "math.clamp(palladium.flight_yaw_delta * 2, -30, 30)"]
}