[PR #2645] [CLOSED] Animate the block textures the GUI draws: a sculk in the inventory moves again #4501

Closed
opened 2026-11-03 04:17:38 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2645
Author: @levzzz5154
Created: 10/27/2026
Status: ❌ Closed

Base: main ← Head: fix/inventory-block-animation


📝 Commits (1)

  • be76afb Animate the block textures the GUI draws

📊 Changes

4 files changed (+111 additions, -44 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+6 -6)
📝 crates/horizon-client/src/gfx.rs (+1 -1)
📝 crates/horizon-client/src/hud.rs (+85 -37)
📝 crates/horizon-client/src/sprites.rs (+19 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself.

What and why

#2488 ("Blocks don't animate in the inventory": a block item in the creative inventory or the hotbar stands still - sculk, a lantern, prismarine - while the block moves in the world).

Cause: the GUI draws a block item with the HUD atlas's own copy of the block's texture (the HUD has a single texture, while vanilla's GUI draws the block model with the block atlas). The HUD atlas packed every animated block and item texture once, as its first frame, and only the four fire textures were kept playing. So every other animated block texture was frozen in the GUI.

Fix:

  • crates/horizon-client/src/hud.rs: the atlas keeps every animated block and item texture it holds (not just the fire ones), and the HUD writes the frame of the tick into its texture - mixed with the next one when the animation interpolates, as the block atlas mixes it.
  • crates/horizon-client/src/sprites.rs: SpriteAnimation::blended_pixels does that mix on the CPU, with the same integer math as the block atlas's animate.wgsl.

The block textures the world draws are untouched: they keep coming from the block atlas.

Fixes #2488

Vanilla reference

  • net/minecraft/client/renderer/texture/SpriteContents.java: AnimationState.tick advances the frame when the sub-frame reaches the frame's time, needsToDraw says the atlas has to be redrawn when the animation interpolates or the frame changed, and drawToAtlas mixes the current frame with the next one by (int)(frameProgress * 1000.0F) when the animation interpolates.
  • net/minecraft/client/renderer/texture/TextureAtlas.java: the atlas holds the animated sprites and draws the frame of the tick into it.
  • assets/minecraft/textures/block/sculk.png.mcmeta: {"frametime": 20, "interpolate": true} - the block the report names; the same file has the other animated block textures (the lanterns, prismarine, magma, the sculk family).
  • Vanilla's GUI draws a block item as the block model (ItemRenderer.renderStatic), whose textures are block atlas sprites, so the animation shows in the inventory.

Self-check

$ cargo test -p horizon-client --lib -- hud::
running 15 tests
test hud::tests::an_animated_block_texture_animates_in_the_gui ... ok
test hud::tests::a_pack_texture_keeps_the_default_textures_gui_size ... ok
test hud::tests::the_default_textures_keep_a_4096_wide_atlas ... ok
...
test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 1150 filtered out; finished in 0.44s

The new test fails without the fix (the atlas only collected the fire textures, so the sculk texture was not among the animated ones):

thread 'hud::tests::an_animated_block_texture_animates_in_the_gui' panicked at crates/horizon-client/src/hud.rs:1547:14:
the animated block texture is in the atlas

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1164 filtered out; finished in 0.04s

🤖 Generated with 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/2645 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/27/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/inventory-block-animation` --- ### 📝 Commits (1) - [`be76afb`](https://github.com/horizon-rust/horizon/commit/be76afb8ba2ff98825a541aca1d35a34dcf70a37) Animate the block textures the GUI draws ### 📊 Changes **4 files changed** (+111 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+6 -6) 📝 `crates/horizon-client/src/gfx.rs` (+1 -1) 📝 `crates/horizon-client/src/hud.rs` (+85 -37) 📝 `crates/horizon-client/src/sprites.rs` (+19 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself. ## What and why #2488 ("Blocks don't animate in the inventory": a block item in the creative inventory or the hotbar stands still - sculk, a lantern, prismarine - while the block moves in the world). Cause: the GUI draws a block item with the HUD atlas's own copy of the block's texture (the HUD has a single texture, while vanilla's GUI draws the block model with the block atlas). The HUD atlas packed every animated block and item texture once, as its first frame, and only the four fire textures were kept playing. So every other animated block texture was frozen in the GUI. Fix: - `crates/horizon-client/src/hud.rs`: the atlas keeps every animated block and item texture it holds (not just the fire ones), and the HUD writes the frame of the tick into its texture - mixed with the next one when the animation interpolates, as the block atlas mixes it. - `crates/horizon-client/src/sprites.rs`: `SpriteAnimation::blended_pixels` does that mix on the CPU, with the same integer math as the block atlas's `animate.wgsl`. The block textures the world draws are untouched: they keep coming from the block atlas. Fixes #2488 ## Vanilla reference - `net/minecraft/client/renderer/texture/SpriteContents.java`: `AnimationState.tick` advances the frame when the sub-frame reaches the frame's time, `needsToDraw` says the atlas has to be redrawn when the animation interpolates or the frame changed, and `drawToAtlas` mixes the current frame with the next one by `(int)(frameProgress * 1000.0F)` when the animation interpolates. - `net/minecraft/client/renderer/texture/TextureAtlas.java`: the atlas holds the animated sprites and draws the frame of the tick into it. - `assets/minecraft/textures/block/sculk.png.mcmeta`: `{"frametime": 20, "interpolate": true}` - the block the report names; the same file has the other animated block textures (the lanterns, prismarine, magma, the sculk family). - Vanilla's GUI draws a block item as the block model (`ItemRenderer.renderStatic`), whose textures are block atlas sprites, so the animation shows in the inventory. ## Self-check ``` $ cargo test -p horizon-client --lib -- hud:: running 15 tests test hud::tests::an_animated_block_texture_animates_in_the_gui ... ok test hud::tests::a_pack_texture_keeps_the_default_textures_gui_size ... ok test hud::tests::the_default_textures_keep_a_4096_wide_atlas ... ok ... test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 1150 filtered out; finished in 0.44s ``` The new test fails without the fix (the atlas only collected the fire textures, so the sculk texture was not among the animated ones): ``` thread 'hud::tests::an_animated_block_texture_animates_in_the_gui' panicked at crates/horizon-client/src/hud.rs:1547:14: the animated block texture is in the atlas test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1164 filtered out; finished in 0.04s ``` 🤖 Generated with [Claude Code](https://claude.com/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 04:17:38 +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#4501
No description provided.