[PR #5659] [MERGED] OptiFine entity models: packs' .jem files reshape mobs #6423

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

📋 Pull Request Information

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

Base: main ← Head: optifine/emf-geometry


📝 Commits (10+)

  • b2a09a2 OptiFine CEM: read .jem and .jpm entity models into vanilla-frame geometry
  • 02a522b OptiFine CEM: compile animation expressions once, evaluate them without allocating
  • 91b523c OptiFine CEM: packs' .jem models reshape mobs
  • d8c627e Merge main into optifine/emf-jem
  • 9469537 OptiFine CEM: read .jem files the way OptiFine does, and keep packs inside the root
  • af00d7a CLAUDE.md: list horizon-optifine among the crates
  • 5eeb2cd OptiFine reader: paths with a backslash are refused too
  • d037799 OptiFine CEM: inheriting shares instead of copying, every entry and bone counts
  • a52700e OptiFine CEM: third review round of the .jem reader
  • c0be27a OptiFine CEM: first review round of the expression compiler

📊 Changes

19 files changed (+3462 additions, -13 deletions)

View changed files

📝 AGENTS.md (+1 -0)
📝 Cargo.lock (+2 -0)
📝 crates/horizon-client/Cargo.toml (+1 -0)
📝 crates/horizon-client/src/game.rs (+4 -1)
📝 crates/horizon-client/src/game/packs.rs (+14 -0)
📝 crates/horizon-client/src/game/perspective.rs (+1 -0)
📝 crates/horizon-client/src/mobs.rs (+1 -0)
➕ crates/horizon-client/src/mobs/cem.rs (+510 -0)
📝 crates/horizon-client/src/mobs/data.rs (+4 -0)
📝 crates/horizon-client/src/mobs/render.rs (+41 -8)
📝 crates/horizon-optifine/Cargo.toml (+5 -1)
➕ crates/horizon-optifine/examples/cem_expr_bench.rs (+136 -0)
➕ crates/horizon-optifine/src/cem/curves.rs (+157 -0)
➕ crates/horizon-optifine/src/cem/expr.rs (+996 -0)
➕ crates/horizon-optifine/src/cem/json.rs (+340 -0)
➕ crates/horizon-optifine/src/cem/mod.rs (+9 -0)
➕ crates/horizon-optifine/src/cem/model.rs (+1234 -0)
📝 crates/horizon-optifine/src/lib.rs (+1 -0)
📝 crates/horizon-optifine/src/paths.rs (+5 -3)

📄 Description

Packs that reshape mobs with OptiFine's custom entity models (optifine/cem/zombie.jem, Fresh Animations' rigs, the many "3D mobs" packs) still drew vanilla's models in Horizon. With this PR, a pack's .jem models now replace or extend the mob models they target, the way Entity Model Features does on Fabric. Animations come in the next PR, so until then a custom model stands in the vanilla animation's pose.

What players get:

  • Each .jem under assets/minecraft/optifine/cem/ reshapes the model layer it names. That includes the cem/<name>/<name>.jem folder form and EMF's assets/minecraft/emf/cem/ override, which wins over OptiFine's.

    • layer names: zombie.jem → zombie#main, sheep_wool.jem → sheep#wool, creeper_charge.jem → creeper#armor, drowned_outer.jem → drowned#outer, puffer_fish_big.jem → pufferfish_big#main, tropical fish patterns and so on
  • Each entry's boxes either replace the vanilla part's own cubes (attach: false) or join them (attach: true), and move with the vanilla part's animation. scale sizes them.

  • OptiFine's part names map to the game's (from cem_model.txt's tables):

    • headwear → hat
    • quadrupeds' leg1..4 and spiders' leg1..8 in vanilla's order
    • back_left_leg → left_hind_leg
    • villagers' headwear2/bodywear
    • tentacleN, stickN, spineN, segmentN, wingN, numbered from 0
    • wither heads, bees', wardens', snow golems', slimes', magma cubes', horses' and phantoms' renamed parts, strider bristles, pufferfish spikes and fins

    A name with no mapping that the game also uses (left_arm, jaw...) stays as it is. A name neither knows is skipped with a warning.

  • Baby layers without their own file use the adult's model (zombie.jem reshapes baby zombies), as cem_model.txt's fallback table and EMF's FEATURES (horses too) say.

  • A .jem's own texture replaces the layer's vanilla texture when it lives under textures/ (so it's in the entity atlas).

  • No CEM files: nothing is built, and every model stays vanilla's.

Cost: models are built when the packs load, and again on every pack reload on the reload worker (stage_pack), never on the render thread. They're swapped into MobData the way villager hats already are. A mob's draw does one hash lookup to swap the layer's part tree and nothing else.

ETF seam: the .jem texture replaces the layer's texture name before it is drawn. Random and emissive selection (the ETF thread) can work from that name the same way it does from vanilla's.

Not in this PR:

  • per-bone textures (a part or submodel texture other than the model's): the shared Part has one texture per draw
  • textures kept inside optifine/ folders: they aren't in the entity atlas. The ETF thread needs that seam too.
  • random models (zombie2.jem + .properties)
  • EMF's armor and player models
  • block entities, boats, minecarts and armor stands, which have their own renderers

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

  • OptiFine's cem_model.txt and cem_part.txt (github.com/sp614x/optifine, OptiFineDoc/doc): the part name tables, fallbacks and file locations
  • OptiDocs' CEM pages (optifine.readthedocs.io, CC0)
  • EMF's FEATURES.md and .github/emf_model.txt (the emf/cem folder, horse baby fallbacks)

Depends on #5622 (the .jem reader) and #5647 (the expression compiler, which this PR doesn't use yet). Neither is merged, and this branch stacks on both. #5574, the shared crate, is on main.

Checks:

  • cargo fmt: clean
  • cargo clippy -p horizon-client --lib --bins --tests -- -D warnings: clean (10 min on the shared machine)
  • cargo test -p horizon-client --lib mobs::cem: 3 passed. They cover layer names (babies, _outer, pufferfish), part names checked against the doc tables, and a temp pack whose .jem files reshape synthetic layers: replace clears the part's cubes but keeps its children, attach keeps them and scales the new bone, babies fall back, emf/cem wins over a broken optifine/cem file, and the texture becomes its atlas name.
  • cargo test -p horizon-optifine: 21 passed
  • not run: the rest of the horizon-client suite and pr_ready.py. This machine has no .local vanilla data, so I couldn't check the part names against the real entity-models.json or look at the result in game. That's the main thing a reviewer with .local should do: drop a .jem into a pack and look at a zombie.

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/5659 **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-geometry` --- ### 📝 Commits (10+) - [`b2a09a2`](https://github.com/horizon-rust/horizon/commit/b2a09a2118909ee17da22fb44c3006afbe650e11) OptiFine CEM: read .jem and .jpm entity models into vanilla-frame geometry - [`02a522b`](https://github.com/horizon-rust/horizon/commit/02a522b86833bc21acd215623ab3ed7977a4e225) OptiFine CEM: compile animation expressions once, evaluate them without allocating - [`91b523c`](https://github.com/horizon-rust/horizon/commit/91b523cc48667a9a063350eaa5750de5b34c80ca) OptiFine CEM: packs' .jem models reshape mobs - [`d8c627e`](https://github.com/horizon-rust/horizon/commit/d8c627e75ed61b3fef2dea5fdb877e642701a744) Merge main into optifine/emf-jem - [`9469537`](https://github.com/horizon-rust/horizon/commit/9469537b1409349518e732bfefb5f5b7e60b6dee) OptiFine CEM: read .jem files the way OptiFine does, and keep packs inside the root - [`af00d7a`](https://github.com/horizon-rust/horizon/commit/af00d7af2b79b3642073319d3632a2bb2c7f057c) CLAUDE.md: list horizon-optifine among the crates - [`5eeb2cd`](https://github.com/horizon-rust/horizon/commit/5eeb2cdd7e039ffae4f10f7e47597b783b354504) OptiFine reader: paths with a backslash are refused too - [`d037799`](https://github.com/horizon-rust/horizon/commit/d0377992dba118264623c58fffed4d0a0e6c9b66) OptiFine CEM: inheriting shares instead of copying, every entry and bone counts - [`a52700e`](https://github.com/horizon-rust/horizon/commit/a52700ebae645f5f7c4c74964c6e614a43a4e6ee) OptiFine CEM: third review round of the .jem reader - [`c0be27a`](https://github.com/horizon-rust/horizon/commit/c0be27ae15b99fd7d93b6cd809dda63526cb207f) OptiFine CEM: first review round of the expression compiler ### 📊 Changes **19 files changed** (+3462 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `AGENTS.md` (+1 -0) 📝 `Cargo.lock` (+2 -0) 📝 `crates/horizon-client/Cargo.toml` (+1 -0) 📝 `crates/horizon-client/src/game.rs` (+4 -1) 📝 `crates/horizon-client/src/game/packs.rs` (+14 -0) 📝 `crates/horizon-client/src/game/perspective.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs.rs` (+1 -0) ➕ `crates/horizon-client/src/mobs/cem.rs` (+510 -0) 📝 `crates/horizon-client/src/mobs/data.rs` (+4 -0) 📝 `crates/horizon-client/src/mobs/render.rs` (+41 -8) 📝 `crates/horizon-optifine/Cargo.toml` (+5 -1) ➕ `crates/horizon-optifine/examples/cem_expr_bench.rs` (+136 -0) ➕ `crates/horizon-optifine/src/cem/curves.rs` (+157 -0) ➕ `crates/horizon-optifine/src/cem/expr.rs` (+996 -0) ➕ `crates/horizon-optifine/src/cem/json.rs` (+340 -0) ➕ `crates/horizon-optifine/src/cem/mod.rs` (+9 -0) ➕ `crates/horizon-optifine/src/cem/model.rs` (+1234 -0) 📝 `crates/horizon-optifine/src/lib.rs` (+1 -0) 📝 `crates/horizon-optifine/src/paths.rs` (+5 -3) </details> ### 📄 Description Packs that reshape mobs with OptiFine's custom entity models (`optifine/cem/zombie.jem`, Fresh Animations' rigs, the many "3D mobs" packs) still drew vanilla's models in Horizon. With this PR, a pack's `.jem` models now replace or extend the mob models they target, the way Entity Model Features does on Fabric. Animations come in the next PR, so until then a custom model stands in the vanilla animation's pose. **What players get:** - Each `.jem` under `assets/minecraft/optifine/cem/` reshapes the model layer it names. That includes the `cem/<name>/<name>.jem` folder form and EMF's `assets/minecraft/emf/cem/` override, which wins over OptiFine's. - layer names: `zombie.jem` → `zombie#main`, `sheep_wool.jem` → `sheep#wool`, `creeper_charge.jem` → `creeper#armor`, `drowned_outer.jem` → `drowned#outer`, `puffer_fish_big.jem` → `pufferfish_big#main`, tropical fish patterns and so on - Each entry's boxes either replace the vanilla part's own cubes (`attach: false`) or join them (`attach: true`), and move with the vanilla part's animation. `scale` sizes them. - OptiFine's part names map to the game's (from `cem_model.txt`'s tables): - `headwear` → `hat` - quadrupeds' `leg1..4` and spiders' `leg1..8` in vanilla's order - `back_left_leg` → `left_hind_leg` - villagers' `headwear2`/`bodywear` - `tentacleN`, `stickN`, `spineN`, `segmentN`, `wingN`, numbered from 0 - wither heads, bees', wardens', snow golems', slimes', magma cubes', horses' and phantoms' renamed parts, strider bristles, pufferfish spikes and fins A name with no mapping that the game also uses (`left_arm`, `jaw`...) stays as it is. A name neither knows is skipped with a warning. - Baby layers without their own file use the adult's model (`zombie.jem` reshapes baby zombies), as `cem_model.txt`'s fallback table and EMF's FEATURES (horses too) say. - A `.jem`'s own `texture` replaces the layer's vanilla texture when it lives under `textures/` (so it's in the entity atlas). - No CEM files: nothing is built, and every model stays vanilla's. **Cost:** models are built when the packs load, and again on every pack reload on the reload worker (`stage_pack`), never on the render thread. They're swapped into `MobData` the way villager hats already are. A mob's draw does one hash lookup to swap the layer's part tree and nothing else. **ETF seam:** the `.jem` texture replaces the layer's texture name before it is drawn. Random and emissive selection (the ETF thread) can work from that name the same way it does from vanilla's. **Not in this PR:** - per-bone textures (a part or submodel `texture` other than the model's): the shared `Part` has one texture per draw - textures kept inside `optifine/` folders: they aren't in the entity atlas. The ETF thread needs that seam too. - random models (`zombie2.jem` + `.properties`) - EMF's armor and player models - block entities, boats, minecarts and armor stands, which have their own renderers **Docs I wrote it from** (no mod source read): - OptiFine's `cem_model.txt` and `cem_part.txt` (github.com/sp614x/optifine, OptiFineDoc/doc): the part name tables, fallbacks and file locations - OptiDocs' CEM pages (optifine.readthedocs.io, CC0) - EMF's `FEATURES.md` and `.github/emf_model.txt` (the `emf/cem` folder, horse baby fallbacks) **Depends on** #5622 (the `.jem` reader) and #5647 (the expression compiler, which this PR doesn't use yet). Neither is merged, and this branch stacks on both. #5574, the shared crate, is on main. **Checks:** - `cargo fmt`: clean - `cargo clippy -p horizon-client --lib --bins --tests -- -D warnings`: clean (10 min on the shared machine) - `cargo test -p horizon-client --lib mobs::cem`: 3 passed. They cover layer names (babies, `_outer`, pufferfish), part names checked against the doc tables, and a temp pack whose `.jem` files reshape synthetic layers: replace clears the part's cubes but keeps its children, attach keeps them and scales the new bone, babies fall back, `emf/cem` wins over a broken `optifine/cem` file, and the texture becomes its atlas name. - `cargo test -p horizon-optifine`: 21 passed - not run: the rest of the `horizon-client` suite and `pr_ready.py`. This machine has no `.local` vanilla data, so I couldn't check the part names against the real `entity-models.json` or look at the result in game. That's the main thing a reviewer with `.local` should do: drop a `.jem` into a pack and look at a zombie. > [!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:22 +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#6423
No description provided.