[PR #6215] [MERGED] OptiFine random entities: vanilla when no rule matches, and custom-model and warden textures choose too #6721

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

📋 Pull Request Information

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

Base: main ← Head: optifine/etf-fixes


📝 Commits (5)

  • b1a756e OptiFine random entities: vanilla on a miss, custom-model and warden textures choose too
  • 12aa338 OptiFine random entities: budget every variant, one cem key, and a miss answered once a check
  • 587872b OptiFine random entities: a pack reload resets the miss throttle too
  • edccd5b Merge main into optifine/etf-fixes
  • 8512214 Merge main into optifine/etf-fixes

📊 Changes

7 files changed (+580 additions, -101 deletions)

View changed files

📝 crates/horizon-client-render/src/hud.rs (+74 -2)
📝 crates/horizon-client/src/game/packs.rs (+2 -4)
📝 crates/horizon-client/src/game/random_textures.rs (+8 -6)
📝 crates/horizon-client/src/mobs/random_textures.rs (+322 -80)
📝 crates/horizon-client/src/mobs/render.rs (+145 -6)
📝 crates/horizon-optifine/src/random.rs (+13 -3)
📝 crates/horizon-optifine/src/random_textures.rs (+16 -0)

📄 Description

#5744 (mobs wear their pack's random texture variants) merged before its review rounds finished. Those rounds found these bugs, all now on main:

  • A mob no rule matches wore <name>1.png instead of the vanilla texture. The same happened for a rule that lists ETF's 0, and for layers following the body's choice. ETF's guide says both mean the vanilla texture.
  • Layers with their own rules never chose.
    • choose walked only body() and layers(). The warden's glowing layers come from render_visible, so they never got a pick. That includes OptiFine's own example, warden_pulsating_spots_2.properties.
    • A .jem texture that replaces a layer's texture (#5659) didn't get one either, so those layers always drew the texture itself.
  • A frozen world stopped the rechecks. The once-a-second recheck was keyed to world.game_time, which doesn't advance under /tick freeze. During a freeze, one mob in 20 rechecked every tick and the rest never rechecked: a dyed sheep kept its old wool.
  • A newly drawn texture showed vanilla for up to a second. If a mob started drawing a texture that has its own rules (a wolf just tamed, with a wolf_tame.properties), it wore the vanilla texture until its next recheck.
  • Splitscreen players kept stale choices. A pack reload only reset the reloading player's mobs. The other players' mobs kept choices made from the old rules for up to a second.
  • A large variant pack could fail every pack. The atlas packed every variant with no limit. Past what the GPU takes, the whole pack set fell back to vanilla instead of just losing its variants.

What changed:

  • Rules::matching returns None when no rule matches. choose keeps that and an explicit 0 as variant 0, which is always the texture itself. Rules::select stays as it was.
  • render::drawn_textures lists the textures render_visible looks up: the body and each layer, a custom model's own texture in their place, and the warden's glowing layers. choose walks that list. It only reads MobData.cem; nothing in mobs/cem*.rs changes (the EMF thread is working there).
  • Choice counts this window's ticks itself:
    • first sight, a new scan, or a missed pick: choose now
    • otherwise every 20 ticks, with the first check spread by entity id
  • When texture() finds a texture with rules but no pick, it sets a flag, and the mob chooses on the next tick. That happens at most once between regular checks, so a texture drawn_textures doesn't list can't make the mob choose every tick. render_visible and drawn_textures share the body's custom-model key, and a comment asks to keep their lists in step.
  • Each RandomTextures scan gets a generation number. A choice from another generation is stale everywhere, so every splitscreen player's mobs choose again. forget_picks is gone.
  • The atlas packs at most 4096×2048 texels of variants, in name order, counting those beside their texture too, with a log warning for the rest. On top of the default 4096×5120 atlas that stays under the 8192 rows many GPUs allow. Mobs whose variant didn't fit wear the texture itself.
  • color() returns the llama's carpet colour as it is.

Not fixed here: the scan still runs twice at startup, once for MobData and once for the atlas. The two copies agree, and only the first pack reload replaces the MobData copy. Merging them means handing the atlas's scan to MobData while the world data loads, so that's left for a follow-up.

Docs (no mod source read):

  • OptiFine's random_entities.properties
  • ETF's RANDOM_GUIDE.md and random_entities.properties (index 0, the vanilla texture when no rule matches, villagers choosing their own)

Checks:

  • cargo fmt: clean
  • Locally, only cargo test -p horizon-optifine (the small OptiFine crate): 97 passed, including Rules::matching.
  • CI on my fork (verify: fmt, clippy -D warnings, cargo test --workspace): run linked in the first comment once it finishes.
  • New tests, with hand-worked picks:
    • mobs::random_textures:
      • a rule miss and ETF's 0 draw vanilla even when sheep1.png exists
      • a warden's warden_pulsating_spots_2 chooses with its own rules
      • recheck timing as a tick count (due on ticks 1 and 21 for entity 1)
      • a missed pick chooses on the next tick
      • a new scan makes choices stale
      • villager layers choose for themselves, in cases where following the body would differ
      • slime and phantom sizes, shulker colour, a librarian's level
    • render: a mob draws its variant's sprite, and the texture when the atlas lacks it.
    • hud: variants outside textures/ pack under their scan names, and those beside their texture under their own; the budget keeps the first variants that fit, in order.
    • a layer without rules follows the body's miss rather than its own <name>1.png
  • Not covered by a test: a .jem texture choosing. Building a CemModels in a test means changing mobs/cem.rs, which the EMF thread owns.
  • Not run: no live game test (no .local/ vanilla data here), so the review-loop's live step is skipped.

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/6215 **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/etf-fixes` --- ### 📝 Commits (5) - [`b1a756e`](https://github.com/horizon-rust/horizon/commit/b1a756ee59bc7ad3ad138b32e970f6d398fc6a45) OptiFine random entities: vanilla on a miss, custom-model and warden textures choose too - [`12aa338`](https://github.com/horizon-rust/horizon/commit/12aa3388627b490c79cdf460fae0557cb8e73254) OptiFine random entities: budget every variant, one cem key, and a miss answered once a check - [`587872b`](https://github.com/horizon-rust/horizon/commit/587872b392191ccdb2206fda9c009cfc7a67cb00) OptiFine random entities: a pack reload resets the miss throttle too - [`edccd5b`](https://github.com/horizon-rust/horizon/commit/edccd5b58ba8ce0ddc75495d2be94f789b4dabe9) Merge main into optifine/etf-fixes - [`8512214`](https://github.com/horizon-rust/horizon/commit/8512214d0ee1978ad4cb6c2a81ab05515bc7001d) Merge main into optifine/etf-fixes ### 📊 Changes **7 files changed** (+580 additions, -101 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/hud.rs` (+74 -2) 📝 `crates/horizon-client/src/game/packs.rs` (+2 -4) 📝 `crates/horizon-client/src/game/random_textures.rs` (+8 -6) 📝 `crates/horizon-client/src/mobs/random_textures.rs` (+322 -80) 📝 `crates/horizon-client/src/mobs/render.rs` (+145 -6) 📝 `crates/horizon-optifine/src/random.rs` (+13 -3) 📝 `crates/horizon-optifine/src/random_textures.rs` (+16 -0) </details> ### 📄 Description #5744 (mobs wear their pack's random texture variants) merged before its review rounds finished. Those rounds found these bugs, all now on main: - **A mob no rule matches wore `<name>1.png` instead of the vanilla texture.** The same happened for a rule that lists ETF's `0`, and for layers following the body's choice. ETF's guide says both mean the vanilla texture. - **Layers with their own rules never chose.** - `choose` walked only `body()` and `layers()`. The warden's glowing layers come from `render_visible`, so they never got a pick. That includes OptiFine's own example, `warden_pulsating_spots_2.properties`. - A `.jem` texture that replaces a layer's texture (#5659) didn't get one either, so those layers always drew the texture itself. - **A frozen world stopped the rechecks.** The once-a-second recheck was keyed to `world.game_time`, which doesn't advance under `/tick freeze`. During a freeze, one mob in 20 rechecked every tick and the rest never rechecked: a dyed sheep kept its old wool. - **A newly drawn texture showed vanilla for up to a second.** If a mob started drawing a texture that has its own rules (a wolf just tamed, with a `wolf_tame.properties`), it wore the vanilla texture until its next recheck. - **Splitscreen players kept stale choices.** A pack reload only reset the reloading player's mobs. The other players' mobs kept choices made from the old rules for up to a second. - **A large variant pack could fail every pack.** The atlas packed every variant with no limit. Past what the GPU takes, the whole pack set fell back to vanilla instead of just losing its variants. What changed: - `Rules::matching` returns `None` when no rule matches. `choose` keeps that and an explicit `0` as variant 0, which is always the texture itself. `Rules::select` stays as it was. - `render::drawn_textures` lists the textures `render_visible` looks up: the body and each layer, a custom model's own texture in their place, and the warden's glowing layers. `choose` walks that list. It only reads `MobData.cem`; nothing in `mobs/cem*.rs` changes (the EMF thread is working there). - `Choice` counts this window's ticks itself: - first sight, a new scan, or a missed pick: choose now - otherwise every 20 ticks, with the first check spread by entity id - When `texture()` finds a texture with rules but no pick, it sets a flag, and the mob chooses on the next tick. That happens at most once between regular checks, so a texture `drawn_textures` doesn't list can't make the mob choose every tick. `render_visible` and `drawn_textures` share the body's custom-model key, and a comment asks to keep their lists in step. - Each `RandomTextures` scan gets a generation number. A choice from another generation is stale everywhere, so every splitscreen player's mobs choose again. `forget_picks` is gone. - The atlas packs at most 4096×2048 texels of variants, in name order, counting those beside their texture too, with a log warning for the rest. On top of the default 4096×5120 atlas that stays under the 8192 rows many GPUs allow. Mobs whose variant didn't fit wear the texture itself. - `color()` returns the llama's carpet colour as it is. **Not fixed here:** the scan still runs twice at startup, once for `MobData` and once for the atlas. The two copies agree, and only the first pack reload replaces the `MobData` copy. Merging them means handing the atlas's scan to `MobData` while the world data loads, so that's left for a follow-up. **Docs** (no mod source read): - OptiFine's `random_entities.properties` - ETF's `RANDOM_GUIDE.md` and `random_entities.properties` (index 0, the vanilla texture when no rule matches, villagers choosing their own) **Checks:** - `cargo fmt`: clean - Locally, only `cargo test -p horizon-optifine` (the small OptiFine crate): 97 passed, including `Rules::matching`. - CI on my fork (`verify`: fmt, clippy `-D warnings`, `cargo test --workspace`): run linked in the first comment once it finishes. - New tests, with hand-worked picks: - `mobs::random_textures`: - a rule miss and ETF's 0 draw vanilla even when `sheep1.png` exists - a warden's `warden_pulsating_spots_2` chooses with its own rules - recheck timing as a tick count (due on ticks 1 and 21 for entity 1) - a missed pick chooses on the next tick - a new scan makes choices stale - villager layers choose for themselves, in cases where following the body would differ - slime and phantom sizes, shulker colour, a librarian's level - `render`: a mob draws its variant's sprite, and the texture when the atlas lacks it. - `hud`: variants outside `textures/` pack under their scan names, and those beside their texture under their own; the budget keeps the first variants that fit, in order. - a layer without rules follows the body's miss rather than its own `<name>1.png` - Not covered by a test: a `.jem` texture choosing. Building a `CemModels` in a test means changing `mobs/cem.rs`, which the EMF thread owns. - Not run: no live game test (no `.local/` vanilla data here), so the review-loop's live step is skipped. > [!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:26 +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#6721
No description provided.