[PR #6246] [MERGED] OptiFine entity models: a .jem's texture leaves overlays alone, and EMF's files win #6740

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

📋 Pull Request Information

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

Base: main ← Head: optifine/emf-model-fixes


📝 Commits (5)

  • e44848c OptiFine entity models: a .jem's texture leaves overlays alone, and EMF's files win
  • 07bdf9a OptiFine entity models: armour cracks keep their texture, and a broken file gives way
  • 96f70dc OptiFine entity models: the render test's spider wears the spider texture again
  • 6415af6 OptiFine entity models: a broken baby file gives way to the adult's, docs name the animations
  • 8a7c925 OptiFine entity models: say which random textures follow a .jem's texture

📊 Changes

6 files changed (+784 additions, -117 deletions)

View changed files

📝 AGENTS.md (+1 -1)
📝 crates/horizon-client/Cargo.toml (+2 -1)
📝 crates/horizon-client/src/mobs/cem.rs (+733 -89)
📝 crates/horizon-client/src/mobs/render.rs (+46 -24)
📝 docs/architecture.md (+1 -1)
📝 docs/resource-packs.md (+1 -1)

📄 Description

Custom entity models (#5659) shipped with bugs the review found but that weren't fixed before the merge:

  • A .jem that named its own texture also repainted every overlay drawn on the same model. A tame wolf's collar painted the whole wolf, spider and enderman eyes drew the body texture at full bright, villagers lost their clothes and showed two hats, and wolf armour lost its cracks.
  • A texture missing from the atlas made the mob invisible.
  • EMF's emf/cem/<name>/<name>.jem lost to OptiFine's flat file, though EMF's override folder should win.
  • A broken file kept a working one from applying.
  • docs/resource-packs.md still said entity models can't come from packs.

This fixes them in mobs/cem.rs and mobs/render.rs:

  • Textures:
    • A .jem's texture paints the body, and the first layer drawn with the .jem's own model (sheep_wool.jem on sheep#wool, wolf_armor.jem on the armour).
    • Later layers on the same model and the overlays on the body's model (eyes, collars, villager clothes, armour cracks) keep their own textures over the new geometry.
    • A texture the atlas doesn't have falls back to the vanilla one. A .jem texture outside textures/, or naming a file the pack doesn't have, is logged once at load.
  • Which file applies:
    • emf/cem comes before optifine/cem in both forms, and within a folder the flat <name>.jem comes before <name>/<name>.jem.
    • A layer tries its candidates in a fixed order (its own names sorted, then fallbacks nearest first) and takes the first that reads and parses. A broken llama_decor.jem gives way to trader_llama_decor.jem, a broken EMF file to OptiFine's, a broken zombie_baby.jem to zombie.jem. Each file is parsed at most once.
  • Fallbacks:
    • The documented ones, followed in chains: salmon_small/salmon_large → salmon, cat_collar → cat, cat_baby_collar → cat_collar → cat, and EMF's player_slim → player.
    • A fallback onto another layer of the model takes the geometry only, so the cat's collar keeps its texture.
    • nautilus_baby doesn't fall back: both docs say it has no fallback.
  • Part names: the small pufferfish's fins map to right_fin/left_fin, the names the game's own animation code uses for that model, and the rabbit's feet to left_hind_foot/right_hind_foot. I left the other names reviewers questioned (salmon fins, pufferfish eyes, rabbit thighs) alone, since nothing in the game's code backs them.
  • Cost: only the files some layer will use are parsed, and with no .jem files nothing is built at all.
  • Docs: docs/resource-packs.md gets a "Custom entity models (OptiFine/EMF)" row; AGENTS.md and docs/architecture.md list mobs/cem.rs, mobs/cem_anim.rs and horizon-optifine.

Docs I worked from (no mod source read): OptiFine's cem_model.txt (part names and fallbacks), EMF's emf_model.txt and FEATURES.md.

Checks:

  • cargo fmt: clean
  • Tests (new in cem.rs):
    • EMF's folder form beats an OptiFine flat file, and a directory named x.jem doesn't shadow
    • a baby's own file beats the adult's
    • the deterministic llama_decor winner
    • broken files give way to the next candidate
    • the fallbacks and chains: salmon_small, cat_baby#collar, none for nautilus_baby, geometry only for the collars
    • an unknown part is skipped while the rest applies
    • render-level, on synthetic mobs:
      • a spider's body draws in the .jem texture's rect while its eyes keep theirs, and with the texture missing the body draws the vanilla one
      • a sheep's wool takes sheep_wool.jem's texture
      • a tame wolf's armour takes wolf_armor.jem's texture while its cracks and collar keep theirs
    • The missing-texture log has no test.
  • An #[ignore]d test, names_reach_horizons_models, checks against the real models when HORIZON_TEST_RESOURCES is set: every LAYERS and FALLBACKS entry, every vanilla baby layer, and a sample of renamed parts. It hasn't been run here, since there's no .local/. It's the one a maintainer with the data should run.
  • Build, clippy and the suite run in fork CI, since this machine doesn't build. An earlier head compiled and passed clippy there; the latest head is at https://github.com/some-du6e/horizon/actions/runs/41341432268 (verify passed on the previous head, 6415af6df)
  • Review loop: three rounds. Rounds 2 and 3 found no correctness problems; their test, doc and comment gaps are fixed. The module doc now says which random textures follow a .jem's texture: variants without rules do. Rule-based .properties for it are a gap on the random-textures side, noted on #6217 along with how that PR should use this one's texture rule. The live game test is skipped (no .local/).

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/6246 **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-model-fixes` --- ### 📝 Commits (5) - [`e44848c`](https://github.com/horizon-rust/horizon/commit/e44848cf9b47dc6536cd2c682c0709707fb3a707) OptiFine entity models: a .jem's texture leaves overlays alone, and EMF's files win - [`07bdf9a`](https://github.com/horizon-rust/horizon/commit/07bdf9af4ee2c7ee92d73ed26364bdb2cec35d55) OptiFine entity models: armour cracks keep their texture, and a broken file gives way - [`96f70dc`](https://github.com/horizon-rust/horizon/commit/96f70dc451a3b05ada53a63e7780e8e39c7059c4) OptiFine entity models: the render test's spider wears the spider texture again - [`6415af6`](https://github.com/horizon-rust/horizon/commit/6415af6dfc54173b9b0e6e7c0855b21782b56681) OptiFine entity models: a broken baby file gives way to the adult's, docs name the animations - [`8a7c925`](https://github.com/horizon-rust/horizon/commit/8a7c9259f03af7005ec8072cd2dc3991c0ee4af1) OptiFine entity models: say which random textures follow a .jem's texture ### 📊 Changes **6 files changed** (+784 additions, -117 deletions) <details> <summary>View changed files</summary> 📝 `AGENTS.md` (+1 -1) 📝 `crates/horizon-client/Cargo.toml` (+2 -1) 📝 `crates/horizon-client/src/mobs/cem.rs` (+733 -89) 📝 `crates/horizon-client/src/mobs/render.rs` (+46 -24) 📝 `docs/architecture.md` (+1 -1) 📝 `docs/resource-packs.md` (+1 -1) </details> ### 📄 Description Custom entity models (#5659) shipped with bugs the review found but that weren't fixed before the merge: - A `.jem` that named its own texture also repainted every overlay drawn on the same model. A tame wolf's collar painted the whole wolf, spider and enderman eyes drew the body texture at full bright, villagers lost their clothes and showed two hats, and wolf armour lost its cracks. - A texture missing from the atlas made the mob invisible. - EMF's `emf/cem/<name>/<name>.jem` lost to OptiFine's flat file, though EMF's override folder should win. - A broken file kept a working one from applying. - `docs/resource-packs.md` still said entity models can't come from packs. This fixes them in `mobs/cem.rs` and `mobs/render.rs`: - **Textures:** - A `.jem`'s texture paints the body, and the first layer drawn with the `.jem`'s own model (`sheep_wool.jem` on `sheep#wool`, `wolf_armor.jem` on the armour). - Later layers on the same model and the overlays on the body's model (eyes, collars, villager clothes, armour cracks) keep their own textures over the new geometry. - A texture the atlas doesn't have falls back to the vanilla one. A `.jem` texture outside `textures/`, or naming a file the pack doesn't have, is logged once at load. - **Which file applies:** - `emf/cem` comes before `optifine/cem` in both forms, and within a folder the flat `<name>.jem` comes before `<name>/<name>.jem`. - A layer tries its candidates in a fixed order (its own names sorted, then fallbacks nearest first) and takes the first that reads and parses. A broken `llama_decor.jem` gives way to `trader_llama_decor.jem`, a broken EMF file to OptiFine's, a broken `zombie_baby.jem` to `zombie.jem`. Each file is parsed at most once. - **Fallbacks:** - The documented ones, followed in chains: `salmon_small`/`salmon_large` → `salmon`, `cat_collar` → `cat`, `cat_baby_collar` → `cat_collar` → `cat`, and EMF's `player_slim` → `player`. - A fallback onto another layer of the model takes the geometry only, so the cat's collar keeps its texture. - `nautilus_baby` doesn't fall back: both docs say it has no fallback. - **Part names:** the small pufferfish's fins map to `right_fin`/`left_fin`, the names the game's own animation code uses for that model, and the rabbit's feet to `left_hind_foot`/`right_hind_foot`. I left the other names reviewers questioned (salmon fins, pufferfish eyes, rabbit thighs) alone, since nothing in the game's code backs them. - **Cost:** only the files some layer will use are parsed, and with no `.jem` files nothing is built at all. - **Docs:** `docs/resource-packs.md` gets a "Custom entity models (OptiFine/EMF)" row; AGENTS.md and `docs/architecture.md` list `mobs/cem.rs`, `mobs/cem_anim.rs` and `horizon-optifine`. Docs I worked from (no mod source read): OptiFine's `cem_model.txt` (part names and fallbacks), EMF's `emf_model.txt` and `FEATURES.md`. Checks: - `cargo fmt`: clean - Tests (new in `cem.rs`): - EMF's folder form beats an OptiFine flat file, and a directory named `x.jem` doesn't shadow - a baby's own file beats the adult's - the deterministic `llama_decor` winner - broken files give way to the next candidate - the fallbacks and chains: `salmon_small`, `cat_baby#collar`, none for `nautilus_baby`, geometry only for the collars - an unknown part is skipped while the rest applies - render-level, on synthetic mobs: - a spider's body draws in the `.jem` texture's rect while its eyes keep theirs, and with the texture missing the body draws the vanilla one - a sheep's wool takes `sheep_wool.jem`'s texture - a tame wolf's armour takes `wolf_armor.jem`'s texture while its cracks and collar keep theirs - The missing-texture log has no test. - An `#[ignore]`d test, `names_reach_horizons_models`, checks against the real models when `HORIZON_TEST_RESOURCES` is set: every `LAYERS` and `FALLBACKS` entry, every vanilla baby layer, and a sample of renamed parts. It hasn't been run here, since there's no `.local/`. It's the one a maintainer with the data should run. - Build, clippy and the suite run in fork CI, since this machine doesn't build. An earlier head compiled and passed clippy there; the latest head is at https://github.com/some-du6e/horizon/actions/runs/41341432268 (`verify` passed on the previous head, 6415af6df) - Review loop: three rounds. Rounds 2 and 3 found no correctness problems; their test, doc and comment gaps are fixed. The module doc now says which random textures follow a `.jem`'s texture: variants without rules do. Rule-based `.properties` for it are a gap on the random-textures side, noted on #6217 along with how that PR should use this one's texture rule. The live game test is skipped (no `.local/`). > [!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:25:58 +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#6740
No description provided.