[PR #3409] [MERGED] Totem of undying: the item activation animation on screen (#3142) #4962

Closed
opened 2026-11-03 05:09:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3409
Author: @degepie
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix/issue-3142-totem-activation


📝 Commits (3)

  • e7f7467 Totem of undying: the item activation animation on screen
  • 9f666ed Merge main into this branch after the render crate split (#3186)
  • 201ea8b Merge main into the branch

📊 Changes

6 files changed (+241 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+16 -2)
📝 crates/horizon-client/src/game/item_draw.rs (+14 -1)
📝 crates/horizon-client/src/game/remote.rs (+3 -0)
📝 crates/horizon-client/src/game/totem.rs (+63 -0)
➕ crates/horizon-client/src/item_activation.rs (+144 -0)
📝 crates/horizon-client/src/lib.rs (+1 -0)

📄 Description

🤖 Opened by degepie's AI agent (Claude Code), not by degepie personally.

Fixes #3142.

What

When a totem of undying saves the player, vanilla flies the totem up to the screen and spins it there for 2 seconds. Horizon already had the particles, the sound and the rumble, but not this animation. This PR adds it.

Vanilla (26.3 client jar, read with javap -c)

  • ClientPacketListener.handleEntityEvent, event 35: the particle emitter, playLocalSound, and, for minecraft.player only, LocalPlayer.displayItemActivation(findTotem(player)).
  • ClientPacketListener.findTotem: the first hand's stack with DEATH_PROTECTION, otherwise new ItemStack(Items.TOTEM_OF_UNDYING). In single player the totem is already used up when the event arrives, so this fallback is the usual case.
  • net.minecraft.client.player.ItemActivation: ANIMATION_LENGTH = 40. activate copies the stack, sets 40 ticks and draws offX, then offY, each as nextFloat() * 2 - 1 from the player's random. tick clears the item when the count reaches 0. isActive is true while it has an item and ticks > 0.
  • GameRenderer.tick ticks it. GameRenderer.resetData (called from Minecraft.disconnect and clearClientLevel) resets it. handleRespawn passes the same object to the new player, so a respawn does not reset it.
  • LevelExtractor: the item is resolved with ItemDisplayContext.FIXED, no owner, seed 0.
  • ScreenEffectRenderer.renderItemActivationAnimation, called from ScreenEffectRenderer.submit and gated only by isHudHidden (F1): t = (40 - ticks + partial) / 40, curve = 10.25t^5 - 24.95t^4 + 25.5t^3 - 13.8t^2 + 4t, a = curve * PI. The pose is a fresh PoseStack (no camera turn, no bob) drawn with render3dHud's hand projection: translate(offX*0.3*aspect*|sin 2a|, offY*0.3*|sin 2a|, -10 + 9 sin a), scale(0.8), Y 900*|sin a|°, X 6*cos(8t)°, Z 6*cos(8t)°. It uses Lighting.Entry.ITEMS_3D at full brightness (15728880).

How

  • New horizon_client::item_activation (lib): ItemActivation (activate / tick / reset / active) and animation_pose, transcribed from the bytecode with vanilla's table Mth.sin/cos.
  • game/totem.rs: totem_event for the player's own event runs find_totem (the death_protection component, otherwise a new totem) and then activate. Vanilla draws the two offsets from LocalPlayer.random. Horizon has no per-player random, so this uses the client-only particle random, the same stand-in ItemEntity.bobOffs uses, which leaves the level random untouched. item_activation_geometry resolves the item and emits it into the hand pass after the held items (the render3dHud order: hand, then screen effects). The hand pass draws with bob * view, so the pose is pre-multiplied by its inverse. That makes the totem ignore the camera turn and the hurt bob, as vanilla's fresh PoseStack does. ITEMS_3D lights get the same transform. Only F1 hides it: it also shows in third person and while scoping, like vanilla.
  • The tick sits next to boss_overlay.tick_darken (GameRenderer.tick) in both the local and the remote tick. The reset sits in finish_close_world and leave_server (resetData).
  • game/item_draw.rs: submit_item_lit, which is submit_item_world with other diffuse lights.

Verified

  • Unit tests (item_activation::tests): the 40-tick lifetime; the two offsets from java.util.Random(0) (0.4619355, 0.662882); the curve's position at ticks 40, 30 and 20 (10 out, then about 1 out at the halfway point), with the sideways swing from the offsets and the aspect; smooth partial ticks; the 0.8 scale.
  • In the game, release build, scratch home and cwd, world T, survival: I ran item replace entity @s weapon.offhand with minecraft:totem_of_undying, then damage @s 100, then 12 back-to-back horizon-ctl screenshot calls, one after wait 10 and one after another wait 40.
    • Before (released v0.2.91): the particles appear but no totem shows on screen. Screenshots: ~/src/i3142-shots/before/*.png.
    • After (this branch): the totem comes in small from the centre, spins up to about one block from the eye, covers the middle of the screen behind the hand and the HUD, and is gone in the last screenshot (zz-gone.png). Screenshots: ~/src/i3142-shots/after/*.png (for example 10.png).
  • No parity harness covers screen-effect rendering (first_person checks the hand's tick state and hud the 2D HUD), so I added no harness.

Not checked: the LAN-guest and dedicated-server paths in the real game. They go through the same remote_totem → totem_event(own) path. I also did not compare pixels against the vanilla client.

pr_ready (tools/pr_ready.py --quick on b550, against origin/main at f3d8535fc, 8 min 37 s)

Check Result
Scope ✅ 6 files, +241 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 408 passed (26 s)
rustfmt ✅ (6 s)
clippy ✅ (2 min 42 s)
tests: horizon-client ✅ 1286 passed (4 min 43 s)
doc tests ✅ 0 passed (40 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 347 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 335 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

[exited with code 0]

Known differences

  • Order with fire/water overlays: vanilla's ScreenEffectRenderer.submit draws the activation after the fire and water overlays, so the totem is on top of them. Horizon draws its screen-effect quads separately, so while the player is burning the totem may show under the fire overlay. Fixing that is a separate change to the screen-effect order.
  • Random source: vanilla draws offX/offY from LocalPlayer.random. Horizon has no per-player client random yet, so this uses the client-only particle random, the same stand-in dropped items' bob already uses. The range (−1…1) is the same, but the values for a given seed are not.
  • Not checked in game: third person, a LAN guest, a dedicated server. These go through the same code path. Not compared pixel for pixel against the vanilla client.

🤖 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/3409 **Author:** [@degepie](https://github.com/degepie) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/issue-3142-totem-activation` --- ### 📝 Commits (3) - [`e7f7467`](https://github.com/horizon-rust/horizon/commit/e7f746782fb7ae9715009bb892ed7ef598e218b8) Totem of undying: the item activation animation on screen - [`9f666ed`](https://github.com/horizon-rust/horizon/commit/9f666edc4485cd9de275fcc5d5c87bde77583dd8) Merge main into this branch after the render crate split (#3186) - [`201ea8b`](https://github.com/horizon-rust/horizon/commit/201ea8b39335305ed69337a43aea9fb4d2964f44) Merge main into the branch ### 📊 Changes **6 files changed** (+241 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+16 -2) 📝 `crates/horizon-client/src/game/item_draw.rs` (+14 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+3 -0) 📝 `crates/horizon-client/src/game/totem.rs` (+63 -0) ➕ `crates/horizon-client/src/item_activation.rs` (+144 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) </details> ### 📄 Description > 🤖 Opened by degepie's AI agent (Claude Code), not by degepie personally. Fixes #3142. ## What When a totem of undying saves the player, vanilla flies the totem up to the screen and spins it there for 2 seconds. Horizon already had the particles, the sound and the rumble, but not this animation. This PR adds it. ## Vanilla (26.3 client jar, read with `javap -c`) - `ClientPacketListener.handleEntityEvent`, event 35: the particle emitter, `playLocalSound`, and, for `minecraft.player` only, `LocalPlayer.displayItemActivation(findTotem(player))`. - `ClientPacketListener.findTotem`: the first hand's stack with `DEATH_PROTECTION`, otherwise `new ItemStack(Items.TOTEM_OF_UNDYING)`. In single player the totem is already used up when the event arrives, so this fallback is the usual case. - `net.minecraft.client.player.ItemActivation`: `ANIMATION_LENGTH = 40`. `activate` copies the stack, sets 40 ticks and draws `offX`, then `offY`, each as `nextFloat() * 2 - 1` from the player's random. `tick` clears the item when the count reaches 0. `isActive` is true while it has an item and ticks > 0. - `GameRenderer.tick` ticks it. `GameRenderer.resetData` (called from `Minecraft.disconnect` and `clearClientLevel`) resets it. `handleRespawn` passes the same object to the new player, so a respawn does not reset it. - `LevelExtractor`: the item is resolved with `ItemDisplayContext.FIXED`, no owner, seed 0. - `ScreenEffectRenderer.renderItemActivationAnimation`, called from `ScreenEffectRenderer.submit` and gated only by `isHudHidden` (F1): `t = (40 - ticks + partial) / 40`, `curve = 10.25t^5 - 24.95t^4 + 25.5t^3 - 13.8t^2 + 4t`, `a = curve * PI`. The pose is a fresh `PoseStack` (no camera turn, no bob) drawn with `render3dHud`'s hand projection: `translate(offX*0.3*aspect*|sin 2a|, offY*0.3*|sin 2a|, -10 + 9 sin a)`, `scale(0.8)`, `Y 900*|sin a|°`, `X 6*cos(8t)°`, `Z 6*cos(8t)°`. It uses `Lighting.Entry.ITEMS_3D` at full brightness (15728880). ## How - New `horizon_client::item_activation` (lib): `ItemActivation` (`activate` / `tick` / `reset` / `active`) and `animation_pose`, transcribed from the bytecode with vanilla's table `Mth.sin`/`cos`. - `game/totem.rs`: `totem_event` for the player's own event runs `find_totem` (the `death_protection` component, otherwise a new totem) and then `activate`. Vanilla draws the two offsets from `LocalPlayer.random`. Horizon has no per-player random, so this uses the client-only particle random, the same stand-in `ItemEntity.bobOffs` uses, which leaves the level random untouched. `item_activation_geometry` resolves the item and emits it into the hand pass after the held items (the `render3dHud` order: hand, then screen effects). The hand pass draws with `bob * view`, so the pose is pre-multiplied by its inverse. That makes the totem ignore the camera turn and the hurt bob, as vanilla's fresh `PoseStack` does. `ITEMS_3D` lights get the same transform. Only F1 hides it: it also shows in third person and while scoping, like vanilla. - The tick sits next to `boss_overlay.tick_darken` (`GameRenderer.tick`) in both the local and the remote tick. The reset sits in `finish_close_world` and `leave_server` (`resetData`). - `game/item_draw.rs`: `submit_item_lit`, which is `submit_item_world` with other diffuse lights. ## Verified - Unit tests (`item_activation::tests`): the 40-tick lifetime; the two offsets from `java.util.Random(0)` (0.4619355, 0.662882); the curve's position at ticks 40, 30 and 20 (10 out, then about 1 out at the halfway point), with the sideways swing from the offsets and the aspect; smooth partial ticks; the 0.8 scale. - In the game, release build, scratch home and cwd, world `T`, survival: I ran `item replace entity @s weapon.offhand with minecraft:totem_of_undying`, then `damage @s 100`, then 12 back-to-back `horizon-ctl screenshot` calls, one after `wait 10` and one after another `wait 40`. - Before (released v0.2.91): the particles appear but no totem shows on screen. Screenshots: `~/src/i3142-shots/before/*.png`. - After (this branch): the totem comes in small from the centre, spins up to about one block from the eye, covers the middle of the screen behind the hand and the HUD, and is gone in the last screenshot (`zz-gone.png`). Screenshots: `~/src/i3142-shots/after/*.png` (for example `10.png`). - No parity harness covers screen-effect rendering (`first_person` checks the hand's tick state and `hud` the 2D HUD), so I added no harness. Not checked: the LAN-guest and dedicated-server paths in the real game. They go through the same `remote_totem` → `totem_event(own)` path. I also did not compare pixels against the vanilla client. **pr_ready** (`tools/pr_ready.py --quick` on b550, against origin/main at f3d8535fc, 8 min 37 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +241 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 408 passed (26 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (2 min 42 s) | | tests: horizon-client | ✅ 1286 passed (4 min 43 s) | | doc tests | ✅ 0 passed (40 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 347 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 335 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | [exited with code 0] ## Known differences - **Order with fire/water overlays:** vanilla's `ScreenEffectRenderer.submit` draws the activation after the fire and water overlays, so the totem is on top of them. Horizon draws its screen-effect quads separately, so while the player is burning the totem may show under the fire overlay. Fixing that is a separate change to the screen-effect order. - **Random source:** vanilla draws `offX`/`offY` from `LocalPlayer.random`. Horizon has no per-player client random yet, so this uses the client-only particle random, the same stand-in dropped items' bob already uses. The range (−1…1) is the same, but the values for a given seed are not. - **Not checked in game:** third person, a LAN guest, a dedicated server. These go through the same code path. Not compared pixel for pixel against the vanilla client. 🤖 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 05:09:12 +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#4962
No description provided.