[PR #5114] [MERGED] Read the projectile power the server sends with a projectile's motion #6083

Closed
opened 2026-11-03 06:11:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5114
Author: @MSedgeMC
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/projectile-power-packet


📝 Commits (1)

  • 67979af Read the projectile power the server sends with a projectile's motion

📊 Changes

3 files changed (+71 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/remote.rs (+9 -0)
📝 crates/horizon-client/src/game/remote_projectiles.rs (+61 -0)
📝 tools/port_map/client-002.tsv (+1 -1)

📄 Description

Fixes the ClientPacketListener.handleProjectilePowerPacket row in the port ledger. (No issue.)

Vanilla's handler is three lines: find the entity by the packet's id, require an AbstractHurtingProjectile, and take its accelerationPower. The power is not a constant — onDeflection halves it when the projectile is deflected by a block and resets it to 0.1 when deflected by an entity, and NBT can set it — which is why the server resends it, bundled with the projectile's motion update.

Horizon modelled the field (Projectile::acceleration), used it in its own client physics, and sent it from its own server in that same bundle — but the client decoded the packet and dropped it in the catch-all, so a remote projectile kept its spawn-time 0.1. The visible case is narrow but real: a deflected fireball accelerates at half the power it should between updates.

The arm follows the positional siblings above it (SetEntityMotion) and the guard mirrors vanilla's instanceof: only the five hurting kinds take the new power, and an arrow, a thrown item or an unknown id is ignored.

Proven: cargo test -p horizon-client --bin horizon-client a_power_packet → 2 passed on a build box: a fireball given 0.5 accelerates to (1.5 + 0.5) * 0.95 = 1.9 on its next tick where the default 0.1 would have made 1.52, and the same packet against an arrow's id, a non-hurting projectile and an unknown id leaves every acceleration untouched.

Not proven: nothing in a game — the honest check is a deflected fireball's flight compared against vanilla's.

Two things left, both pre-existing and named rather than silently fixed: a dragon fireball is an AbstractHurtingProjectile in vanilla but a separate struct in Horizon with no acceleration field, so a power packet for one is ignored (harmless today, since its remote step hardcodes the 0.1 our sender also sends); and our sender writes a per-kind constant rather than the live power, so a Horizon host never sends the halved value — porting ServerEntity.sendChanges to read the real field is its own change.


🔄 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/5114 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/projectile-power-packet` --- ### 📝 Commits (1) - [`67979af`](https://github.com/horizon-rust/horizon/commit/67979afe8db5d0b7415b47b6e4020f61d151f455) Read the projectile power the server sends with a projectile's motion ### 📊 Changes **3 files changed** (+71 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/remote.rs` (+9 -0) 📝 `crates/horizon-client/src/game/remote_projectiles.rs` (+61 -0) 📝 `tools/port_map/client-002.tsv` (+1 -1) </details> ### 📄 Description Fixes the `ClientPacketListener.handleProjectilePowerPacket` row in the port ledger. (No issue.) Vanilla's handler is three lines: find the entity by the packet's id, require an `AbstractHurtingProjectile`, and take its `accelerationPower`. The power is not a constant — `onDeflection` halves it when the projectile is deflected by a block and resets it to 0.1 when deflected by an entity, and NBT can set it — which is why the server resends it, bundled with the projectile's motion update. Horizon modelled the field (`Projectile::acceleration`), used it in its own client physics, and **sent** it from its own server in that same bundle — but the client decoded the packet and dropped it in the catch-all, so a remote projectile kept its spawn-time 0.1. The visible case is narrow but real: a deflected fireball accelerates at half the power it should between updates. The arm follows the positional siblings above it (`SetEntityMotion`) and the guard mirrors vanilla's `instanceof`: only the five hurting kinds take the new power, and an arrow, a thrown item or an unknown id is ignored. **Proven:** `cargo test -p horizon-client --bin horizon-client a_power_packet` → 2 passed on a build box: a fireball given 0.5 accelerates to `(1.5 + 0.5) * 0.95 = 1.9` on its next tick where the default 0.1 would have made 1.52, and the same packet against an arrow's id, a non-hurting projectile and an unknown id leaves every acceleration untouched. **Not proven:** nothing in a game — the honest check is a deflected fireball's flight compared against vanilla's. Two things left, both pre-existing and named rather than silently fixed: a **dragon fireball** is an `AbstractHurtingProjectile` in vanilla but a separate struct in Horizon with no acceleration field, so a power packet for one is ignored (harmless today, since its remote step hardcodes the 0.1 our sender also sends); and our sender writes a **per-kind constant** rather than the live power, so a Horizon host never sends the halved value — porting `ServerEntity.sendChanges` to read the real field is its own change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:11:31 +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#6083
No description provided.