[PR #196] [MERGED] Inverting crosshair and a working attack indicator #2399

Closed
opened 2026-11-02 15:55:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/196
Author: @ludovic111
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ludovic111

Base: main ← Head: fix/crosshair-97


📝 Commits (1)

  • 6ab958a Crosshair through the inverting CROSSHAIR pipeline, with the attack indicator

📊 Changes

10 files changed (+209 additions, -45 deletions)

View changed files

📝 crates/horizon-client/examples/hud_fixture.rs (+8 -2)
📝 crates/horizon-client/src/game.rs (+8 -4)
📝 crates/horizon-client/src/game/hand.rs (+19 -1)
📝 crates/horizon-client/src/hud.rs (+111 -30)
📝 crates/horizon-client/src/hud_layout.rs (+37 -5)
📝 crates/horizon-client/src/hud_overlays.rs (+4 -0)
📝 crates/horizon-client/src/tab_list.rs (+1 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaHudOracle.java (+14 -3)
📝 tools/hud_parity_cases.py (+6 -0)
📝 tools/test_hud_parity.py (+1 -0)

📄 Description

Fixes #97

What was wrong

  • Vanilla's Hud.extractCrosshair draws the crosshair (and its attack indicator) with RenderPipelines.CROSSHAIR, whose BlendFunction.INVERT is ONE_MINUS_DST_COLOR, ONE_MINUS_SRC_COLOR, ONE, ZERO: the crosshair inverts the colour under it. Horizon drew it alpha-blended, so it was always white.
  • The attack indicator always showed full strength (then_some(1.0) with a "no attack cooldown yet" comment) although the attack strength ticker (attack_strength::AttackStrength, ticked and reset like Player.attackStrengthTicker) exists; and the full "can hit" sprite was never drawn (full was hard-coded false).

Fix

  • GuiDraw::Sprite carries its pipeline (Blend::Textured / new Blend::Crosshair); hud_layout::crosshair marks all its sprites Crosshair. paint records their vertex ranges in HudBatch::invert, and HudRenderer draws the batch in order, switching to a second pipeline with the INVERT blend state for those ranges (HudBatch::runs, unit-tested).
  • Crosshair and hotbar indicators use getAttackStrengthScale(0) from the hand's attack strength and the main hand's ATTACK_SPEED.
  • hud_layout::full_attack_indicator: full strength, getCurrentItemAttackStrengthDelay() > 5 (MIN_CROSSHAIR_ATTACK_SPEED) and crosshairPickEntity a living entity that is alive. The game finds that entity as the nearest entity under the crosshair before any block (crosshair_living: mobs, armor stands and the dragon are living; paintings, frames, boats and carts in front hide them). Vanilla's extra ATTACK_RANGE component check is not modelled (Horizon has no attack_range component yet).

Harness (tools/test_hud_parity.py)

  • The oracle now records every sprite's pipeline (pipeline/gui_textured, pipeline/crosshair), and the fixture writes Horizon's; decorations cases give the crosshair a stand-in crosshairPickEntity (none, alive, dead) and an attack delay (4 to 20 ticks).
  • Mac mini: 2200/2200 HUD states match, 0 oracle errors; the decorations kind has 43 crosshair-indicator cases (33 progress bars, 7 full sprites, 11 full strength on a target without the sprite) and every crosshair case checks the CROSSHAIR pipeline.
  • cargo fmt --check, workspace clippy --all-targets -D warnings and cargo test -p horizon-client --lib hud: clean.

In game (vscreen, llvmpipe): agent-state/wave5b-shots/97-crosshair-crops.png on the desktop, left to right: the full-strength sword sprite while looking at a pig with an iron axe; the cooldown bar right after a swing and 0.25 s later; the crosshair over the sky (brown) and over red sand (blue).

🤖 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/196 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/crosshair-97` --- ### 📝 Commits (1) - [`6ab958a`](https://github.com/horizon-rust/horizon/commit/6ab958a42314a00407c44b1d7e3228302d3b80dc) Crosshair through the inverting CROSSHAIR pipeline, with the attack indicator ### 📊 Changes **10 files changed** (+209 additions, -45 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/hud_fixture.rs` (+8 -2) 📝 `crates/horizon-client/src/game.rs` (+8 -4) 📝 `crates/horizon-client/src/game/hand.rs` (+19 -1) 📝 `crates/horizon-client/src/hud.rs` (+111 -30) 📝 `crates/horizon-client/src/hud_layout.rs` (+37 -5) 📝 `crates/horizon-client/src/hud_overlays.rs` (+4 -0) 📝 `crates/horizon-client/src/tab_list.rs` (+1 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaHudOracle.java` (+14 -3) 📝 `tools/hud_parity_cases.py` (+6 -0) 📝 `tools/test_hud_parity.py` (+1 -0) </details> ### 📄 Description Fixes #97 **What was wrong** - Vanilla's `Hud.extractCrosshair` draws the crosshair (and its attack indicator) with `RenderPipelines.CROSSHAIR`, whose `BlendFunction.INVERT` is `ONE_MINUS_DST_COLOR, ONE_MINUS_SRC_COLOR, ONE, ZERO`: the crosshair inverts the colour under it. Horizon drew it alpha-blended, so it was always white. - The attack indicator always showed full strength (`then_some(1.0)` with a "no attack cooldown yet" comment) although the attack strength ticker (`attack_strength::AttackStrength`, ticked and reset like `Player.attackStrengthTicker`) exists; and the full "can hit" sprite was never drawn (`full` was hard-coded `false`). **Fix** - `GuiDraw::Sprite` carries its pipeline (`Blend::Textured` / new `Blend::Crosshair`); `hud_layout::crosshair` marks all its sprites `Crosshair`. `paint` records their vertex ranges in `HudBatch::invert`, and `HudRenderer` draws the batch in order, switching to a second pipeline with the INVERT blend state for those ranges (`HudBatch::runs`, unit-tested). - Crosshair and hotbar indicators use `getAttackStrengthScale(0)` from the hand's attack strength and the main hand's ATTACK_SPEED. - `hud_layout::full_attack_indicator`: full strength, `getCurrentItemAttackStrengthDelay() > 5` (MIN_CROSSHAIR_ATTACK_SPEED) and `crosshairPickEntity` a living entity that is alive. The game finds that entity as the nearest entity under the crosshair before any block (`crosshair_living`: mobs, armor stands and the dragon are living; paintings, frames, boats and carts in front hide them). Vanilla's extra `ATTACK_RANGE` component check is not modelled (Horizon has no attack_range component yet). **Harness (tools/test_hud_parity.py)** - The oracle now records every sprite's pipeline (`pipeline/gui_textured`, `pipeline/crosshair`), and the fixture writes Horizon's; decorations cases give the crosshair a stand-in `crosshairPickEntity` (none, alive, dead) and an attack delay (4 to 20 ticks). - Mac mini: **2200/2200 HUD states match, 0 oracle errors**; the decorations kind has 43 crosshair-indicator cases (33 progress bars, 7 full sprites, 11 full strength on a target without the sprite) and every crosshair case checks the CROSSHAIR pipeline. - `cargo fmt --check`, workspace `clippy --all-targets -D warnings` and `cargo test -p horizon-client --lib hud`: clean. **In game (vscreen, llvmpipe)**: `agent-state/wave5b-shots/97-crosshair-crops.png` on the desktop, left to right: the full-strength sword sprite while looking at a pig with an iron axe; the cooldown bar right after a swing and 0.25 s later; the crosshair over the sky (brown) and over red sand (blue). 🤖 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-02 15:55:41 +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#2399
No description provided.