[PR #5718] [MERGED] OptiFine packs: shared connected-texture tile geometry #6460

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

📋 Pull Request Information

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

Base: main ← Head: optifine/ctm-connect


📝 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

25 files changed (+3960 additions, -38 deletions)

View changed files

📝 Cargo.lock (+2 -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/Cargo.toml (+2 -1)
➕ crates/horizon-optifine/src/ctm.rs (+877 -0)
➕ crates/horizon-optifine/src/ctm/connect.rs (+571 -0)

...and 5 more files

📄 Description

Connected textures need one shared piece of geometry: given which neighbours of a face join it, which tile does each method draw? This PR adds that as pure functions, with no game types, so both the OptiFine reader (#5711) and other connected-texture formats (Fusion's, coming later) can use the same tables instead of each copying the templates.

Depends on #5711 (its commits are at the bottom of this branch). Review only ctm/connect.rs (the commits after #5711's).

horizon_optifine::ctm::connect (in crates/horizon-optifine/src/ctm/connect.rs) has:

  • Axes: where a face's texture points (right and up) in the world. Axes::cube follows vanilla's default cube UVs; Axes::column follows a cube column turned by axis, the way vanilla's blockstates turn one (OptiFine's horizontal/vertical methods, Continuity's orient=state_axis).
  • neighbours: an 8-bit mask of the neighbours that join, from a joins(offset) callback the mesher answers from its own neighbour access. With innerSeams, a neighbour whose face is covered doesn't count, so inner corners get a seam.
  • Tile tables read off OptiFine's template images: ctm_index (47 tiles, a 256-entry table built at compile time), compact_quarters (ctm_compact's 5 tiles per quarter), horizontal, vertical, horizontal_vertical, vertical_horizontal (7 tiles) and overlay_tiles (17 tiles; facing sides take two tiles, since the template has none for them).
  • repeat_index (the place in a width x height pattern along the face) and random_index (a fixed, weighted pick per block position and face, with randomLoops), plus symmetric_face for symmetry.

The random pick uses a fixed integer hash, so a world looks the same every load. It's not OptiFine's own random sequence, which isn't documented, so random tiles land in different places than in OptiFine, with the same weights.

For the Fusion thread: build the mask with connect::neighbours and read tiles with the functions above. If Fusion's layouts number their tiles differently, add a table next to these rather than a second neighbour walker.

Next in the stack: tiles loaded into the block textures, the mesher seam (a per-block-state rule list built at load), and ctm/ctm_compact drawn in the world.

Docs used: OptiFine's OptiFineDoc/doc/ctm.properties, and the template images ctm_template.png, ctm_compact_template.png, horizontal_template.png, vertical_template.png and overlay_template.png (I read each tile's borders and corner marks off the images). Continuity's wiki page "Continuity Connected Textures Specification" (the orient section). No mod source was read.

Checks: cargo fmt; cargo test -p horizon-optifine --lib connect (10 tests, all pass). Clippy and the full suite run on CI, not on this machine: fork run https://github.com/some-du6e/horizon/actions/runs/41273150624. There's no live game test: this machine has no vanilla data (.local/), and nothing draws these tiles yet.

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/5718 **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-connect` --- ### 📝 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 **25 files changed** (+3960 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+2 -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/Cargo.toml` (+2 -1) ➕ `crates/horizon-optifine/src/ctm.rs` (+877 -0) ➕ `crates/horizon-optifine/src/ctm/connect.rs` (+571 -0) _...and 5 more files_ </details> ### 📄 Description Connected textures need one shared piece of geometry: given which neighbours of a face join it, which tile does each method draw? This PR adds that as pure functions, with no game types, so both the OptiFine reader (#5711) and other connected-texture formats (Fusion's, coming later) can use the same tables instead of each copying the templates. **Depends on #5711** (its commits are at the bottom of this branch). Review only `ctm/connect.rs` (the commits after #5711's). `horizon_optifine::ctm::connect` (in `crates/horizon-optifine/src/ctm/connect.rs`) has: - `Axes`: where a face's texture points (right and up) in the world. `Axes::cube` follows vanilla's default cube UVs; `Axes::column` follows a cube column turned by `axis`, the way vanilla's blockstates turn one (OptiFine's horizontal/vertical methods, Continuity's `orient=state_axis`). - `neighbours`: an 8-bit mask of the neighbours that join, from a `joins(offset)` callback the mesher answers from its own neighbour access. With `innerSeams`, a neighbour whose face is covered doesn't count, so inner corners get a seam. - Tile tables read off OptiFine's template images: `ctm_index` (47 tiles, a 256-entry table built at compile time), `compact_quarters` (`ctm_compact`'s 5 tiles per quarter), `horizontal`, `vertical`, `horizontal_vertical`, `vertical_horizontal` (7 tiles) and `overlay_tiles` (17 tiles; facing sides take two tiles, since the template has none for them). - `repeat_index` (the place in a `width` x `height` pattern along the face) and `random_index` (a fixed, weighted pick per block position and face, with `randomLoops`), plus `symmetric_face` for `symmetry`. The random pick uses a fixed integer hash, so a world looks the same every load. It's not OptiFine's own random sequence, which isn't documented, so random tiles land in different places than in OptiFine, with the same weights. **For the Fusion thread:** build the mask with `connect::neighbours` and read tiles with the functions above. If Fusion's layouts number their tiles differently, add a table next to these rather than a second neighbour walker. Next in the stack: tiles loaded into the block textures, the mesher seam (a per-block-state rule list built at load), and `ctm`/`ctm_compact` drawn in the world. **Docs used:** OptiFine's `OptiFineDoc/doc/ctm.properties`, and the template images `ctm_template.png`, `ctm_compact_template.png`, `horizontal_template.png`, `vertical_template.png` and `overlay_template.png` (I read each tile's borders and corner marks off the images). Continuity's wiki page "Continuity Connected Textures Specification" (the `orient` section). No mod source was read. **Checks:** `cargo fmt`; `cargo test -p horizon-optifine --lib connect` (10 tests, all pass). Clippy and the full suite run on CI, not on this machine: fork run https://github.com/some-du6e/horizon/actions/runs/41273150624. There's no live game test: this machine has no vanilla data (`.local/`), and nothing draws these tiles yet. > [!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:01 +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#6460
No description provided.