[PR #7148] [MERGED] Ender pearls and other projectiles stop at the world border #7375

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7148
Author: @Akirabane
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/7078-pearl-chorus-border


📝 Commits (4)

  • 71a70d9 Projectiles stop at the world border, so ender pearls no longer cross it
  • 5d896c0 Test that a pearl stops on the world border
  • 77215da Merge remote-tracking branch 'origin/main' into fix/7078-pearl-chorus-border
  • 71b3233 Merge remote-tracking branch 'origin/main' into fix/7078-pearl-chorus-border

📊 Changes

5 files changed (+149 additions, -10 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+24 -8)
📝 crates/horizon-client/src/game/fireworks.rs (+1 -0)
📝 crates/horizon-client/src/game/native_projectiles.rs (+5 -1)
📝 crates/horizon-client/src/game/remote_projectiles.rs (+1 -0)
📝 crates/horizon-client/src/projectiles.rs (+118 -1)

📄 Description

🤖 Opened by both Akirabane's AI agent (Claude Code), and Akirabane Himself after his review.

Fixes #7078

What was wrong

A projectile's ray (ProjWorld::clip) only met blocks, so a pearl thrown at the world border flew through it, landed outside and teleported its thrower there. In vanilla 26.3 every flying projectile clips through CollisionGetter.clipIncludingBorder (ProjectileUtil.getHitResultOnMoveVector, used by ThrowableProjectile, AbstractHurtingProjectile, ShulkerBullet, LlamaSpit and FireworkRocketEntity). A ray that starts inside the border and would end or hit a block outside it stops on the border. Projectile.hitTargetOrDeflectSelf then calls onHit, and ThrownEnderpearl.onHit teleports the owner to oldPosition(), which is inside.

What changed

  • projectiles::clip_including_border ports clipIncludingBorder from the class file. It runs only when from is within bounds (WorldBorder.isWithinBounds, far edges outside) and the hit, or to on a miss, is not. The new hit sits at WorldBorder.clampVec3ToBound of that point (Mth.clamp, maxX/maxZ - 1.0E-5F), its block is BlockPos.containing, and its face is Direction.getApproximateNearest of the travel.
  • ProjWorld now carries the border's bounds and applies the function to its block clip. The server tick, rockets, mod-cancelled impacts and the client's own projectile ticks pass self.border.bounds(), as a vanilla client level has its border too. The field lives on ProjWorld, not MobWorld, to stay clear of the mob border work for #7080.
  • Not covered: arrows and tridents (arrows::tick) still ignore the border. In vanilla they bounce off it (AbstractArrow.shouldBounceOnWorldBorder), which is a separate behaviour; same for fishing hooks.

Vanilla read (javap of the pinned 26.3 server-game.jar): CollisionGetter.clipIncludingBorder, ProjectileUtil.getHitResult, ThrowableProjectile.tick, Projectile.hitTargetOrDeflectSelf / shouldBounceOnWorldBorder, ThrownEnderpearl.onHit, WorldBorder.isWithinBounds / clampVec3ToBound, Direction.getApproximateNearest. No other code read.

How it was checked

  • In game (horizon-ctl, offscreen, creative, /worldborder center 0 0, /worldborder set 10, so x and z run from -4.5 to 5.5):
    • main 0c027235c: from (3.5, 68, 0.5), a pearl thrown east lands the player at x = 37.6, outside.
    • this branch: pearls thrown east, east and steeper, south, north, west and diagonally from (3.5, 68, 3.5) all leave the player inside, for example (4.91, 68, 3.49) and (-3.33, 68, 3.43).
  • Unit tests in projectiles.rs. Their expected values come from the class file, not from the code under test (the 9.999999747378752E-6 inset is the constant clampVec3ToBound holds):
    • a pearl thrown at the border stops on it, facing east, with its oldPosition inside;
    • each axis clamps on its own, and maxX itself counts as outside;
    • inner block hits, rays that stay inside and rays from outside are left alone.

#7083 (chorus fruit) was looked at with this one and already matches vanilla (see the comment there), so this PR does not touch it.

Self-check

python3 tools/pr_ready.py --quick --base origin/main:

Check Result
Scope ✅ 5 files, +149 −10
Cargo.lock ✅ unchanged
Public tree ✅
rustfmt ✅
clippy ✅
tests: horizon-client, horizon-client-lib ✅ 2081 passed
mod API up to date ✅ 17 passed (re-run after merging the newer main; the first run was against a main that had moved mid-check)
Python tests ❌ local only: tests/test_port_ledger.py cannot import tests.test_class_index under unittest discover -s tests on this Windows machine; no Python file is touched here
Parity ➖ not run (--quick)

🤖 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/7148 **Author:** [@Akirabane](https://github.com/Akirabane) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/7078-pearl-chorus-border` --- ### 📝 Commits (4) - [`71a70d9`](https://github.com/horizon-rust/horizon/commit/71a70d923331aeff779da35c4bf1a73a6f6fff45) Projectiles stop at the world border, so ender pearls no longer cross it - [`5d896c0`](https://github.com/horizon-rust/horizon/commit/5d896c047138652620bd1d66d1e9d07ece1b40e4) Test that a pearl stops on the world border - [`77215da`](https://github.com/horizon-rust/horizon/commit/77215da03961ccc25008fb0b8b2bd61bc4346811) Merge remote-tracking branch 'origin/main' into fix/7078-pearl-chorus-border - [`71b3233`](https://github.com/horizon-rust/horizon/commit/71b32333ef8f986baa451e765abdcd1dc5b4c0e3) Merge remote-tracking branch 'origin/main' into fix/7078-pearl-chorus-border ### 📊 Changes **5 files changed** (+149 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+24 -8) 📝 `crates/horizon-client/src/game/fireworks.rs` (+1 -0) 📝 `crates/horizon-client/src/game/native_projectiles.rs` (+5 -1) 📝 `crates/horizon-client/src/game/remote_projectiles.rs` (+1 -0) 📝 `crates/horizon-client/src/projectiles.rs` (+118 -1) </details> ### 📄 Description > 🤖 Opened by both Akirabane's AI agent (Claude Code), and Akirabane Himself after his review. Fixes #7078 ## What was wrong A projectile's ray (`ProjWorld::clip`) only met blocks, so a pearl thrown at the world border flew through it, landed outside and teleported its thrower there. In vanilla 26.3 every flying projectile clips through `CollisionGetter.clipIncludingBorder` (`ProjectileUtil.getHitResultOnMoveVector`, used by `ThrowableProjectile`, `AbstractHurtingProjectile`, `ShulkerBullet`, `LlamaSpit` and `FireworkRocketEntity`). A ray that starts inside the border and would end or hit a block outside it stops on the border. `Projectile.hitTargetOrDeflectSelf` then calls `onHit`, and `ThrownEnderpearl.onHit` teleports the owner to `oldPosition()`, which is inside. ## What changed - `projectiles::clip_including_border` ports `clipIncludingBorder` from the class file. It runs only when `from` is within bounds (`WorldBorder.isWithinBounds`, far edges outside) and the hit, or `to` on a miss, is not. The new hit sits at `WorldBorder.clampVec3ToBound` of that point (`Mth.clamp`, `maxX/maxZ - 1.0E-5F`), its block is `BlockPos.containing`, and its face is `Direction.getApproximateNearest` of the travel. - `ProjWorld` now carries the border's bounds and applies the function to its block clip. The server tick, rockets, mod-cancelled impacts and the client's own projectile ticks pass `self.border.bounds()`, as a vanilla client level has its border too. The field lives on `ProjWorld`, not `MobWorld`, to stay clear of the mob border work for #7080. - Not covered: arrows and tridents (`arrows::tick`) still ignore the border. In vanilla they bounce off it (`AbstractArrow.shouldBounceOnWorldBorder`), which is a separate behaviour; same for fishing hooks. Vanilla read (javap of the pinned 26.3 `server-game.jar`): `CollisionGetter.clipIncludingBorder`, `ProjectileUtil.getHitResult`, `ThrowableProjectile.tick`, `Projectile.hitTargetOrDeflectSelf` / `shouldBounceOnWorldBorder`, `ThrownEnderpearl.onHit`, `WorldBorder.isWithinBounds` / `clampVec3ToBound`, `Direction.getApproximateNearest`. No other code read. ## How it was checked - In game (`horizon-ctl`, offscreen, creative, `/worldborder center 0 0`, `/worldborder set 10`, so x and z run from -4.5 to 5.5): - main `0c027235c`: from (3.5, 68, 0.5), a pearl thrown east lands the player at **x = 37.6**, outside. - this branch: pearls thrown east, east and steeper, south, north, west and diagonally from (3.5, 68, 3.5) all leave the player inside, for example (4.91, 68, 3.49) and (-3.33, 68, 3.43). - Unit tests in `projectiles.rs`. Their expected values come from the class file, not from the code under test (the `9.999999747378752E-6` inset is the constant `clampVec3ToBound` holds): - a pearl thrown at the border stops on it, facing east, with its `oldPosition` inside; - each axis clamps on its own, and `maxX` itself counts as outside; - inner block hits, rays that stay inside and rays from outside are left alone. #7083 (chorus fruit) was looked at with this one and already matches vanilla (see the comment there), so this PR does not touch it. ## Self-check `python3 tools/pr_ready.py --quick --base origin/main`: | Check | Result | | --- | --- | | Scope | ✅ 5 files, +149 −10 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client, horizon-client-lib | ✅ 2081 passed | | mod API up to date | ✅ 17 passed (re-run after merging the newer main; the first run was against a main that had moved mid-check) | | Python tests | ❌ local only: `tests/test_port_ledger.py` cannot import `tests.test_class_index` under `unittest discover -s tests` on this Windows machine; no Python file is touched here | | Parity | ➖ not run (--quick) | 🤖 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 06:38:34 +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#7375
No description provided.