[PR #5744] [MERGED] OptiFine random entities: mobs wear their pack's texture variants #6471

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

📋 Pull Request Information

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

Base: main ← Head: optifine/etf-game


📝 Commits (10+)

  • a6fcdfa OptiFine CEM: custom entity models animate
  • 6049010 OptiFine random entities: read the rules that pick an entity's texture variant
  • ffb010b OptiFine random entities: a rule with a bad or unsupported condition never matches
  • 9375dab OptiFine random entities: nbt list paths, seedSource and exact health percent
  • a8a1d74 OptiFine random entities: biome patterns, and empty conditions skip the rule
  • 733c361 OptiFine random entities: a lone ! or an empty weights line, and one key scan
  • 2e80781 OptiFine random entities: the bad-condition test uses facts a dropped entry would pass
  • 90f5650 OptiFine random entities: a blocks rule fails when no blocks are known
  • 763a448 OptiFine random entities: say what empty Facts.blocks means
  • db3b3df OptiFine random entities: a file holds at most 1024 rules

📊 Changes

22 files changed (+2496 additions, -32 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-client-render/Cargo.toml (+1 -0)
📝 crates/horizon-client-render/src/hud.rs (+37 -7)
📝 crates/horizon-client/Cargo.toml (+1 -1)
📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/creatures.rs (+15 -0)
📝 crates/horizon-client/src/game/packs.rs (+11 -0)
📝 crates/horizon-client/src/game/perspective.rs (+1 -0)
➕ crates/horizon-client/src/game/random_textures.rs (+64 -0)
📝 crates/horizon-client/src/game/remote.rs (+1 -0)
📝 crates/horizon-client/src/mobs.rs (+5 -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/data.rs (+7 -0)
📝 crates/horizon-client/src/mobs/llama.rs (+1 -1)
➕ crates/horizon-client/src/mobs/random_textures.rs (+349 -0)
📝 crates/horizon-client/src/mobs/render.rs (+30 -6)
📝 crates/horizon-optifine/src/lib.rs (+7 -2)
📝 crates/horizon-optifine/src/matchers.rs (+15 -8)
📝 crates/horizon-optifine/src/paths.rs (+34 -4)

...and 2 more files

📄 Description

Packs with OptiFine random entity textures (several zombie skins, desert villagers, a pig named "Pinky") still drew every mob of a kind with the same texture in Horizon. With this PR, mobs wear their pack's variants, chosen the way OptiFine and Entity Texture Features choose them. #5710 reads the rules and #5716 finds the files; this PR draws them.

What players get:

  • The variants under optifine/random/entity/, ETF's etf/random/entity/ and the legacy optifine/mob/ and mcpatcher/mob/ (and beside the texture when a .properties is there) replace the body texture and every layer texture they vary: wool, eyes, saddles, collars, armour, villager types and professions.
  • When a mob chooses:
    • When this window first sees it. That's OptiFine's "when it is first seen by the client" for multiplayer, and on the default server-thread single-player path every mob is a server mob.
    • Again once a second, staggered by entity id, never per frame.
    • On every resource-pack reload.
  • Facts read:
    • Fixed at the first sighting:
      • biome, block height
      • the block below and the block it stands in (ETF reads both)
      • moon phase, time of day, weather
    • Read fresh at each check (ETF's "updating" properties):
      • custom name
      • villager and zombie villager profession and level
      • colour: sheep wool, wolf and cat collars, llama carpet, shulker shell
      • baby, health and max health
      • slime, magma cube and phantom size
    • A dyed sheep or a renamed mob changes its look within a second; a zombie that walks out of the desert keeps its desert texture.
  • Seed: Java's UUID.hashCode of the entity's UUID, which the client already keeps (persist.uuids), or the entity id when it doesn't know it.
  • Layers: a layer with its own rules (or those of the name it extends, wolf_tame → wolf) wears that file's pick. A layer without rules follows the body's variant, so a sheep in sheep3 wears sheep_wool3 when the pack has it, as ETF does. Villager layers choose their own, as ETF's docs say.
  • No pack with these files: nothing is scanned into the atlas, no mob chooses anything, and every mob draws exactly as before.

How:

  • HudAtlas (the entity atlas) runs RandomTextures::scan while it packs, and packs each variant under the name the scan gives it (minecraft:optifine/random/entity/zombie/zombie2). Files beside their texture are walked already.
  • The pack reload hands the scan from the new atlas to MobData.random_textures on the render thread, like villager hats. No second scan.
  • Mob.random_textures holds the mob's first sighting, seed and picks. game/random_textures.rs (tick_random_textures, called from tick_remote after the entities) fills it. The per-mob work is body() + layers(), the facts, and one Rules::select per rule file, once a second per mob.
  • render_visible's only change: the body's and each layer's atlas lookup first asks mobs::random_textures::texture, which does two hash lookups and a scan of a short vec. The texture keeps its own name for the rest of the code (horse markings' translucency, villager hats). A variant the atlas lacks falls back to the texture.

EMF seam: #5659 replaces a layer's texture name with its .jem's texture before drawing. This lookup runs on whatever name is drawn, so a custom model's texture gets variants too if the pack ships them. The two changes touch neighbouring lines in render_visible, and whichever lands second rebases. Variants under optifine/ are in the entity atlas now, which #5659 listed as a gap for its own .jem textures there.

Not in this PR (next in the stack): emissive _e overlays, ETF blinking, block entities (chests, beds, shulker boxes), nbt.* and ETF's extra conditions (teams, items, ...), which #5710 skips.

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

  • OptiFine's OptiFineDoc/doc/random_entities.properties
  • ETF's RANDOM_GUIDE.md: updating properties, layers matching the body's variant, villagers choosing their own

Checks:

  • cargo fmt: clean
  • CI on my fork (verify: fmt, clippy -D warnings, cargo test --workspace): passed on this branch. Run: https://github.com/some-du6e/horizon/actions/runs/41274781368
  • New tests (mobs::random_textures), with temp packs and hand-worked picks:
    • a red sheep picks sheep3 and its wool sheep_wool3, and turns sheep2 once dyed white
    • the desert sighting is kept after walking into plains
    • the wool follows an even choice of the body, falling back to vanilla when its number is missing
    • seeds from the client's UUID ints, with the unsigned low word
  • Not run: no live game test. This machine has no .local/ vanilla data, so I couldn't load a pack and look at mobs; the review-loop's live test step was skipped for that reason. A reviewer with .local should drop an optifine/random/entity/zombie/zombie2.png into a pack and look at zombies.

Stacked on #5716 and #5710; this branch includes their commits until they merge.

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/5744 **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-game` --- ### 📝 Commits (10+) - [`a6fcdfa`](https://github.com/horizon-rust/horizon/commit/a6fcdfaf847d98155f5fe061bea740679c310ffc) OptiFine CEM: custom entity models animate - [`6049010`](https://github.com/horizon-rust/horizon/commit/6049010105be7fa6c51ab695529af56055699dcc) OptiFine random entities: read the rules that pick an entity's texture variant - [`ffb010b`](https://github.com/horizon-rust/horizon/commit/ffb010b543d40f072a95eb9a5e1f41945df4a60e) OptiFine random entities: a rule with a bad or unsupported condition never matches - [`9375dab`](https://github.com/horizon-rust/horizon/commit/9375dab6328006ec380095908d58f5f4d9d09f11) OptiFine random entities: nbt list paths, seedSource and exact health percent - [`a8a1d74`](https://github.com/horizon-rust/horizon/commit/a8a1d74d1573cbf91f91ad58abbf19ffe8ea08df) OptiFine random entities: biome patterns, and empty conditions skip the rule - [`733c361`](https://github.com/horizon-rust/horizon/commit/733c361874bba9c115347c847759786981dfb3fb) OptiFine random entities: a lone ! or an empty weights line, and one key scan - [`2e80781`](https://github.com/horizon-rust/horizon/commit/2e80781c76ef2e22149a46ec75e390b40bb13cec) OptiFine random entities: the bad-condition test uses facts a dropped entry would pass - [`90f5650`](https://github.com/horizon-rust/horizon/commit/90f565000793666ebc525c30c4d26e1be6e59f5e) OptiFine random entities: a blocks rule fails when no blocks are known - [`763a448`](https://github.com/horizon-rust/horizon/commit/763a4489850c8f4b4d81feb6c092278316658b4e) OptiFine random entities: say what empty Facts.blocks means - [`db3b3df`](https://github.com/horizon-rust/horizon/commit/db3b3dfb96e60897488885f8a3b04e2c10c33470) OptiFine random entities: a file holds at most 1024 rules ### 📊 Changes **22 files changed** (+2496 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-client-render/Cargo.toml` (+1 -0) 📝 `crates/horizon-client-render/src/hud.rs` (+37 -7) 📝 `crates/horizon-client/Cargo.toml` (+1 -1) 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+15 -0) 📝 `crates/horizon-client/src/game/packs.rs` (+11 -0) 📝 `crates/horizon-client/src/game/perspective.rs` (+1 -0) ➕ `crates/horizon-client/src/game/random_textures.rs` (+64 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs.rs` (+5 -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/data.rs` (+7 -0) 📝 `crates/horizon-client/src/mobs/llama.rs` (+1 -1) ➕ `crates/horizon-client/src/mobs/random_textures.rs` (+349 -0) 📝 `crates/horizon-client/src/mobs/render.rs` (+30 -6) 📝 `crates/horizon-optifine/src/lib.rs` (+7 -2) 📝 `crates/horizon-optifine/src/matchers.rs` (+15 -8) 📝 `crates/horizon-optifine/src/paths.rs` (+34 -4) _...and 2 more files_ </details> ### 📄 Description Packs with OptiFine random entity textures (several zombie skins, desert villagers, a pig named "Pinky") still drew every mob of a kind with the same texture in Horizon. With this PR, mobs wear their pack's variants, chosen the way OptiFine and Entity Texture Features choose them. #5710 reads the rules and #5716 finds the files; this PR draws them. **What players get:** - The variants under `optifine/random/entity/`, ETF's `etf/random/entity/` and the legacy `optifine/mob/` and `mcpatcher/mob/` (and beside the texture when a `.properties` is there) replace the body texture and every layer texture they vary: wool, eyes, saddles, collars, armour, villager types and professions. - **When a mob chooses:** - When this window first sees it. That's OptiFine's "when it is first seen by the client" for multiplayer, and on the default server-thread single-player path every mob is a server mob. - Again once a second, staggered by entity id, never per frame. - On every resource-pack reload. - **Facts read:** - Fixed at the first sighting: - biome, block height - the block below and the block it stands in (ETF reads both) - moon phase, time of day, weather - Read fresh at each check (ETF's "updating" properties): - custom name - villager and zombie villager profession and level - colour: sheep wool, wolf and cat collars, llama carpet, shulker shell - baby, health and max health - slime, magma cube and phantom size - A dyed sheep or a renamed mob changes its look within a second; a zombie that walks out of the desert keeps its desert texture. - **Seed:** Java's `UUID.hashCode` of the entity's UUID, which the client already keeps (`persist.uuids`), or the entity id when it doesn't know it. - **Layers:** a layer with its own rules (or those of the name it extends, `wolf_tame` → `wolf`) wears that file's pick. A layer without rules follows the body's variant, so a sheep in `sheep3` wears `sheep_wool3` when the pack has it, as ETF does. Villager layers choose their own, as ETF's docs say. - No pack with these files: nothing is scanned into the atlas, no mob chooses anything, and every mob draws exactly as before. **How:** - `HudAtlas` (the entity atlas) runs `RandomTextures::scan` while it packs, and packs each variant under the name the scan gives it (`minecraft:optifine/random/entity/zombie/zombie2`). Files beside their texture are walked already. - The pack reload hands the scan from the new atlas to `MobData.random_textures` on the render thread, like villager hats. No second scan. - `Mob.random_textures` holds the mob's first sighting, seed and picks. `game/random_textures.rs` (`tick_random_textures`, called from `tick_remote` after the entities) fills it. The per-mob work is `body()` + `layers()`, the facts, and one `Rules::select` per rule file, once a second per mob. - `render_visible`'s only change: the body's and each layer's atlas lookup first asks `mobs::random_textures::texture`, which does two hash lookups and a scan of a short vec. The texture keeps its own name for the rest of the code (horse markings' translucency, villager hats). A variant the atlas lacks falls back to the texture. **EMF seam:** #5659 replaces a layer's texture name with its `.jem`'s `texture` before drawing. This lookup runs on whatever name is drawn, so a custom model's texture gets variants too if the pack ships them. The two changes touch neighbouring lines in `render_visible`, and whichever lands second rebases. Variants under `optifine/` are in the entity atlas now, which #5659 listed as a gap for its own `.jem` textures there. **Not in this PR (next in the stack):** emissive `_e` overlays, ETF blinking, block entities (chests, beds, shulker boxes), `nbt.*` and ETF's extra conditions (teams, items, ...), which #5710 skips. **Docs I wrote it from** (no mod source read): - OptiFine's `OptiFineDoc/doc/random_entities.properties` - ETF's `RANDOM_GUIDE.md`: updating properties, layers matching the body's variant, villagers choosing their own **Checks:** - `cargo fmt`: clean - CI on my fork (`verify`: fmt, clippy `-D warnings`, `cargo test --workspace`): passed on this branch. Run: https://github.com/some-du6e/horizon/actions/runs/41274781368 - New tests (`mobs::random_textures`), with temp packs and hand-worked picks: - a red sheep picks `sheep3` and its wool `sheep_wool3`, and turns `sheep2` once dyed white - the desert sighting is kept after walking into plains - the wool follows an even choice of the body, falling back to vanilla when its number is missing - seeds from the client's UUID ints, with the unsigned low word - Not run: no live game test. This machine has no `.local/` vanilla data, so I couldn't load a pack and look at mobs; the review-loop's live test step was skipped for that reason. A reviewer with `.local` should drop an `optifine/random/entity/zombie/zombie2.png` into a pack and look at zombies. Stacked on #5716 and #5710; this branch includes their commits until they merge. > [!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:21:10 +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#6471
No description provided.