[PR #5746] [MERGED] OptiFine packs: connected-texture tiles load with the packs, and each block face picks one #6473

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

📋 Pull Request Information

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

Base: main ← Head: optifine/ctm-mesh


📝 Commits (10+)

  • a6fcdfa OptiFine CEM: custom entity models animate
  • 6049010 OptiFine random entities: read the rules that pick an entity's texture variant
  • f51a81b OptiFine packs: read connected-texture rules (optifine/ctm)
  • 943b1c7 OptiFine CTM rules: bound tile ranges, reject bad names, read Latin-1
  • ffb010b OptiFine random entities: a rule with a bad or unsupported condition never matches
  • c76b2a2 OptiFine CTM rules: close the tile cap, refuse backslashes and bad heights
  • 9375dab OptiFine random entities: nbt list paths, seedSource and exact health percent
  • 7a2b81f OptiFine CTM rules: one bound on tile ranges
  • b916c9a OptiFine CTM rules: assets/minecraft/ tiles stay in minecraft
  • a8a1d74 OptiFine random entities: biome patterns, and empty conditions skip the rule

📊 Changes

29 files changed (+4761 additions, -42 deletions)

View changed files

📝 Cargo.lock (+2 -0)
📝 crates/horizon-client-render/Cargo.toml (+1 -0)
📝 crates/horizon-client-render/src/assets.rs (+30 -2)
➕ crates/horizon-client-render/src/connected.rs (+724 -0)
📝 crates/horizon-client-render/src/hud.rs (+37 -7)
📝 crates/horizon-client-render/src/lib.rs (+1 -0)
📝 crates/horizon-client-render/src/sprites.rs (+45 -2)
📝 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)

...and 9 more files

📄 Description

With #5711 and #5718, Horizon can read OptiFine connected-texture rules and work out which tile each method picks, but nothing reaches the game yet. This PR loads the rules with the resource packs, puts their tiles into the block textures, and decides for each block face which tile it gets. The mesher doesn't use the decision yet; the next PR draws it.

Depends on #5711 and #5718 (their commits are at the bottom of this branch). Review only the commits after them: connected.rs, Sprites::insert_file and the hook in assets.rs.

What it does:

  • RenderAssets::load reads optifine/ctm rules from the overlay root (only when drawing, not for a server). Every tile becomes a sprite layer. A tile under textures/ reuses that sprite; any other tile goes through the new Sprites::insert_file, which reads a PNG at a resource path. These tiles skip the sprite disk cache, since its fingerprint only covers textures/. If a tile is missing, its rule is dropped with a warning, so the block looks vanilla rather than magenta.
  • ConnectedTextures builds, once per load, the ordered rule list for every block state (block rules, indexed by block name so each state only tests its own) and for every sprite layer (tile rules). pick merges the two short lists for a face. A rule naming both blocks and tiles needs both.
  • Methods: ctm, ctm_compact (quarters, and the ctm.N replacements), horizontal, vertical, horizontal+vertical, vertical+horizontal, top, random (weights, randomLoops, symmetry, linked following a door's or double plant's lower half), repeat and fixed. Also faces, heights, biomes, connect=block|state|tile, innerSeams, and the axis of logs for the horizontal/vertical methods (OptiFine's behaviour). <skip> moves on to the next rule; <default> keeps the face's own sprite and stops.
  • Without CTM files, load returns an empty table before touching any sprite, and the mesher's check is a single is_empty().

Not yet: overlays (two PRs on), name= (section meshes see no block entity, so those rules aren't loaded), tiles produced by one rule being matched again by another, and orient=texture (treated as the cube's own directions).

Docs used: OptiFine's OptiFineDoc/doc/ctm.properties and its template images, and Continuity's wiki page "Continuity Connected Textures Specification". No mod source was read.

Checks: cargo fmt. The new tests (connected.rs, 11 tests; sprites.rs files_outside_textures_load_by_path) build synthetic rules and block states and check the chosen tile against hand-worked answers. Fork CI: https://github.com/some-du6e/horizon/actions/runs/41275653130 (fmt and workspace clippy pass; tests running when this was opened). Nothing was built on this machine. There's no live game test: this machine has no vanilla data (.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/5746 **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/ctm-mesh` --- ### 📝 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 - [`f51a81b`](https://github.com/horizon-rust/horizon/commit/f51a81bbed5b82e1f62a9c3420baa316e4415447) OptiFine packs: read connected-texture rules (optifine/ctm) - [`943b1c7`](https://github.com/horizon-rust/horizon/commit/943b1c7bc136e90a8d9e5c27813b4af23501617e) OptiFine CTM rules: bound tile ranges, reject bad names, read Latin-1 - [`ffb010b`](https://github.com/horizon-rust/horizon/commit/ffb010b543d40f072a95eb9a5e1f41945df4a60e) OptiFine random entities: a rule with a bad or unsupported condition never matches - [`c76b2a2`](https://github.com/horizon-rust/horizon/commit/c76b2a249a8ed398738c7f7001629fd88272f43c) OptiFine CTM rules: close the tile cap, refuse backslashes and bad heights - [`9375dab`](https://github.com/horizon-rust/horizon/commit/9375dab6328006ec380095908d58f5f4d9d09f11) OptiFine random entities: nbt list paths, seedSource and exact health percent - [`7a2b81f`](https://github.com/horizon-rust/horizon/commit/7a2b81f86f7f7fd1d9f810371df1991e191c097e) OptiFine CTM rules: one bound on tile ranges - [`b916c9a`](https://github.com/horizon-rust/horizon/commit/b916c9a224e5cce013c9a7ab322468a2f672bf73) OptiFine CTM rules: assets/minecraft/ tiles stay in minecraft - [`a8a1d74`](https://github.com/horizon-rust/horizon/commit/a8a1d74d1573cbf91f91ad58abbf19ffe8ea08df) OptiFine random entities: biome patterns, and empty conditions skip the rule ### 📊 Changes **29 files changed** (+4761 additions, -42 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+2 -0) 📝 `crates/horizon-client-render/Cargo.toml` (+1 -0) 📝 `crates/horizon-client-render/src/assets.rs` (+30 -2) ➕ `crates/horizon-client-render/src/connected.rs` (+724 -0) 📝 `crates/horizon-client-render/src/hud.rs` (+37 -7) 📝 `crates/horizon-client-render/src/lib.rs` (+1 -0) 📝 `crates/horizon-client-render/src/sprites.rs` (+45 -2) 📝 `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) _...and 9 more files_ </details> ### 📄 Description With #5711 and #5718, Horizon can read OptiFine connected-texture rules and work out which tile each method picks, but nothing reaches the game yet. This PR loads the rules with the resource packs, puts their tiles into the block textures, and decides for each block face which tile it gets. The mesher doesn't use the decision yet; the next PR draws it. **Depends on #5711 and #5718** (their commits are at the bottom of this branch). Review only the commits after them: `connected.rs`, `Sprites::insert_file` and the hook in `assets.rs`. What it does: - `RenderAssets::load` reads `optifine/ctm` rules from the overlay root (only when drawing, not for a server). Every tile becomes a sprite layer. A tile under `textures/` reuses that sprite; any other tile goes through the new `Sprites::insert_file`, which reads a PNG at a resource path. These tiles skip the sprite disk cache, since its fingerprint only covers `textures/`. If a tile is missing, its rule is dropped with a warning, so the block looks vanilla rather than magenta. - `ConnectedTextures` builds, once per load, the ordered rule list for every block state (block rules, indexed by block name so each state only tests its own) and for every sprite layer (tile rules). `pick` merges the two short lists for a face. A rule naming both blocks and tiles needs both. - Methods: `ctm`, `ctm_compact` (quarters, and the `ctm.N` replacements), `horizontal`, `vertical`, `horizontal+vertical`, `vertical+horizontal`, `top`, `random` (`weights`, `randomLoops`, `symmetry`, `linked` following a door's or double plant's lower half), `repeat` and `fixed`. Also `faces`, `heights`, `biomes`, `connect=block|state|tile`, `innerSeams`, and the `axis` of logs for the horizontal/vertical methods (OptiFine's behaviour). `<skip>` moves on to the next rule; `<default>` keeps the face's own sprite and stops. - Without CTM files, `load` returns an empty table before touching any sprite, and the mesher's check is a single `is_empty()`. Not yet: overlays (two PRs on), `name=` (section meshes see no block entity, so those rules aren't loaded), tiles produced by one rule being matched again by another, and `orient=texture` (treated as the cube's own directions). **Docs used:** OptiFine's `OptiFineDoc/doc/ctm.properties` and its template images, and Continuity's wiki page "Continuity Connected Textures Specification". No mod source was read. **Checks:** `cargo fmt`. The new tests (`connected.rs`, 11 tests; `sprites.rs` `files_outside_textures_load_by_path`) build synthetic rules and block states and check the chosen tile against hand-worked answers. Fork CI: https://github.com/some-du6e/horizon/actions/runs/41275653130 (fmt and workspace clippy pass; tests running when this was opened). Nothing was built on this machine. There's no live game test: this machine has no vanilla data (`.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:21:14 +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#6473
No description provided.