[PR #6334] [MERGED] OptiFine CIT: items draw their pack's texture or model #6803

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

📋 Pull Request Information

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

Base: main ← Head: optifine/cit-items


📝 Commits (10+)

  • bea7d2d OptiFine CIT: items draw their pack's texture or model
  • e78f536 Merge branch 'optifine/cit-overlay' into optifine/cit-items
  • 123bd3f OptiFine CIT: item swap tests keep their files until the sprites are baked
  • 6fb7637 Merge branch 'optifine/cit-overlay' into optifine/cit-items
  • bc1f509 Merge branch 'optifine/cit-overlay' into optifine/cit-items
  • bcbffc7 Merge branch 'optifine/cit-overlay' into optifine/cit-items
  • 382c9e7 OptiFine CIT: texture. on the layer it names, OptiFine's old sub-names, broken models stay vanilla; docs row
  • 4d4de49 OptiFine CIT: a plain texture is the whole item; texture. on a layer keeps the rule's model; 26.x names beat old ones
  • 6167381 OptiFine CIT: the generic texture takes the layers no texture. claims; block items take it on every face
  • c19317a OptiFine CIT: layer numbers from the claimed slot names

📊 Changes

9 files changed (+1087 additions, -25 deletions)

View changed files

📝 crates/horizon-assets/src/resolve.rs (+39 -0)
📝 crates/horizon-client-render/src/cit_assets.rs (+176 -3)
📝 crates/horizon-client-render/src/hud.rs (+30 -5)
📝 crates/horizon-client/src/game.rs (+6 -1)
📝 crates/horizon-client/src/game/item_draw.rs (+25 -1)
📝 crates/horizon-client/src/game/mob_blocks.rs (+6 -1)
📝 crates/horizon-client/src/item_render.rs (+43 -13)
➕ crates/horizon-client/src/item_render/cit.rs (+760 -0)
📝 docs/resource-packs.md (+2 -1)

📄 Description

Resource packs made for OptiFine's Custom Item Textures (and CIT Resewn) re-skin items by their name, enchantments, damage or components: a stick named Excalibur that looks like a sword, a bow with its own pulling frames, a potion with its own bottle. Since #5749 Horizon knows which rule a stack matches, and #6232 puts the rules' textures in the atlas, but items still drew their vanilla look. With this PR they draw the pack's texture or model.

This PR builds on #6232 and #6264. GitHub shows their commits too. This PR's own changes are item_render.rs, item_render/cit.rs (new), game/item_draw.rs, the two hand call sites, the model half of cit_assets.rs/hud.rs, ModelLibrary::resolves in horizon-assets (does a model's whole parent chain exist), and a row in docs/resource-packs.md.

What players get:

  • Items whose stack matches a CIT type=item rule draw its texture or model in every place an item is drawn: the GUI and hotbar, held in either hand, dropped, in item frames, on heads, and thrown. The hand is the one the item is in (first person, other players and mobs); the GUI counts as the main hand, as OptiFine says.
  • texture= draws that texture once, untinted, as the item generated from it (keeping its model's transforms). The pack's art carries its own colours, as OptiFine's doc says of potions ("include the colored liquid"), so a potion, a filled map, a firework star or dyed wolf armour shows the pack's picture rather than vanilla's tint over it. It goes on layer0, or on the lowest layer no texture.<name> claims, and the item's other unclaimed layers are dropped. On a block item or a 3D model it goes on every face.
  • texture.<name> / model.<name> replace one model of an item the 26.x item definition picks: texture.bow_pulling_1 swaps only that frame. Or they replace one layer, by slot (texture.layer1) or by the vanilla texture's file name (texture.potion_overlay, and texture.potion for the bottle alone, alongside the rule's model= or texture=). If an old name and its 26.x name are both set, the 26.x one wins. OptiFine's older names work too: bow_standby is the resting bow, and potion_bottle_drinkable/_splash/_lingering are the bottles.
  • A rule whose model doesn't load (bad JSON, a missing or looping parent) leaves the item vanilla instead of drawing the missing model.
  • Tints, glints and special renderers (heads, shields, banners, the in-hand trident) stay as they were: only model layers are swapped. A model= rule on a special renderer is left for a follow-up.
  • Armour stands' off-hand items use the main hand here; the armour PR next in the stack gives them the off hand.
  • Without CIT rules nothing changes. The renderer holds no CIT state and does no lookup (one Option check per draw).

How:

  • ItemRenderer loads the rules and the pack's CIT models once per resource load. The models are overlaid onto the item model library (#6264), and the textures they name are packed with the rest (#6232).
  • resolve_item asks the cached matcher (#5749) for the stack's rule. The LayerContent::Model arm of the item model walk then bakes that rule's version of the leaf model. Bakes are cached per (rule, leaf), with None for leaves a rule leaves alone, so a matched stack costs a hash lookup per layer after the first frame.

Tests (synthetic resource roots, PNGs written by the test, no Mojang files):

  • texture.bow_pulling_1 swaps only that leaf;
  • precedence: model.<leaf>, then texture.<leaf>, then model with texture in every slot;
  • potion layers checked one by one by tint index: texture= alone is one untinted layer; with texture.potion_overlay, the generic texture is the untinted bottle; texture.potion and texture.potion_bottle_drinkable swap only the bottle, also next to texture= or over model=; a block item takes a plain texture= on all 6 faces and as its particle;
  • a 26.x name beats OptiFine's old one in either order, for textures and models;
  • a broken model.<leaf> leaves that leaf vanilla;
  • texture.bow_standby swaps the resting bow;
  • a broken model leaves its leaf vanilla while the rule's good model.<leaf> still draws;
  • the stack's max_damage component wins over the item's;
  • a CIT model's relative texture reaches the atlas;
  • a model alone keeps its relative textures;
  • texture.potion_overlay matches by file name and texture.layer1 by slot;
  • one bake per rule and leaf;
  • a matched stack resolves end to end to the rule's model;
  • with no rules, cit is None and every resolve is identical to before.

Docs used: CIT Resewn's wiki (citresewn.shcm.io: CIT Item, CIT Base "Asset Resolution") and OptiFine's cit_single.properties. Written from those docs; no OptiFine code was read.

Checks:

  • cargo fmt
  • Fork CI (verify: workspace clippy -D warnings and every test): passed on this code (before the last atlas fix came in): https://github.com/some-du6e/horizon/actions/runs/41339955516. On the current head: https://github.com/some-du6e/horizon/actions/runs/41360655422
  • Nothing was built locally: the machine is shared.
  • Known follow-up: the atlas and the item renderer each read the CIT rules and models once per resource load; sharing one read is a later change.
  • The live game test was skipped: there is no vanilla data (.local/) on this machine to launch the game with. Someone with it should try a CIT pack (a renamed sword, a bow with pulling frames, a potion overlay) before merging.

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/6334 **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-items` --- ### 📝 Commits (10+) - [`bea7d2d`](https://github.com/horizon-rust/horizon/commit/bea7d2d0fb614afb81cf29e7c93b3ec521d379a0) OptiFine CIT: items draw their pack's texture or model - [`e78f536`](https://github.com/horizon-rust/horizon/commit/e78f5366c7beb213a0debd369c39a6768c6bae9f) Merge branch 'optifine/cit-overlay' into optifine/cit-items - [`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 - [`bc1f509`](https://github.com/horizon-rust/horizon/commit/bc1f50970fa2a6f7d70fd80fcedcb2f277f1aa6f) Merge branch 'optifine/cit-overlay' into optifine/cit-items - [`bcbffc7`](https://github.com/horizon-rust/horizon/commit/bcbffc7f1681a9327f8ec96a3848d206b80a42cf) Merge branch 'optifine/cit-overlay' into optifine/cit-items - [`382c9e7`](https://github.com/horizon-rust/horizon/commit/382c9e749989dd553ba8651346b5bab7032b0ffe) OptiFine CIT: texture.<name> on the layer it names, OptiFine's old sub-names, broken models stay vanilla; docs row - [`4d4de49`](https://github.com/horizon-rust/horizon/commit/4d4de49de96f83bbc1a72af7cce4a16905e4e4d6) OptiFine CIT: a plain texture is the whole item; texture.<name> on a layer keeps the rule's model; 26.x names beat old ones - [`6167381`](https://github.com/horizon-rust/horizon/commit/616738141a6e433012c2cf590f2f491b73afc55a) OptiFine CIT: the generic texture takes the layers no texture.<name> claims; block items take it on every face - [`c19317a`](https://github.com/horizon-rust/horizon/commit/c19317af2406a6ec3166a7d04d178bdfbb4eabde) OptiFine CIT: layer numbers from the claimed slot names ### 📊 Changes **9 files changed** (+1087 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-assets/src/resolve.rs` (+39 -0) 📝 `crates/horizon-client-render/src/cit_assets.rs` (+176 -3) 📝 `crates/horizon-client-render/src/hud.rs` (+30 -5) 📝 `crates/horizon-client/src/game.rs` (+6 -1) 📝 `crates/horizon-client/src/game/item_draw.rs` (+25 -1) 📝 `crates/horizon-client/src/game/mob_blocks.rs` (+6 -1) 📝 `crates/horizon-client/src/item_render.rs` (+43 -13) ➕ `crates/horizon-client/src/item_render/cit.rs` (+760 -0) 📝 `docs/resource-packs.md` (+2 -1) </details> ### 📄 Description Resource packs made for OptiFine's Custom Item Textures (and CIT Resewn) re-skin items by their name, enchantments, damage or components: a stick named *Excalibur* that looks like a sword, a bow with its own pulling frames, a potion with its own bottle. Since #5749 Horizon knows which rule a stack matches, and #6232 puts the rules' textures in the atlas, but items still drew their vanilla look. With this PR they draw the pack's texture or model. **This PR builds on #6232 and #6264.** GitHub shows their commits too. This PR's own changes are `item_render.rs`, `item_render/cit.rs` (new), `game/item_draw.rs`, the two hand call sites, the model half of `cit_assets.rs`/`hud.rs`, `ModelLibrary::resolves` in `horizon-assets` (does a model's whole parent chain exist), and a row in `docs/resource-packs.md`. What players get: - Items whose stack matches a CIT `type=item` rule draw its texture or model in every place an item is drawn: the GUI and hotbar, held in either hand, dropped, in item frames, on heads, and thrown. The hand is the one the item is in (first person, other players and mobs); the GUI counts as the main hand, as OptiFine says. - `texture=` draws that texture once, untinted, as the item generated from it (keeping its model's transforms). The pack's art carries its own colours, as OptiFine's doc says of potions ("include the colored liquid"), so a potion, a filled map, a firework star or dyed wolf armour shows the pack's picture rather than vanilla's tint over it. It goes on `layer0`, or on the lowest layer no `texture.<name>` claims, and the item's other unclaimed layers are dropped. On a block item or a 3D model it goes on every face. - `texture.<name>` / `model.<name>` replace one model of an item the 26.x item definition picks: `texture.bow_pulling_1` swaps only that frame. Or they replace one layer, by slot (`texture.layer1`) or by the vanilla texture's file name (`texture.potion_overlay`, and `texture.potion` for the bottle alone, alongside the rule's `model=` or `texture=`). If an old name and its 26.x name are both set, the 26.x one wins. OptiFine's older names work too: `bow_standby` is the resting bow, and `potion_bottle_drinkable`/`_splash`/`_lingering` are the bottles. - A rule whose model doesn't load (bad JSON, a missing or looping parent) leaves the item vanilla instead of drawing the missing model. - Tints, glints and special renderers (heads, shields, banners, the in-hand trident) stay as they were: only model layers are swapped. A `model=` rule on a special renderer is left for a follow-up. - Armour stands' off-hand items use the main hand here; the armour PR next in the stack gives them the off hand. - **Without CIT rules nothing changes.** The renderer holds no CIT state and does no lookup (one `Option` check per draw). How: - `ItemRenderer` loads the rules and the pack's CIT models once per resource load. The models are overlaid onto the item model library (#6264), and the textures they name are packed with the rest (#6232). - `resolve_item` asks the cached matcher (#5749) for the stack's rule. The `LayerContent::Model` arm of the item model walk then bakes that rule's version of the leaf model. Bakes are cached per (rule, leaf), with `None` for leaves a rule leaves alone, so a matched stack costs a hash lookup per layer after the first frame. **Tests** (synthetic resource roots, PNGs written by the test, no Mojang files): - `texture.bow_pulling_1` swaps only that leaf; - precedence: `model.<leaf>`, then `texture.<leaf>`, then `model` with `texture` in every slot; - potion layers checked one by one by tint index: `texture=` alone is one untinted layer; with `texture.potion_overlay`, the generic texture is the untinted bottle; `texture.potion` and `texture.potion_bottle_drinkable` swap only the bottle, also next to `texture=` or over `model=`; a block item takes a plain `texture=` on all 6 faces and as its particle; - a 26.x name beats OptiFine's old one in either order, for textures and models; - a broken `model.<leaf>` leaves that leaf vanilla; - `texture.bow_standby` swaps the resting bow; - a broken model leaves its leaf vanilla while the rule's good `model.<leaf>` still draws; - the stack's `max_damage` component wins over the item's; - a CIT model's relative texture reaches the atlas; - a model alone keeps its relative textures; - `texture.potion_overlay` matches by file name and `texture.layer1` by slot; - one bake per rule and leaf; - a matched stack resolves end to end to the rule's model; - with no rules, `cit` is `None` and every resolve is identical to before. **Docs used:** CIT Resewn's wiki (citresewn.shcm.io: CIT Item, CIT Base "Asset Resolution") and OptiFine's `cit_single.properties`. Written from those docs; no OptiFine code was read. **Checks:** - `cargo fmt` - Fork CI (`verify`: workspace clippy `-D warnings` and every test): passed on this code (before the last atlas fix came in): https://github.com/some-du6e/horizon/actions/runs/41339955516. On the current head: https://github.com/some-du6e/horizon/actions/runs/41360655422 - Nothing was built locally: the machine is shared. - Known follow-up: the atlas and the item renderer each read the CIT rules and models once per resource load; sharing one read is a later change. - **The live game test was skipped:** there is no vanilla data (`.local/`) on this machine to launch the game with. Someone with it should try a CIT pack (a renamed sword, a bow with pulling frames, a potion overlay) before merging. > [!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: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#6803
No description provided.