[PR #1969] [MERGED] Give a server player's new body its effects at once after a level change #3898

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

📋 Pull Request Information

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

Base: main ← Head: fix/1302-speed-after-travel


📝 Commits (3)

  • a7ff22e Give a server player's new body its effects at once after a level change
  • 19a5098 Leave a respawned body's reset to the swap that builds it
  • a14da6b Merge origin/main into fix/1302-speed-after-travel

📊 Changes

1 file changed (+9 additions, -5 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+9 -5)

📄 Description

Fixes #1302.

What and why

On the server thread a player gets a new body (a fresh PlayerMotion) when it joins, respawns or changes
level. What the old body had been given by its effects, the applied effect modifiers and the armor protection
table (BodyPotions), stayed in the player's record. apply_effect_status compares the effects' modifiers with
that list, found nothing to change, and never put them on the new body. After a trip to another dimension
Speed II kept its icon, but the body's movement speed fell from 0.14 back to 0.10 until the effect was cleared
and given again. Enchanted armor's protection table had the same stale cache.

enter_guest now clears that record for a new body, as it already did for equipment (play.equipped), and
applies the effects to the new body when it is created, before the movement that brought it is handled.
Respawn already cleared the record; joining and respawning only get the effects one tick earlier.

Vanilla reference

ServerPlayer.teleport into another level keeps the same entity, with its AttributeMap and
MobEffect.addAttributeModifiers modifiers (LivingEntity.onEffectAdded). MobEffects.SPEED: +0.2 per level,
ADD_MULTIPLIED_TOTAL.

Harnesses (server path regressions; none covers attributes after a level change):

  • python tools/test_server_dimension_players_parity.py: server dimension players: 40 lines identical
  • python tools/test_hardcore_respawn_parity.py: hardcore respawn: 2 lines identical
  • python tools/test_cursor_death_parity.py: cursor death: 3 lines identical
  • python tools/test_pearl_death_parity.py: pearl death: 2 lines identical

In game (release build, fresh world, driven with horizon-ctl): survival, /effect give @s speed 120 1,
/attribute @s minecraft:movement_speed get, /execute in minecraft:the_nether run tp @s 0.5 110 0.5 onto a
prepared floor, then the same attribute get.

  • Server thread, before: 0.14 before the trip, 0.10 after.
  • Server thread, after: 0.14 before and after.
  • --in-frame: 0.14 before and after (unchanged).

Related: #1338 (Resistance ignored for the arrival fall) has the same cause in its hypothesis: the new body had
no effect status until the next tick. This change puts the effects on the new body before its first movement.
I could not reproduce #1338 on current main (Resistance V, a cold and a warm Nether arrival fall: health stayed
20 both times, before the fix too), so this PR does not claim it.

Self-check

I did not paste a tools/pr_ready.py block: I work on Windows, where tools/parity.py cannot run (it needs
fcntl) and three horizon-client tests fail on upstream/main as well
(crash::tests::stacks_start_at_the_panicking_frame,
packs::cache::tests::directory_inputs_config_and_owned_output_recovery,
save::tests::session_lock_is_exclusive). cargo fmt --all -- --check passes; CI runs clippy and the
tests on Linux, and the harnesses above were run one by one (python tools/test_<name>_parity.py).


🔄 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/1969 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/1302-speed-after-travel` --- ### 📝 Commits (3) - [`a7ff22e`](https://github.com/horizon-rust/horizon/commit/a7ff22eea05de72275341d7346252fc5d2ecdbb6) Give a server player's new body its effects at once after a level change - [`19a5098`](https://github.com/horizon-rust/horizon/commit/19a5098b140f4ca6eab01b0e73f5d8688cd52d85) Leave a respawned body's reset to the swap that builds it - [`a14da6b`](https://github.com/horizon-rust/horizon/commit/a14da6bb70a66598dd27e3eb00699de058e881cd) Merge origin/main into fix/1302-speed-after-travel ### 📊 Changes **1 file changed** (+9 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+9 -5) </details> ### 📄 Description Fixes #1302. ## What and why On the server thread a player gets a new body (a fresh `PlayerMotion`) when it joins, respawns or changes level. What the old body had been given by its effects, the applied effect modifiers and the armor protection table (`BodyPotions`), stayed in the player's record. `apply_effect_status` compares the effects' modifiers with that list, found nothing to change, and never put them on the new body. After a trip to another dimension Speed II kept its icon, but the body's movement speed fell from 0.14 back to 0.10 until the effect was cleared and given again. Enchanted armor's protection table had the same stale cache. `enter_guest` now clears that record for a new body, as it already did for equipment (`play.equipped`), and applies the effects to the new body when it is created, before the movement that brought it is handled. Respawn already cleared the record; joining and respawning only get the effects one tick earlier. ## Vanilla reference `ServerPlayer.teleport` into another level keeps the same entity, with its `AttributeMap` and `MobEffect.addAttributeModifiers` modifiers (`LivingEntity.onEffectAdded`). `MobEffects.SPEED`: +0.2 per level, `ADD_MULTIPLIED_TOTAL`. Harnesses (server path regressions; none covers attributes after a level change): - `python tools/test_server_dimension_players_parity.py`: `server dimension players: 40 lines identical` - `python tools/test_hardcore_respawn_parity.py`: `hardcore respawn: 2 lines identical` - `python tools/test_cursor_death_parity.py`: `cursor death: 3 lines identical` - `python tools/test_pearl_death_parity.py`: `pearl death: 2 lines identical` In game (release build, fresh world, driven with horizon-ctl): survival, `/effect give @s speed 120 1`, `/attribute @s minecraft:movement_speed get`, `/execute in minecraft:the_nether run tp @s 0.5 110 0.5` onto a prepared floor, then the same `attribute get`. - Server thread, before: 0.14 before the trip, 0.10 after. - Server thread, after: 0.14 before and after. - `--in-frame`: 0.14 before and after (unchanged). Related: #1338 (Resistance ignored for the arrival fall) has the same cause in its hypothesis: the new body had no effect status until the next tick. This change puts the effects on the new body before its first movement. I could not reproduce #1338 on current main (Resistance V, a cold and a warm Nether arrival fall: health stayed 20 both times, before the fix too), so this PR does not claim it. ## Self-check I did not paste a `tools/pr_ready.py` block: I work on Windows, where `tools/parity.py` cannot run (it needs `fcntl`) and three horizon-client tests fail on upstream/main as well (`crash::tests::stacks_start_at_the_panicking_frame`, `packs::cache::tests::directory_inputs_config_and_owned_output_recovery`, `save::tests::session_lock_is_exclusive`). `cargo fmt --all -- --check` passes; CI runs clippy and the tests on Linux, and the harnesses above were run one by one (`python tools/test_<name>_parity.py`). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:13:06 +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#3898
No description provided.