[PR #2155] [MERGED] Target blocks react to projectile hits #4056

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

📋 Pull Request Information

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

Base: main ← Head: fix/target-block-projectiles


📝 Commits (1)

  • 7d5a052 Target blocks react to projectile hits

📊 Changes

3 files changed (+77 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+24 -0)
📝 crates/horizon-world/src/level/mod.rs (+16 -0)
📝 crates/horizon-world/src/level/redstone.rs (+37 -0)

📄 Description

What and why

A target block did nothing when it was hit: its power stayed 0 for arrows, snowballs, eggs and every other projectile. In vanilla every projectile that hits a block calls BlockState.onProjectileHit (arrows included, not only burning ones), and a target block uses that to power itself.

This change:

  • adds Behaviours::target_projectile_hit to the block behaviour library: for a target block it sets power from where the projectile landed (1 to 15, by the distance from the centre of the face that was hit, along the face's two other axes), and schedules the reset with the usual scheduled tick (20 ticks for an arrow, 8 for anything else), only when no reset is already scheduled;
  • calls it from Game::projectile_hit for every block hit, so arrows (burning or not), snowballs, eggs, ender pearls, fireballs, wind charges, llama spit, shulker bullets, wither skulls and witches' potions all power a target block. The fire-only reactions of burning arrows (TNT, campfires, candles) are untouched and stay fire-only;
  • counts the target_hit statistic when a player's projectile hits a target block;
  • the existing target block tick (back to 0) and its neighbour update handling already exist and are reused.

Not covered here: thrown tridents and player-thrown potions, whose flight code has no ray-cast hit position or face to feed the target block, and the target_hit advancement trigger (used by "Bullseye").

Vanilla reference

  • TargetBlock.onProjectileHit, updateRedstoneOutput, getRedstoneStrength, setOutputPower and tick (20 ticks for AbstractArrow, 8 otherwise; no new power while a reset is scheduled)
  • Projectile.onHitBlock (calls state.onProjectileHit for every projectile) and AbstractArrow.onHitBlock, which calls it through super

Self-check

cargo check -p horizon-client passes.


🔄 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/2155 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/target-block-projectiles` --- ### 📝 Commits (1) - [`7d5a052`](https://github.com/horizon-rust/horizon/commit/7d5a05226183aedba5a95047d8ecf9f91a3442fa) Target blocks react to projectile hits ### 📊 Changes **3 files changed** (+77 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+24 -0) 📝 `crates/horizon-world/src/level/mod.rs` (+16 -0) 📝 `crates/horizon-world/src/level/redstone.rs` (+37 -0) </details> ### 📄 Description ## What and why A target block did nothing when it was hit: its power stayed 0 for arrows, snowballs, eggs and every other projectile. In vanilla every projectile that hits a block calls `BlockState.onProjectileHit` (arrows included, not only burning ones), and a target block uses that to power itself. This change: - adds `Behaviours::target_projectile_hit` to the block behaviour library: for a target block it sets `power` from where the projectile landed (1 to 15, by the distance from the centre of the face that was hit, along the face's two other axes), and schedules the reset with the usual scheduled tick (20 ticks for an arrow, 8 for anything else), only when no reset is already scheduled; - calls it from `Game::projectile_hit` for every block hit, so arrows (burning or not), snowballs, eggs, ender pearls, fireballs, wind charges, llama spit, shulker bullets, wither skulls and witches' potions all power a target block. The fire-only reactions of burning arrows (TNT, campfires, candles) are untouched and stay fire-only; - counts the `target_hit` statistic when a player's projectile hits a target block; - the existing target block tick (back to 0) and its neighbour update handling already exist and are reused. Not covered here: thrown tridents and player-thrown potions, whose flight code has no ray-cast hit position or face to feed the target block, and the `target_hit` advancement trigger (used by "Bullseye"). ## Vanilla reference - `TargetBlock.onProjectileHit`, `updateRedstoneOutput`, `getRedstoneStrength`, `setOutputPower` and `tick` (20 ticks for `AbstractArrow`, 8 otherwise; no new power while a reset is scheduled) - `Projectile.onHitBlock` (calls `state.onProjectileHit` for every projectile) and `AbstractArrow.onHitBlock`, which calls it through `super` ## Self-check `cargo check -p horizon-client` passes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:14:22 +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#4056
No description provided.