[PR #3543] [MERGED] Hurt players flash red for the other players too (#2827) #5038

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

📋 Pull Request Information

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

Base: main ← Head: fix/issue-2827-hurt-red-tint


📝 Commits (1)

  • 955e7fe Hurt players flash red for the other players too

📊 Changes

2 files changed (+57 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game/lan.rs (+35 -1)
📝 tools/lan_e2e.py (+22 -2)

📄 Description

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

Fixes #2827.

What

When a player got hurt, the other players never saw them flash red. That covers multiplayer, LAN, and anyone watching the host of a single-player world opened to LAN. Mobs flashed as they should. The cause was on the server side: Horizon's server sent the damage event only for mobs and never for players.

I could not reproduce one reading of the report. The local player in third person (F5) already turns red, both on the server thread and in-frame, in v0.2.91 and on main. The red appears one tick after the camera tilt. In first person nothing turns red, and vanilla does the same (see below). The attached video has expired, so the cases left were the other-player view and first person. The other-player view is the one that was broken.

Vanilla

  • LivingEntity.hurtServer: when a hit restarts hurtTime (outside the damage cooldown, or a type that bypasses it) and no BlocksAttacks item blocked it, it calls ServerLevel.broadcastDamageEvent. A blocked hit runs BlocksAttacks.onBlocked and skips the broadcast. This applies to every living entity, players included.
  • ServerLevel.broadcastDamageEvent sends ClientboundDamageEventPacket through ServerChunkCache.sendToTrackingPlayersAndSelf, so the players tracking the entity get it, and so does the hurt player.
  • On the client, LivingEntity.handleDamageEvent sets hurtTime/hurtDuration to 10 and jolts the walk animation. LivingEntityRenderer.extractRenderState sets hasRedOverlay from hurtTime > 0 || deathTime > 0, and getOverlayCoords turns that into the red OverlayTexture row. AvatarRenderer is a LivingEntityRenderer, so the same applies to players.
  • First person: AvatarRenderer.renderHand submits the arm with OverlayTexture.NO_OVERLAY, so vanilla never tints the hand.

How

  • game/lan.rs, lan_flush_effects: after the mobs' hurt and death diff, the host player (if this game has one) and every guest in this level are diffed the same way. The diff uses PlayerHealth.hurt_animation_time, which is set only when a hit restarts the hurt time and is not shield-blocked, so it matches vanilla's broadcast condition. The previous values are kept next to the mobs' in mob_state, keyed by entity id. When the value goes up, the existing Hub::damage_event goes to the players around, the hurt player included. The damage type comes from the player's last HurtRecord, or minecraft:generic when there is none (starving keeps no record). The client side was already in place: remote.rs sets hurt_time = 10 on the player's model, and the renderer turns that red.
  • game/lan.rs, lan_update_models: an in-frame LAN host draws its guests from models of its own. These now carry the guest's hurt time, so that host sees guests flash too.
  • tools/lan_e2e.py, check hurt: after the pigs, the host and then the guest take instant damage, and the other side has to see that player's hurt_time > 0. On the in-frame path the host's view of the guest is checked only by screenshot, because those models are not entities.

Verified

  • The local player in third person already turns red on the unfixed v0.2.91 build (server thread and --in-frame) and on main. It was checked with /damage @s 2 and screenshots. The debug build showed every player vertex carrying the hurt overlay.
  • Before the fix (v0.2.91 and v0.2.96, server thread, host plus a guest on the same machine): after /damage on the host, the guest's entities shows the host with hurt_time 0 in every read. A zombie hurt at the same moment reads 10.
  • After the fix: the guest sees the host at hurt_time 10, and the host sees the guest at 9 (instant damage). Screenshots show the model red from both sides and from an in-frame host.
  • python3 tools/lan_e2e.py --check hurt: PASS on the server thread (host hurt 9, guest hurt 9) and with --in-frame. With the v0.2.96 binaries it FAILS (host hurt 0, guest hurt 0).

pr_ready (tools/pr_ready.py --quick on horizon-build, against origin/main at b56048d99, 3 min 11 s)

Check Result
Scope ✅ 2 files, +57 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 408 passed (32 s)
rustfmt ✅ (7 s)
clippy ✅ (10 s)
tests: horizon-client ✅ 1286 passed (2 min 15 s)
doc tests ✅ 0 passed (4 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)

Known differences

  • The packet's cause and direct entity are left empty. Horizon's client does not read them yet, and the hurt sound still comes from the server as before.
  • A hit of a type that bypasses the cooldown (DamageTypeTags.BYPASSES_COOLDOWN), landing on the very tick of a previous restart, is not seen as a new restart. The mobs' diff has the same limit.
  • A shield-blocked hit sends nothing, as in vanilla. I did not check this case in game.
  • A stronger, unblocked hit inside the cooldown of a shield-blocked hit raises hurt_animation_time from 0, so it sends the event. In vanilla that branch does not restart the hurt time and sends nothing. The only effect is an extra red flash.
  • Starving records no HurtRecord, so its event can carry an earlier hit's damage type (or minecraft:generic). Clients don't read the type yet.

🤖 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/3543 **Author:** [@degepie](https://github.com/degepie) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/issue-2827-hurt-red-tint` --- ### 📝 Commits (1) - [`955e7fe`](https://github.com/horizon-rust/horizon/commit/955e7fe48d6d170d9ad489296835294dec8fb506) Hurt players flash red for the other players too ### 📊 Changes **2 files changed** (+57 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan.rs` (+35 -1) 📝 `tools/lan_e2e.py` (+22 -2) </details> ### 📄 Description > 🤖 Opened by degepie's AI agent (Claude Code), not by degepie personally. Fixes #2827. ## What When a player got hurt, the other players never saw them flash red. That covers multiplayer, LAN, and anyone watching the host of a single-player world opened to LAN. Mobs flashed as they should. The cause was on the server side: Horizon's server sent the damage event only for mobs and never for players. I could not reproduce one reading of the report. The local player in third person (F5) already turns red, both on the server thread and in-frame, in v0.2.91 and on main. The red appears one tick after the camera tilt. In first person nothing turns red, and vanilla does the same (see below). The attached video has expired, so the cases left were the other-player view and first person. The other-player view is the one that was broken. ## Vanilla - `LivingEntity.hurtServer`: when a hit restarts `hurtTime` (outside the damage cooldown, or a type that bypasses it) and no `BlocksAttacks` item blocked it, it calls `ServerLevel.broadcastDamageEvent`. A blocked hit runs `BlocksAttacks.onBlocked` and skips the broadcast. This applies to every living entity, players included. - `ServerLevel.broadcastDamageEvent` sends `ClientboundDamageEventPacket` through `ServerChunkCache.sendToTrackingPlayersAndSelf`, so the players tracking the entity get it, and so does the hurt player. - On the client, `LivingEntity.handleDamageEvent` sets `hurtTime`/`hurtDuration` to 10 and jolts the walk animation. `LivingEntityRenderer.extractRenderState` sets `hasRedOverlay` from `hurtTime > 0 || deathTime > 0`, and `getOverlayCoords` turns that into the red `OverlayTexture` row. `AvatarRenderer` is a `LivingEntityRenderer`, so the same applies to players. - First person: `AvatarRenderer.renderHand` submits the arm with `OverlayTexture.NO_OVERLAY`, so vanilla never tints the hand. ## How - `game/lan.rs`, `lan_flush_effects`: after the mobs' hurt and death diff, the host player (if this game has one) and every guest in this level are diffed the same way. The diff uses `PlayerHealth.hurt_animation_time`, which is set only when a hit restarts the hurt time and is not shield-blocked, so it matches vanilla's broadcast condition. The previous values are kept next to the mobs' in `mob_state`, keyed by entity id. When the value goes up, the existing `Hub::damage_event` goes to the players around, the hurt player included. The damage type comes from the player's last `HurtRecord`, or `minecraft:generic` when there is none (starving keeps no record). The client side was already in place: `remote.rs` sets `hurt_time = 10` on the player's model, and the renderer turns that red. - `game/lan.rs`, `lan_update_models`: an in-frame LAN host draws its guests from models of its own. These now carry the guest's hurt time, so that host sees guests flash too. - `tools/lan_e2e.py`, check `hurt`: after the pigs, the host and then the guest take instant damage, and the other side has to see that player's `hurt_time > 0`. On the in-frame path the host's view of the guest is checked only by screenshot, because those models are not entities. ## Verified - The local player in third person already turns red on the unfixed v0.2.91 build (server thread and `--in-frame`) and on main. It was checked with `/damage @s 2` and screenshots. The debug build showed every player vertex carrying the hurt overlay. - Before the fix (v0.2.91 and v0.2.96, server thread, host plus a guest on the same machine): after `/damage` on the host, the guest's `entities` shows the host with `hurt_time` 0 in every read. A zombie hurt at the same moment reads 10. - After the fix: the guest sees the host at `hurt_time` 10, and the host sees the guest at 9 (instant damage). Screenshots show the model red from both sides and from an in-frame host. - `python3 tools/lan_e2e.py --check hurt`: PASS on the server thread (`host hurt` 9, `guest hurt` 9) and with `--in-frame`. With the v0.2.96 binaries it FAILS (`host hurt` 0, `guest hurt` 0). **pr_ready** (`tools/pr_ready.py --quick` on horizon-build, against origin/main at b56048d99, 3 min 11 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +57 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 408 passed (32 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (10 s) | | tests: horizon-client | ✅ 1286 passed (2 min 15 s) | | doc tests | ✅ 0 passed (4 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) | ## Known differences - The packet's cause and direct entity are left empty. Horizon's client does not read them yet, and the hurt sound still comes from the server as before. - A hit of a type that bypasses the cooldown (`DamageTypeTags.BYPASSES_COOLDOWN`), landing on the very tick of a previous restart, is not seen as a new restart. The mobs' diff has the same limit. - A shield-blocked hit sends nothing, as in vanilla. I did not check this case in game. - A stronger, unblocked hit inside the cooldown of a shield-blocked hit raises `hurt_animation_time` from 0, so it sends the event. In vanilla that branch does not restart the hurt time and sends nothing. The only effect is an extra red flash. - Starving records no `HurtRecord`, so its event can carry an earlier hit's damage type (or `minecraft:generic`). Clients don't read the type yet. 🤖 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:47 +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#5038
No description provided.