EMF Animation Math, Variables, and .jem Export Reference
This guide explains the math functions, entity and global variables, and model export tools available in Entity Model Features (EMF). Everything here is operated through the mod's interface and hotkeys, not through crafting.
Animation Math Functions
EMF provides a large library of math functions for use in custom entity model animations. You can browse them in the Animation math details section of the settings, where clicking any function shows more information about it.
Basic arithmetic and rounding functions include abs(x) for the positive value of a number, ceil(x) and floor(x) for rounding up or down, round(x) for rounding to the nearest whole number, and frac(x) for the part after the decimal point. signum(x) gives whether a number is positive or negative, while fmod(x, y) returns a remainder that always carries the divisor's sign.
Trigonometry is covered by sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), and atan2(y, x). Angle helpers include todeg(rad) and torad(deg) for converting between units, wrapdeg(x) and wraprad(x) for wrapping values into standard ranges, and degdiff(x, y) and raddiff(x, y) for finding the shortest angular gap between two values.
Interpolation functions include lerp(k, x, y) for linear blending, keyframe(k, a, b, c,...) and keyframeloop(k, a, b, c,...) for smooth transitions across a sequence of values, and spline options such as catmullrom, cubicbezier, quadbezier, and hermite, each taking control points. A full family of easing functions is available, covering ease in, ease out, and ease in-out variants of back, bounce, circ, cubic, elastic, expo, quad, quart, quint, and sine.
Other useful functions include clamp(x, min, max) to limit a value, min and max to pick from a list, pow(x, y), sqrt(x), exp(x), log(x), random(seed) for a value between 0 and 1, and if(cond, val, [cond2, val2, ...], val_else) for conditional selection. Boolean counterparts exist as ifb and randomb. Comparison helpers include between(x, min, max), equals(x, y, epsilon), and in(x, val1, val2, ...). Debugging tools include print(id, n, x) and printb(id, n, x) for logging values every N-th frame, catch(x, c, id) to substitute a fallback when a calculation fails, and nan to deliberately throw an exception. The nbt(x, y) function checks whether an entity's NBT tag matches a query.
Entity and Global Variables
Entity variables use the prefix var. for floats or varb. for booleans, with any name you choose. They belong to the rendered entity, start at 0 or false, and are handy for carrying animation data between frames. Global variables use global_var. and global_varb. instead, and are shared across multiple entities.
Many built-in variables describe entity state, including health values, hurt and death timers, anger timers, swing progress, limb swing and limb speed, movement direction, fluid depth, height above ground, and position and rotation in the world. Boolean variables cover conditions such as burning, child state, invisibility, glowing, sitting, taming, riding, being ridden, swimming, gliding, crawling, blocking, and holding items. There are also variables for the client player's position and rotation, the current dimension, day count and day time, total game time, frame time, a frame counter, and a unique entity identifier. Render variables control shadow size, opacity and offsets, plus leash attachment points.
Model part variables use the format .<variable_name> and accept names like tx, ty, tz, rx, ry, rz, sx, sy, sz, visible, and visible_boxes. You can address the current custom model, the original part model, or search by part name or ID, including hierarchical paths through child models.
Exporting and Model Tools
To export a model, open its entry under the models list and choose the export option. The file is written to the emf export directory and can be opened in Blockbench, containing pivots, boxes, and UVs. Extra details are printed to the log, including where to place the file for use in a resource pack. If export fails, the reason is shown. Note that arrow and spectral arrow models, plus the player cape model, are supported but do not appear in the list.
Logging options let you record model construction information or produce complete .jem files for every accessible model on each reload. Unknown models are those not supported by OptiFine CEM. Be aware that the verbose math logging option is extremely lag inducing.
Related Settings
Several settings affect how models behave. parrot shoulder animate makes the parrot follow player animations, with a tooltip option that follows the animated player position. Sulfur Cube block default animation animates internal blocks by default. armor hack restores armor copying custom animations on newer versions. animate once limits models to animating once per entity. optifine fallback properties, optifine syntax, optifine subfolders, and variation base enforce OptiFine compatibility rules. substitute vanilla replaces missing parts with vanilla counterparts, and force models tries to stop other mods overriding EMF models. Debug rendering options include wireframe and flashing overlays, plus a hover-only mode. Animation LOD distance controls when frames start being skipped, with large mob lod and low fps lod softening the effect.