[PR #2691] [MERGED] Keep a rider with the vehicle it rides through a Nether portal #4545

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2691
Author: @levzzz5154
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @ludovic111

Base: main ← Head: fix/portal-rider-travel


📝 Commits (3)

  • 33e81f4 Keep a rider with the vehicle it rides through a portal
  • 44850bd Merge upstream/main into the portal rider travel branch
  • 7e68f1e Remove the duplicate rabbit arm in entity_nbt

📊 Changes

5 files changed (+208 additions, -17 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+1 -4)
📝 crates/horizon-client/src/game/lan_vehicles.rs (+8 -0)
📝 crates/horizon-client/src/game/levels.rs (+26 -3)
📝 crates/horizon-client/src/game/nether_portal.rs (+16 -8)
📝 crates/horizon-client/src/game/server_travel.rs (+157 -2)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself.

What and why

On a server thread (a dedicated server, or single player on its server thread), a
player who rode a horse into a Nether portal arrived in the Nether on foot:
/ride @s dismount said the player was not riding anything.

The horse and the rider travelled by two unrelated paths and the link between
them broke:

  • the horse was a mob, so it went through the portal on its own, as an entity:
    it was saved to NBT, waited as an Arrival for the destination level, and was
    restored there with a new entity id;
  • the rider was a server player, so it travelled alone: the Respawn packet, the
    level swap and the teleport to the exit.

The guest's vehicle still held the horse's old id, so the first tick after the
arrival found no vehicle with that id in the new level, dropped the ride, and
the rider stood next to a horse with a different id. Vanilla does not have that
split: the vehicle travels with the passengers and the passengers ride it again
in the other dimension.

The fix makes the vehicle a server player rides travel with that player:

  • the animal a player rides is left out of the entity portal path
    (mob_can_use_portal), as vanilla leaves a passenger out
    (Entity.canUsePortal(false) is false for a passenger); it no longer goes
    through the portal on its own, so it is not duplicated and its id does not
    change;
  • the trip (Trip) now carries the vehicle the player rides and the level the
    player came from; when the trip arrives, the vehicle moves from that level to
    the destination level with the same entity id, stands where its rider
    arrives, and keeps its UUID and the compound it was loaded with, so it is
    saved as it was;
  • the vehicle that came through the portal does not go straight back through the
    exit portal (Entity.setPortalCooldown, 300 ticks).

The ride is therefore never broken: the guest still holds the vehicle, the
clients get the SetPassengers for the same vehicle id, and the player is still
mounted when it arrives.

Fixes #1486

Vanilla reference

  • net.minecraft.world.entity.Entity#teleportCrossDimension (26.3): the
    vehicle is recreated in the other dimension
    (this.getType().create(newLevel, EntitySpawnReason.DIMENSION_TRAVEL),
    newLevel.addDuringTeleport(newEntity)), and every passenger is put back on
    it with newPassenger.startRiding(newEntity, true, false) — the passengers
    travel with the vehicle and ride it again.
  • net.minecraft.world.entity.Entity#calculatePassengerTransition: the
    passenger keeps its seat (its offset from the vehicle) and its rotation
    across the travel.
  • net.minecraft.world.entity.Entity#canUsePortal:
    (ignorePassenger || !this.isPassenger()) && this.isAlive() — a passenger
    does not use a portal on its own; the vehicle carries it.
  • net.minecraft.world.level.block.NetherPortalBlock#entityInside:
    if (entity.canUsePortal(false)) entity.setAsInsidePortal(this, pos); — only
    the vehicle gets a portal process.
  • net.minecraft.world.level.block.NetherPortalBlock#getPortalTransitionTime:
    the game rule delay for players, 0 for the other entities.
  • net.minecraft.world.entity.Entity#handlePortal /
    #teleportToPortalDestination / #getDimensionChangingDelay: the entity
    that goes through the portal is teleported to its destination.
  • net.minecraft.world.entity.Entity#setPortalCooldown: the entity that came
    through a portal does not go back through it for 300 ticks
    (Entity.getDimensionChangingDelay).
  • net.minecraft.server.level.ServerPlayer#teleport:
    if (!transition.asPassenger()) this.removeVehicle(); — a player that is a
    passenger keeps its vehicle, and the Respawn packet keeps all its data
    (KEEP_ALL_DATA).

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on cachyos-x8664, against upstream/main at 12e0094f1, 4 min 5 s)

Check Result
Scope ✅ 5 files, +208 −17
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 331 passed (19 s)
rustfmt ✅ (4 s)
clippy ✅ (56 s)
tests: horizon-client ✅ 1316 passed (2 min 13 s)
doc tests ✅ 0 passed (16 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 ➖ 74 affected, to run in CI (--quick): arrow, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, breaking_model, cauldron, command_exec, composter, crafter and 62 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
cargo fmt -p horizon-client (the tree is rustfmt-clean, so it only touched
what changed).

The focused test, with the fix:

$ cargo test -p horizon-client --bin horizon-client -- the_vehicle_a_player_rides_travels_with_it
   Compiling horizon-client v0.1.0 (/home/levzzz/horizon-wt/portal/crates/horizon-client)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 4.98s
     Running unittests src/main.rs (/home/levzzz/Documents/horizon/target/debug/deps/horizon_client-970bfd26dedebcd4)

running 1 test
test game::server_travel::tests::the_vehicle_a_player_rides_travels_with_it ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 125 filtered out; finished in 0.00s

The same test on the pre-fix code (4be5c8eb, the commit this branch starts
from), where the vehicle does not travel with its rider at all:

$ cargo test -p horizon-client --bin horizon-client -- the_vehicle_a_player_rides_travels_with_it
   Compiling horizon-client v0.1.0 (/home/levzzz/horizon-wt/portal/crates/horizon-client)
error[E0425]: cannot find function `take_vehicle` in this scope
   --> crates/horizon-client/src/game/server_travel.rs:508:20
    |
508 |         let boat = take_vehicle(&mut boats, 7, at, 90.0)
    |                    ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `take_vehicle` in this scope
   --> crates/horizon-client/src/game/server_travel.rs:515:17
    |
515 |         assert!(take_vehicle(&mut carts, 9, at, 0.0).is_none());
    |                 ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `take_vehicle` in this scope
   --> crates/horizon-client/src/game/server_travel.rs:517:17
    |
517 |         assert!(take_vehicle(&mut mobs, 9, at, 0.0).is_none());
    |                 ^^^^^^^^^^^^ not found in this scope

For more information about this error, try `rustc --explain E0425`.
error: could not compile `horizon-client` (bin "horizon-client" test) due to 3 previous errors

🤖 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/2691 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/portal-rider-travel` --- ### 📝 Commits (3) - [`33e81f4`](https://github.com/horizon-rust/horizon/commit/33e81f464ef138a17731b18967dd3839282a167a) Keep a rider with the vehicle it rides through a portal - [`44850bd`](https://github.com/horizon-rust/horizon/commit/44850bdd557c84f1fff31125a792b429648d2101) Merge upstream/main into the portal rider travel branch - [`7e68f1e`](https://github.com/horizon-rust/horizon/commit/7e68f1ed321622ff16629845f645e57bd312309d) Remove the duplicate rabbit arm in entity_nbt ### 📊 Changes **5 files changed** (+208 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+1 -4) 📝 `crates/horizon-client/src/game/lan_vehicles.rs` (+8 -0) 📝 `crates/horizon-client/src/game/levels.rs` (+26 -3) 📝 `crates/horizon-client/src/game/nether_portal.rs` (+16 -8) 📝 `crates/horizon-client/src/game/server_travel.rs` (+157 -2) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself. ## What and why On a server thread (a dedicated server, or single player on its server thread), a player who rode a horse into a Nether portal arrived in the Nether **on foot**: `/ride @s dismount` said the player was not riding anything. The horse and the rider travelled by two unrelated paths and the link between them broke: - the horse was a mob, so it went through the portal on its own, as an entity: it was saved to NBT, waited as an `Arrival` for the destination level, and was restored there **with a new entity id**; - the rider was a server player, so it travelled alone: the Respawn packet, the level swap and the teleport to the exit. The guest's `vehicle` still held the horse's old id, so the first tick after the arrival found no vehicle with that id in the new level, dropped the ride, and the rider stood next to a horse with a different id. Vanilla does not have that split: the vehicle travels with the passengers and the passengers ride it again in the other dimension. The fix makes the vehicle a server player rides travel with that player: - the animal a player rides is left out of the entity portal path (`mob_can_use_portal`), as vanilla leaves a passenger out (`Entity.canUsePortal(false)` is false for a passenger); it no longer goes through the portal on its own, so it is not duplicated and its id does not change; - the trip (`Trip`) now carries the vehicle the player rides and the level the player came from; when the trip arrives, the vehicle moves from that level to the destination level **with the same entity id**, stands where its rider arrives, and keeps its UUID and the compound it was loaded with, so it is saved as it was; - the vehicle that came through the portal does not go straight back through the exit portal (`Entity.setPortalCooldown`, 300 ticks). The ride is therefore never broken: the guest still holds the vehicle, the clients get the `SetPassengers` for the same vehicle id, and the player is still mounted when it arrives. Fixes #1486 ## Vanilla reference - `net.minecraft.world.entity.Entity#teleportCrossDimension` (26.3): the vehicle is recreated in the other dimension (`this.getType().create(newLevel, EntitySpawnReason.DIMENSION_TRAVEL)`, `newLevel.addDuringTeleport(newEntity)`), and every passenger is put back on it with `newPassenger.startRiding(newEntity, true, false)` — the passengers travel with the vehicle and ride it again. - `net.minecraft.world.entity.Entity#calculatePassengerTransition`: the passenger keeps its seat (its offset from the vehicle) and its rotation across the travel. - `net.minecraft.world.entity.Entity#canUsePortal`: `(ignorePassenger || !this.isPassenger()) && this.isAlive()` — a passenger does not use a portal on its own; the vehicle carries it. - `net.minecraft.world.level.block.NetherPortalBlock#entityInside`: `if (entity.canUsePortal(false)) entity.setAsInsidePortal(this, pos);` — only the vehicle gets a portal process. - `net.minecraft.world.level.block.NetherPortalBlock#getPortalTransitionTime`: the game rule delay for players, `0` for the other entities. - `net.minecraft.world.entity.Entity#handlePortal` / `#teleportToPortalDestination` / `#getDimensionChangingDelay`: the entity that goes through the portal is teleported to its destination. - `net.minecraft.world.entity.Entity#setPortalCooldown`: the entity that came through a portal does not go back through it for 300 ticks (`Entity.getDimensionChangingDelay`). - `net.minecraft.server.level.ServerPlayer#teleport`: `if (!transition.asPassenger()) this.removeVehicle();` — a player that is a passenger keeps its vehicle, and the Respawn packet keeps all its data (`KEEP_ALL_DATA`). ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on cachyos-x8664, against upstream/main at 12e0094f1, 4 min 5 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +208 −17 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 331 passed (19 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (56 s) | | tests: horizon-client | ✅ 1316 passed (2 min 13 s) | | doc tests | ✅ 0 passed (16 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 | ➖ 74 affected, to run in CI (--quick): arrow, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, breaking_model, cauldron, command_exec, composter, crafter and 62 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | `cargo fmt -p horizon-client` (the tree is rustfmt-clean, so it only touched what changed). The focused test, with the fix: ``` $ cargo test -p horizon-client --bin horizon-client -- the_vehicle_a_player_rides_travels_with_it Compiling horizon-client v0.1.0 (/home/levzzz/horizon-wt/portal/crates/horizon-client) Finished `test` profile [unoptimized + debuginfo] target(s) in 4.98s Running unittests src/main.rs (/home/levzzz/Documents/horizon/target/debug/deps/horizon_client-970bfd26dedebcd4) running 1 test test game::server_travel::tests::the_vehicle_a_player_rides_travels_with_it ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 125 filtered out; finished in 0.00s ``` The same test on the pre-fix code (`4be5c8eb`, the commit this branch starts from), where the vehicle does not travel with its rider at all: ``` $ cargo test -p horizon-client --bin horizon-client -- the_vehicle_a_player_rides_travels_with_it Compiling horizon-client v0.1.0 (/home/levzzz/horizon-wt/portal/crates/horizon-client) error[E0425]: cannot find function `take_vehicle` in this scope --> crates/horizon-client/src/game/server_travel.rs:508:20 | 508 | let boat = take_vehicle(&mut boats, 7, at, 90.0) | ^^^^^^^^^^^^ not found in this scope error[E0425]: cannot find function `take_vehicle` in this scope --> crates/horizon-client/src/game/server_travel.rs:515:17 | 515 | assert!(take_vehicle(&mut carts, 9, at, 0.0).is_none()); | ^^^^^^^^^^^^ not found in this scope error[E0425]: cannot find function `take_vehicle` in this scope --> crates/horizon-client/src/game/server_travel.rs:517:17 | 517 | assert!(take_vehicle(&mut mobs, 9, at, 0.0).is_none()); | ^^^^^^^^^^^^ not found in this scope For more information about this error, try `rustc --explain E0425`. error: could not compile `horizon-client` (bin "horizon-client" test) due to 3 previous errors ``` 🤖 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 04:17:58 +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#4545
No description provided.