[PR #5665] [MERGED] OptiFine entity models: custom models animate #6425

Closed
opened 2026-11-03 06:20:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5665
Author: @some-du6e
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: optifine/emf-animations


📝 Commits (4)

  • a6fcdfa OptiFine CEM: custom entity models animate
  • 4c8d6b3 Merge optifine/emf-geometry into optifine/emf-animations
  • b1b7226 Merge main into the OptiFine series
  • 84bf620 Merge main into optifine/emf-animations

📊 Changes

5 files changed (+585 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+15 -0)
📝 crates/horizon-client/src/mobs.rs (+1 -0)
📝 crates/horizon-client/src/mobs/cem.rs (+26 -3)
➕ crates/horizon-client/src/mobs/cem_anim.rs (+534 -0)
📝 crates/horizon-client/src/mobs/render.rs (+9 -1)

📄 Description

Packs' custom entity models stood still: the previous PR swapped in their shapes, but the animations that make Fresh Animations' mobs breathe, look around and walk with knees still did nothing. This PR runs them.

What players get: each .jem's animations now run on every mob drawn with that model, every frame, after the vanilla animation has posed the parts (as in OptiFine):

  • part.rx reads the vanilla pose, and head.rx = ... overrides it.
  • Targets: tx ty tz rx ry rz sx sy sz visible visible_boxes (pixels and radians on vanilla's axes, as ModelPart keeps them) on:
    • this (the vanilla part for a replacing entry, the new bone for an attached one)
    • part
    • any OptiFine part name (through the same name table as the geometry)
    • any bone id, and hierarchical a:b:c paths searching ids below
  • Variables: var.*/varb.* persist per entity from frame to frame, kept per entity id, with at most 4096 entities per model before the table starts over. EMF's global_var.* is accepted too, but it is still per entity, not shared between entities.
  • Parameters:
    • from the entity: limb_swing limb_speed age head_yaw head_pitch swing_progress health max_health hurt_time death_time pos_* rot_* id, EMF's distance move_forward move_strafing fluid_depth fluid_depth_down
    • frame-wide: time (OptiFine's 27720-tick loop), day_time day_count frame_time frame_counter dimension player_pos_* player_rot_*
    • booleans: is_alive is_burning is_child is_glowing is_hurt is_in_water is_in_lava is_wet is_invisible is_on_ground is_riding is_climbing is_jumping is_aggressive (has a target), and EMF's is_paused and perspective flags (set to defaults for now)
  • render.* targets are accepted and do nothing yet: shadow and leash offsets need their renderers.
  • An expression that doesn't compile, or names something that doesn't exist, is skipped with a log warning instead of failing the whole model.

Not yet (they read 0 for now; each needs state the client mob doesn't expose yet):

  • is_sitting is_tamed is_sneaking is_sprinting is_blocking is_crawling is_swimming is_ridden is_using_item is_holding_item_* and the swinging-arm flags
  • anger_time, height_above_ground, fluid_depth_up, rule_index (it arrives with random models)
  • is_in_hand, is_in_gui and the other item/GUI contexts

Cost:

  • Compiled once per model at pack load, in two passes: the names fix the slot layout, then the expressions compile against it.
  • Per mob per frame: one f32 slot array, reused per thread; the expressions run (~35 ns of CPU each, see #5647); the bound parts' poses are copied in and out.
  • A model without animations costs nothing.

Docs I wrote it from (no mod source read):

  • OptiFine's cem_animation.txt (github.com/sp614x/optifine, OptiFineDoc/doc)
  • OptiDocs' animation page (optifine.readthedocs.io, CC0)
  • EMF's FEATURES.md and .github/emf_animation.txt

Depends on #5622, #5647 and #5659, stacked in that order. #5574, the shared crate, is on main.

Checks:

  • cargo fmt: clean
  • cargo clippy -p horizon-client --lib --bins --tests -- -D warnings: clean
  • cargo test -p horizon-client --lib mobs::cem: 5 passed (2 new). One runs an animation over a model with a renamed head and nested bone ids for two entities and two frames. It checks:
    • part.ty reads the vanilla pose
    • sin(limb_swing) lands in rx
    • an id path moves a nested bone
    • visible hides it once a per-entity counter passes 2
    • the counter is separate per entity
    • an expression with an unknown name is dropped while the rest run
  • pr_ready.py --quick --base origin/main on the whole stack: Public tree, Python tests (510), rustfmt, clippy and content-root tests passed. The workspace tests and launcher clippy/tests failed because the shared host's disk filled up mid-run ("No space left on device"), not on this code. CI on the fork runs the suite instead: https://github.com/some-du6e/horizon/actions/runs/41269603147
  • not run: an in-game look. There's no .local vanilla data here, so a reviewer with it should try an animated .jem (any Fresh Animations mob).

Note

Filed by Opus 5.5 using Claude Code.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/5665 **Author:** [@some-du6e](https://github.com/some-du6e) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `optifine/emf-animations` --- ### 📝 Commits (4) - [`a6fcdfa`](https://github.com/horizon-rust/horizon/commit/a6fcdfaf847d98155f5fe061bea740679c310ffc) OptiFine CEM: custom entity models animate - [`4c8d6b3`](https://github.com/horizon-rust/horizon/commit/4c8d6b3595f0864516783d8524879d3171a8ecc5) Merge optifine/emf-geometry into optifine/emf-animations - [`b1b7226`](https://github.com/horizon-rust/horizon/commit/b1b722682ac8a4bd1c8ce8400035556e7fcbeab2) Merge main into the OptiFine series - [`84bf620`](https://github.com/horizon-rust/horizon/commit/84bf62028b16e115ddf708bdea9997e77b9ddbca) Merge main into optifine/emf-animations ### 📊 Changes **5 files changed** (+585 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+15 -0) 📝 `crates/horizon-client/src/mobs.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs/cem.rs` (+26 -3) ➕ `crates/horizon-client/src/mobs/cem_anim.rs` (+534 -0) 📝 `crates/horizon-client/src/mobs/render.rs` (+9 -1) </details> ### 📄 Description Packs' custom entity models stood still: the previous PR swapped in their shapes, but the `animations` that make Fresh Animations' mobs breathe, look around and walk with knees still did nothing. This PR runs them. **What players get:** each `.jem`'s `animations` now run on every mob drawn with that model, every frame, after the vanilla animation has posed the parts (as in OptiFine): - `part.rx` reads the vanilla pose, and `head.rx = ...` overrides it. - **Targets:** `tx ty tz rx ry rz sx sy sz visible visible_boxes` (pixels and radians on vanilla's axes, as `ModelPart` keeps them) on: - `this` (the vanilla part for a replacing entry, the new bone for an attached one) - `part` - any OptiFine part name (through the same name table as the geometry) - any bone `id`, and hierarchical `a:b:c` paths searching ids below - **Variables:** `var.*`/`varb.*` persist per entity from frame to frame, kept per entity id, with at most 4096 entities per model before the table starts over. EMF's `global_var.*` is accepted too, but it is still per entity, not shared between entities. - **Parameters:** - from the entity: `limb_swing limb_speed age head_yaw head_pitch swing_progress health max_health hurt_time death_time pos_* rot_* id`, EMF's `distance move_forward move_strafing fluid_depth fluid_depth_down` - frame-wide: `time` (OptiFine's 27720-tick loop), `day_time day_count frame_time frame_counter dimension player_pos_* player_rot_*` - booleans: `is_alive is_burning is_child is_glowing is_hurt is_in_water is_in_lava is_wet is_invisible is_on_ground is_riding is_climbing is_jumping is_aggressive` (has a target), and EMF's `is_paused` and perspective flags (set to defaults for now) - `render.*` targets are accepted and do nothing yet: shadow and leash offsets need their renderers. - An expression that doesn't compile, or names something that doesn't exist, is skipped with a log warning instead of failing the whole model. **Not yet** (they read 0 for now; each needs state the client mob doesn't expose yet): - `is_sitting is_tamed is_sneaking is_sprinting is_blocking is_crawling is_swimming is_ridden is_using_item is_holding_item_*` and the swinging-arm flags - `anger_time`, `height_above_ground`, `fluid_depth_up`, `rule_index` (it arrives with random models) - `is_in_hand`, `is_in_gui` and the other item/GUI contexts **Cost:** - Compiled once per model at pack load, in two passes: the names fix the slot layout, then the expressions compile against it. - Per mob per frame: one `f32` slot array, reused per thread; the expressions run (~35 ns of CPU each, see #5647); the bound parts' poses are copied in and out. - A model without animations costs nothing. **Docs I wrote it from** (no mod source read): - OptiFine's `cem_animation.txt` (github.com/sp614x/optifine, OptiFineDoc/doc) - OptiDocs' animation page (optifine.readthedocs.io, CC0) - EMF's `FEATURES.md` and `.github/emf_animation.txt` **Depends on** #5622, #5647 and #5659, stacked in that order. #5574, the shared crate, is on main. **Checks:** - `cargo fmt`: clean - `cargo clippy -p horizon-client --lib --bins --tests -- -D warnings`: clean - `cargo test -p horizon-client --lib mobs::cem`: 5 passed (2 new). One runs an animation over a model with a renamed head and nested bone ids for two entities and two frames. It checks: - `part.ty` reads the vanilla pose - `sin(limb_swing)` lands in `rx` - an id path moves a nested bone - `visible` hides it once a per-entity counter passes 2 - the counter is separate per entity - an expression with an unknown name is dropped while the rest run - `pr_ready.py --quick --base origin/main` on the whole stack: Public tree, Python tests (510), rustfmt, clippy and content-root tests passed. The workspace tests and launcher clippy/tests failed because the shared host's disk filled up mid-run ("No space left on device"), not on this code. CI on the fork runs the suite instead: https://github.com/some-du6e/horizon/actions/runs/41269603147 - not run: an in-game look. There's no `.local` vanilla data here, so a reviewer with it should try an animated `.jem` (any Fresh Animations mob). > [!NOTE] > Filed by Opus 5.5 using Claude Code. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:20:23 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6425
No description provided.