[PR #6392] [MERGED] OptiFine CIT: enchantment glint layers, chosen per stack #6844

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

📋 Pull Request Information

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

Base: main ← Head: optifine/cit-glint-rules


📝 Commits (10+)

  • bea7d2d OptiFine CIT: items draw their pack's texture or model
  • 608545c OptiFine CIT: worn armour and elytra wear their pack's textures
  • f605856 OptiFine CIT: pack armour and elytra textures with the rest
  • e78f536 Merge branch 'optifine/cit-overlay' into optifine/cit-items
  • 19327fd Merge branch 'optifine/cit-items' into optifine/cit-armor
  • 123bd3f OptiFine CIT: item swap tests keep their files until the sprites are baked
  • 6fb7637 Merge branch 'optifine/cit-overlay' into optifine/cit-items
  • d4080d5 Merge branch 'optifine/cit-items' into optifine/cit-armor
  • bc1f509 Merge branch 'optifine/cit-overlay' into optifine/cit-items
  • a7d1142 Merge branch 'optifine/cit-items' into optifine/cit-armor

📊 Changes

17 files changed (+2473 additions, -77 deletions)

View changed files

📝 crates/horizon-assets/src/resolve.rs (+39 -0)
📝 crates/horizon-client-render/src/cit.rs (+165 -19)
➕ crates/horizon-client-render/src/cit_armor.rs (+319 -0)
📝 crates/horizon-client-render/src/cit_assets.rs (+184 -6)
➕ crates/horizon-client-render/src/cit_glint.rs (+386 -0)
📝 crates/horizon-client-render/src/hud.rs (+39 -9)
📝 crates/horizon-client-render/src/lib.rs (+2 -0)
📝 crates/horizon-client/src/client_lib.rs (+8 -8)
📝 crates/horizon-client/src/game.rs (+6 -1)
📝 crates/horizon-client/src/game/armor_stands.rs (+36 -11)
📝 crates/horizon-client/src/game/item_draw.rs (+25 -1)
📝 crates/horizon-client/src/game/mob_blocks.rs (+6 -1)
📝 crates/horizon-client/src/game/perspective.rs (+11 -7)
📝 crates/horizon-client/src/item_render.rs (+43 -13)
➕ crates/horizon-client/src/item_render/cit.rs (+797 -0)
📝 crates/horizon-optifine/src/cit.rs (+405 -0)
📝 docs/resource-packs.md (+2 -1)

📄 Description

OptiFine and CIT Resewn packs replace the purple enchantment glint with their own layers (type=enchantment): a flame swirl on Fire Aspect swords, several scrolling layers blended together. A pack's cit.properties sets how layers share an item (method, cap, fade) and whether vanilla's glint still draws (useGlint). This PR reads those rules and decides, per stack, which layers draw and how strongly. The next PR draws them. Players see no change from this PR alone.

This PR builds on #6358 (and the PRs under it). GitHub shows their commits too. This PR's own changes are the glint half of horizon-optifine/src/cit.rs, cit_glint.rs (new), and CitRules::glint in cit.rs.

What it adds:

  • Parsing (horizon-optifine):
    • layer, blend, speed, rotation, duration, r/g/b/a, useGlint and blur, read for type=enchantment rules only (a stray glint key never drops an item or armour rule). NaN and infinity are malformed. An enchantment rule without a texture is dropped, as in CIT Resewn.
    • blend is a named method (add, alpha, glint, subtract, multiply, dodge, burn, screen, overlay, replace) or two or four GL factors, given by name or number, as CIT Resewn reads them.
    • The pack's cit.properties gives method (average, layered, cycle, and CIT Resewn's none), cap, fade and useGlint. It is the first that exists of CIT Resewn's and OptiFine's places, as both docs say (CIT Resewn's code merges their keys instead).
  • Selection (cit_glint.rs, CitRules::glint(stack, hand, max_damage, foil)), cached per stack and hand like the other lookups. Only stacks that draw a glint get layers: the caller passes ItemStack::has_foil, so enchantment_glint_override counts, and hand= applies to glints too (GUI items count as the main hand):
    • Layers: one rule per layer (the highest-priority one), in ascending layer order. cap keeps the topmost layers, as OptiFine's doc says, for average, layered and none.
    • average / layered: a layer's strength is its enchantment's level over the sum (or the max) of the stack's levels. The level is the highest of the rule's named enchantments that also passes its enchantmentLevels. A rule without an enchantment condition is at full strength, and so is every layer under none.
    • cycle: one layer at a time, each for its duration, fading over fade. It is a pure function of time and allocates nothing.
    • Vanilla glint: useGlint=false in cit.properties removes it everywhere. A drawn layer's useGlint=true keeps it under the layers; it is decided after cap, so cap=0 leaves vanilla's glint only if the pack allows it.
    • Without enchantment rules, glint is None and nothing changes.

Choices where the sources differ:

  • cap keeps the topmost layers and doesn't cap cycle (OptiFine's doc; CIT Resewn keeps the bottom ones).
  • When a rule names several enchantments the stack has, the highest level its enchantmentLevels allows counts (CIT Resewn takes whichever its set yields first).
  • duration defaults to 1 second (OptiFine's doc and CIT Resewn's code). blur defaults to true (CIT Resewn's code; its wiki says false).

Tests: parsing (all ten named blends against literal factors, custom factors, defaults, clamping, case, non-finite values, glint keys ignored on other rule types), cit.properties (which file wins, method=none, a Latin-1 file), and selection with hand-computed answers: per-layer winner, ordering, cap, average and layered strengths, the level enchantmentLevels allows, hand=off layers, cycle timing and fades (strengths sum to 1 at every sampled time, duration=0), and the useGlint rules around cap; only stacks with a glint get layers (override on and off, never answered from the cache); an enchantment rule without a texture is dropped; cap under method=none. The rule and cit.properties readers share one read_properties.

Docs used: OptiFine's cit.properties and cit_single.properties ("Enchantments"); CIT Resewn's wiki (CIT Enchantment, Global Properties); and CIT Resewn's MIT source (TypeEnchantment, GlobalProperties, Loops.statelessFadingLoop, LICENSE checked), for the strength formulas and the cycle fade. No OptiFine code was read.

Checks:

  • cargo fmt
  • cargo test -p horizon-optifine locally (it is small)
  • Fork CI (verify job: workspace clippy -D warnings and every test) on the current head: https://github.com/some-du6e/horizon/actions/runs/41350345916 passed
  • Nothing else was built locally: the machine is shared.
  • The live game test was skipped: nothing draws these yet, and there is no vanilla data (.local/) here.

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/6392 **Author:** [@some-du6e](https://github.com/some-du6e) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `optifine/cit-glint-rules` --- ### 📝 Commits (10+) - [`bea7d2d`](https://github.com/horizon-rust/horizon/commit/bea7d2d0fb614afb81cf29e7c93b3ec521d379a0) OptiFine CIT: items draw their pack's texture or model - [`608545c`](https://github.com/horizon-rust/horizon/commit/608545c23e3a3e891bb26638dc86bc967b1da66d) OptiFine CIT: worn armour and elytra wear their pack's textures - [`f605856`](https://github.com/horizon-rust/horizon/commit/f6058569cb45f1e8ae8d450c4a9fc7dafecb8dec) OptiFine CIT: pack armour and elytra textures with the rest - [`e78f536`](https://github.com/horizon-rust/horizon/commit/e78f5366c7beb213a0debd369c39a6768c6bae9f) Merge branch 'optifine/cit-overlay' into optifine/cit-items - [`19327fd`](https://github.com/horizon-rust/horizon/commit/19327fd08f85fccaedff4758797a4a5307860c50) Merge branch 'optifine/cit-items' into optifine/cit-armor - [`123bd3f`](https://github.com/horizon-rust/horizon/commit/123bd3ff7a01b5c4d75f54e9ed335fdb155f078d) OptiFine CIT: item swap tests keep their files until the sprites are baked - [`6fb7637`](https://github.com/horizon-rust/horizon/commit/6fb7637cf1cabf64f4ea75ea064b23f893c3513f) Merge branch 'optifine/cit-overlay' into optifine/cit-items - [`d4080d5`](https://github.com/horizon-rust/horizon/commit/d4080d5d7fc69f262c71d7f780f7e8413c57abfc) Merge branch 'optifine/cit-items' into optifine/cit-armor - [`bc1f509`](https://github.com/horizon-rust/horizon/commit/bc1f50970fa2a6f7d70fd80fcedcb2f277f1aa6f) Merge branch 'optifine/cit-overlay' into optifine/cit-items - [`a7d1142`](https://github.com/horizon-rust/horizon/commit/a7d11428c2e248e5f458c204941c2911523fcf9d) Merge branch 'optifine/cit-items' into optifine/cit-armor ### 📊 Changes **17 files changed** (+2473 additions, -77 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-assets/src/resolve.rs` (+39 -0) 📝 `crates/horizon-client-render/src/cit.rs` (+165 -19) ➕ `crates/horizon-client-render/src/cit_armor.rs` (+319 -0) 📝 `crates/horizon-client-render/src/cit_assets.rs` (+184 -6) ➕ `crates/horizon-client-render/src/cit_glint.rs` (+386 -0) 📝 `crates/horizon-client-render/src/hud.rs` (+39 -9) 📝 `crates/horizon-client-render/src/lib.rs` (+2 -0) 📝 `crates/horizon-client/src/client_lib.rs` (+8 -8) 📝 `crates/horizon-client/src/game.rs` (+6 -1) 📝 `crates/horizon-client/src/game/armor_stands.rs` (+36 -11) 📝 `crates/horizon-client/src/game/item_draw.rs` (+25 -1) 📝 `crates/horizon-client/src/game/mob_blocks.rs` (+6 -1) 📝 `crates/horizon-client/src/game/perspective.rs` (+11 -7) 📝 `crates/horizon-client/src/item_render.rs` (+43 -13) ➕ `crates/horizon-client/src/item_render/cit.rs` (+797 -0) 📝 `crates/horizon-optifine/src/cit.rs` (+405 -0) 📝 `docs/resource-packs.md` (+2 -1) </details> ### 📄 Description OptiFine and CIT Resewn packs replace the purple enchantment glint with their own layers (`type=enchantment`): a flame swirl on Fire Aspect swords, several scrolling layers blended together. A pack's `cit.properties` sets how layers share an item (`method`, `cap`, `fade`) and whether vanilla's glint still draws (`useGlint`). This PR reads those rules and decides, per stack, which layers draw and how strongly. The next PR draws them. Players see no change from this PR alone. **This PR builds on #6358** (and the PRs under it). GitHub shows their commits too. This PR's own changes are the glint half of `horizon-optifine/src/cit.rs`, `cit_glint.rs` (new), and `CitRules::glint` in `cit.rs`. What it adds: - **Parsing** (`horizon-optifine`): - `layer`, `blend`, `speed`, `rotation`, `duration`, `r`/`g`/`b`/`a`, `useGlint` and `blur`, read for `type=enchantment` rules only (a stray glint key never drops an item or armour rule). NaN and infinity are malformed. An enchantment rule without a texture is dropped, as in CIT Resewn. - `blend` is a named method (`add`, `alpha`, `glint`, `subtract`, `multiply`, `dodge`, `burn`, `screen`, `overlay`, `replace`) or two or four GL factors, given by name or number, as CIT Resewn reads them. - The pack's `cit.properties` gives `method` (`average`, `layered`, `cycle`, and CIT Resewn's `none`), `cap`, `fade` and `useGlint`. It is the first that exists of CIT Resewn's and OptiFine's places, as both docs say (CIT Resewn's code merges their keys instead). - **Selection** (`cit_glint.rs`, `CitRules::glint(stack, hand, max_damage, foil)`), cached per stack and hand like the other lookups. Only stacks that draw a glint get layers: the caller passes `ItemStack::has_foil`, so `enchantment_glint_override` counts, and `hand=` applies to glints too (GUI items count as the main hand): - **Layers:** one rule per `layer` (the highest-priority one), in ascending layer order. `cap` keeps the topmost layers, as OptiFine's doc says, for `average`, `layered` and `none`. - **`average` / `layered`:** a layer's strength is its enchantment's level over the sum (or the max) of the stack's levels. The level is the highest of the rule's named enchantments that also passes its `enchantmentLevels`. A rule without an enchantment condition is at full strength, and so is every layer under `none`. - **`cycle`:** one layer at a time, each for its `duration`, fading over `fade`. It is a pure function of time and allocates nothing. - **Vanilla glint:** `useGlint=false` in `cit.properties` removes it everywhere. A drawn layer's `useGlint=true` keeps it under the layers; it is decided after `cap`, so `cap=0` leaves vanilla's glint only if the pack allows it. - Without enchantment rules, `glint` is `None` and nothing changes. **Choices where the sources differ:** - `cap` keeps the topmost layers and doesn't cap `cycle` (OptiFine's doc; CIT Resewn keeps the bottom ones). - When a rule names several enchantments the stack has, the highest level its `enchantmentLevels` allows counts (CIT Resewn takes whichever its set yields first). - `duration` defaults to 1 second (OptiFine's doc and CIT Resewn's code). `blur` defaults to true (CIT Resewn's code; its wiki says false). **Tests:** parsing (all ten named blends against literal factors, custom factors, defaults, clamping, case, non-finite values, glint keys ignored on other rule types), `cit.properties` (which file wins, `method=none`, a Latin-1 file), and selection with hand-computed answers: per-layer winner, ordering, cap, average and layered strengths, the level `enchantmentLevels` allows, `hand=off` layers, cycle timing and fades (strengths sum to 1 at every sampled time, `duration=0`), and the `useGlint` rules around `cap`; only stacks with a glint get layers (override on and off, never answered from the cache); an enchantment rule without a texture is dropped; `cap` under `method=none`. The rule and `cit.properties` readers share one `read_properties`. **Docs used:** OptiFine's `cit.properties` and `cit_single.properties` ("Enchantments"); CIT Resewn's wiki (CIT Enchantment, Global Properties); and CIT Resewn's MIT source (`TypeEnchantment`, `GlobalProperties`, `Loops.statelessFadingLoop`, LICENSE checked), for the strength formulas and the cycle fade. No OptiFine code was read. **Checks:** - `cargo fmt` - `cargo test -p horizon-optifine` locally (it is small) - Fork CI (`verify` job: workspace clippy `-D warnings` and every test) on the current head: https://github.com/some-du6e/horizon/actions/runs/41350345916 passed - Nothing else was built locally: the machine is shared. - The live game test was skipped: nothing draws these yet, and there is no vanilla data (`.local/`) here. > [!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:27:53 +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#6844
No description provided.