[PR #5711] [MERGED] OptiFine packs: read connected-texture rules (optifine/ctm) #6454

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

📋 Pull Request Information

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

Base: main ← Head: optifine/ctm-rules


📝 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

24 files changed (+3386 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 (+874 -0)
📝 crates/horizon-optifine/src/lib.rs (+8 -2)

...and 4 more files

📄 Description

Packs made for OptiFine or Continuity ship connected textures (glass that joins into one pane, bookshelves that line up, random stone and so on) as optifine/ctm/**/*.properties files. Horizon ignores them, so those packs look flat. This is the first step of supporting them: reading the rules. Nothing renders differently yet.

horizon_optifine::ctm turns every CTM file into a Rule, in the order OptiFine tries them:

  • every method (ctm, ctm_compact, horizontal, vertical, horizontal+vertical, vertical+horizontal, top, random, repeat, fixed and the five overlay* methods, plus MCPatcher's old names and Continuity's four extra overlay methods), with the tile count each one needs. A file with the wrong count is logged and skipped.
  • matchTiles and matchBlocks, or what the file name implies when both are missing (block_<name>.properties and <name>.properties).
  • tiles: numbers, ranges (in either direction), names, paths, ~/, a leading /, assets/minecraft/, <skip>, <default>, and Continuity's namespaced sprite locations (ns:x is ns:textures/block/x, ns:a/b is ns:textures/a/b). Every tile path passes the same check as paths::resolve (now shared as paths::in_root, which also refuses \), so a tile can't point outside the resource root. A file with a refused tile, more than 4096 tiles, or the wrong count for its method is logged and skipped. Files that aren't UTF-8 are read as ISO-8859-1, as Java reads them.
  • faces, biomes, heights (plus the legacy minHeight/maxHeight and Continuity's a..b), name, weight, connect (defaults to block for block rules, tile for tile rules), connectTiles, connectBlocks, innerSeams, weights, randomLoops, symmetry, linked, width/height, ctm.N, tintIndex, tintBlock, layer.
  • Continuity's orient (with OptiFine's own behaviour as the default: fixed face directions for ctm, the block's axis for the horizontal/vertical methods), prioritize and optifineOnly.
  • Ordering: tile rules first, then the highest weight, then the path.

metadata is read by nothing: it holds legacy numeric data values, which name no block since 1.13.

The crate now depends on log, so it can report the files it skips.

Next in the stack: the connection geometry (the 47-tile, compact, horizontal/vertical, overlay, repeat and random tile choice) as shared helpers, then the mesher seam and the tiles in the block textures.

Docs used: OptiFine's OptiFineDoc/doc/ctm.properties and its template images (ctm_template.png, ctm_compact_template.png, horizontal_template.png, vertical_template.png, overlay_template.png), and Continuity's wiki page "Continuity Connected Textures Specification". No mod source was read.

Checks: cargo fmt; cargo test -p horizon-optifine --lib (20 tests, 11 of them new, all pass). Clippy and the full suite run on CI, not on this machine: the fork's verify job (fmt, workspace clippy -D warnings, tests) passed on the first commit (https://github.com/some-du6e/horizon/actions/runs/41271544150); the run for the head commit is https://github.com/some-du6e/horizon/actions/runs/41272889613. Reviewed in 5 rounds of fresh agent reviewers; their fixes are the later commits. There's no live game test: this machine has no vanilla data (.local/), and nothing here renders 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/5711 **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-rules` --- ### 📝 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 **24 files changed** (+3386 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` (+874 -0) 📝 `crates/horizon-optifine/src/lib.rs` (+8 -2) _...and 4 more files_ </details> ### 📄 Description Packs made for OptiFine or Continuity ship connected textures (glass that joins into one pane, bookshelves that line up, random stone and so on) as `optifine/ctm/**/*.properties` files. Horizon ignores them, so those packs look flat. This is the first step of supporting them: reading the rules. Nothing renders differently yet. `horizon_optifine::ctm` turns every CTM file into a `Rule`, in the order OptiFine tries them: - every method (`ctm`, `ctm_compact`, `horizontal`, `vertical`, `horizontal+vertical`, `vertical+horizontal`, `top`, `random`, `repeat`, `fixed` and the five `overlay*` methods, plus MCPatcher's old names and Continuity's four extra overlay methods), with the tile count each one needs. A file with the wrong count is logged and skipped. - `matchTiles` and `matchBlocks`, or what the file name implies when both are missing (`block_<name>.properties` and `<name>.properties`). - `tiles`: numbers, ranges (in either direction), names, paths, `~/`, a leading `/`, `assets/minecraft/`, `<skip>`, `<default>`, and Continuity's namespaced sprite locations (`ns:x` is `ns:textures/block/x`, `ns:a/b` is `ns:textures/a/b`). Every tile path passes the same check as `paths::resolve` (now shared as `paths::in_root`, which also refuses `\`), so a tile can't point outside the resource root. A file with a refused tile, more than 4096 tiles, or the wrong count for its method is logged and skipped. Files that aren't UTF-8 are read as ISO-8859-1, as Java reads them. - `faces`, `biomes`, `heights` (plus the legacy `minHeight`/`maxHeight` and Continuity's `a..b`), `name`, `weight`, `connect` (defaults to block for block rules, tile for tile rules), `connectTiles`, `connectBlocks`, `innerSeams`, `weights`, `randomLoops`, `symmetry`, `linked`, `width`/`height`, `ctm.N`, `tintIndex`, `tintBlock`, `layer`. - Continuity's `orient` (with OptiFine's own behaviour as the default: fixed face directions for `ctm`, the block's `axis` for the horizontal/vertical methods), `prioritize` and `optifineOnly`. - Ordering: tile rules first, then the highest `weight`, then the path. `metadata` is read by nothing: it holds legacy numeric data values, which name no block since 1.13. The crate now depends on `log`, so it can report the files it skips. Next in the stack: the connection geometry (the 47-tile, compact, horizontal/vertical, overlay, repeat and random tile choice) as shared helpers, then the mesher seam and the tiles in the block textures. **Docs used:** OptiFine's `OptiFineDoc/doc/ctm.properties` and its template images (`ctm_template.png`, `ctm_compact_template.png`, `horizontal_template.png`, `vertical_template.png`, `overlay_template.png`), and Continuity's wiki page "Continuity Connected Textures Specification". No mod source was read. **Checks:** `cargo fmt`; `cargo test -p horizon-optifine --lib` (20 tests, 11 of them new, all pass). Clippy and the full suite run on CI, not on this machine: the fork's `verify` job (fmt, workspace clippy `-D warnings`, tests) passed on the first commit (https://github.com/some-du6e/horizon/actions/runs/41271544150); the run for the head commit is https://github.com/some-du6e/horizon/actions/runs/41272889613. Reviewed in 5 rounds of fresh agent reviewers; their fixes are the later commits. There's no live game test: this machine has no vanilla data (`.local/`), and nothing here renders 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:20:55 +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#6454
No description provided.