[PR #7108] [MERGED] Mobs stop at the world border, endermen teleport inside it #7346

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

📋 Pull Request Information

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

Base: main ← Head: fix/7080-mob-world-border


📝 Commits (2)

  • 9e78d07 Mobs stop at the world border
  • df7f4fb Endermen teleport inside the world border

📊 Changes

8 files changed (+145 additions, -2 deletions)

View changed files

📝 crates/horizon-client-render/src/collisions.rs (+30 -0)
📝 crates/horizon-client/examples/probe/mob_ai_probe.rs (+1 -0)
📝 crates/horizon-client/src/game/creatures.rs (+2 -0)
📝 crates/horizon-client/src/mobs.rs (+3 -0)
📝 crates/horizon-client/src/mobs/enderman.rs (+60 -0)
📝 crates/horizon-client/src/mobs/living.rs (+47 -2)
📝 crates/horizon-client/src/mobs/world.rs (+1 -0)
📝 crates/horizon-client/src/mobs/zombie_villager.rs (+1 -0)

📄 Description

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

Refs #7080

What was wrong

Entity.collide builds its colliders with Entity.collectColliders, which adds WorldBorder.getCollisionShape for any entity inside and close to the border (isInsideCloseToBorder; read with javap on the 26.3 server jar). Mob::do_move resolved a mob's moves against the blocks alone, so every mob walked through the border.

Endermen: Enderman.teleport(x, y, z) goes through LivingEntity.randomTeleport, which clamps the target with WorldBorder.clampVec3ToBound (Mth.clamp to [min, max - 1.0E-5F] on x and z) before looking for ground. Horizon's enderman::teleport_to skipped the clamp, so an enderman could land outside the border. (checkPositionAndTeleport then uses the entity-less Level.noCollision(AABB), so no border collision test there; nothing added for it.)

What changed

Two commits, one per mechanism:

  1. Mobs stop at the world border. MobWorld carries the level's border (Game::mob_world_base fills it from self.border.geometry(), test worlds pass None). Mob::do_move resolves through the new SceneCollisions::resolve_in_border, which wraps the scene in EntityCollisions with the border and keeps the mob's own collision context (lava walkers).
  2. Endermen teleport inside the world border. teleport_to clamps x and z into the border as clampVec3ToBound does, after the passenger check (Enderman.teleport's order).

Not in this PR (same cause, other paths): item entities, experience orbs and falling blocks in entities.rs still collide with border: None; passing the border there goes through game.rs callers and is left for a follow-up. Hence Refs, not Fixes.

How it was checked

Unit tests with expected values from the border geometry, not from the code under test:

  • mobs::living::tests::the_world_border_stops_a_mob: a pig at x = 11.5 moving 1.5 east, border of size 10 around (8, 8) (east wall at 13). Without a border its box ends past 13; with it, its east side stops at 13 and horizontal_collision is set.
  • mobs::enderman::tests::an_enderman_teleports_inside_the_world_border: border of size 10 around the origin, teleport to (20.5, 0, -20.5) lands at (5 - 1.0E-5F, 0, -5); without a border it lands at the target.

Not checked in game (no live reproduction run); no change to the client or server split.

Self-check

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

Check Result
Scope 8 files, +145 −2
Cargo.lock unchanged
rustfmt, clippy ✅
tests: horizon-client, horizon-client-lib, horizon-client-render 3224 passed, 1 failed: gfx::entity_skin::tests::the_shader_writes_what_the_cpu_reference_computes (a 1-ulp float difference from this machine's GPU; this PR touches no gfx code)
mod API up to date ✅
Python tests 1 error from my machine's setup, untouched here
Parity not run (--quick): the CI parity job picks the affected harnesses

🤖 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/7108 **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/7080-mob-world-border` --- ### 📝 Commits (2) - [`9e78d07`](https://github.com/horizon-rust/horizon/commit/9e78d076c4ce9bc76d73013aa4bd63a96675dcf1) Mobs stop at the world border - [`df7f4fb`](https://github.com/horizon-rust/horizon/commit/df7f4fbd7c20b945e0423a98cbc6d327da5d8913) Endermen teleport inside the world border ### 📊 Changes **8 files changed** (+145 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/collisions.rs` (+30 -0) 📝 `crates/horizon-client/examples/probe/mob_ai_probe.rs` (+1 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+2 -0) 📝 `crates/horizon-client/src/mobs.rs` (+3 -0) 📝 `crates/horizon-client/src/mobs/enderman.rs` (+60 -0) 📝 `crates/horizon-client/src/mobs/living.rs` (+47 -2) 📝 `crates/horizon-client/src/mobs/world.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs/zombie_villager.rs` (+1 -0) </details> ### 📄 Description > 🤖 Opened by both Akirabane's AI agent (Claude Code), and Akirabane Himself after his review. Refs #7080 ## What was wrong `Entity.collide` builds its colliders with `Entity.collectColliders`, which adds `WorldBorder.getCollisionShape` for any entity inside and close to the border (`isInsideCloseToBorder`; read with `javap` on the 26.3 server jar). `Mob::do_move` resolved a mob's moves against the blocks alone, so every mob walked through the border. Endermen: `Enderman.teleport(x, y, z)` goes through `LivingEntity.randomTeleport`, which clamps the target with `WorldBorder.clampVec3ToBound` (`Mth.clamp` to `[min, max - 1.0E-5F]` on x and z) before looking for ground. Horizon's `enderman::teleport_to` skipped the clamp, so an enderman could land outside the border. (`checkPositionAndTeleport` then uses the entity-less `Level.noCollision(AABB)`, so no border collision test there; nothing added for it.) ## What changed Two commits, one per mechanism: 1. **Mobs stop at the world border.** `MobWorld` carries the level's border (`Game::mob_world_base` fills it from `self.border.geometry()`, test worlds pass `None`). `Mob::do_move` resolves through the new `SceneCollisions::resolve_in_border`, which wraps the scene in `EntityCollisions` with the border and keeps the mob's own collision context (lava walkers). 2. **Endermen teleport inside the world border.** `teleport_to` clamps x and z into the border as `clampVec3ToBound` does, after the passenger check (`Enderman.teleport`'s order). Not in this PR (same cause, other paths): item entities, experience orbs and falling blocks in `entities.rs` still collide with `border: None`; passing the border there goes through `game.rs` callers and is left for a follow-up. Hence `Refs`, not `Fixes`. ## How it was checked Unit tests with expected values from the border geometry, not from the code under test: - `mobs::living::tests::the_world_border_stops_a_mob`: a pig at x = 11.5 moving 1.5 east, border of size 10 around (8, 8) (east wall at 13). Without a border its box ends past 13; with it, its east side stops at 13 and `horizontal_collision` is set. - `mobs::enderman::tests::an_enderman_teleports_inside_the_world_border`: border of size 10 around the origin, teleport to (20.5, 0, -20.5) lands at (5 - 1.0E-5F, 0, -5); without a border it lands at the target. Not checked in game (no live reproduction run); no change to the client or server split. ## Self-check `tools/pr_ready.py --quick --base origin/main`: | Check | Result | | --- | --- | | Scope | 8 files, +145 −2 | | Cargo.lock | unchanged | | rustfmt, clippy | ✅ | | tests: horizon-client, horizon-client-lib, horizon-client-render | 3224 passed, 1 failed: `gfx::entity_skin::tests::the_shader_writes_what_the_cpu_reference_computes` (a 1-ulp float difference from this machine's GPU; this PR touches no `gfx` code) | | mod API up to date | ✅ | | Python tests | 1 error from my machine's setup, untouched here | | Parity | not run (`--quick`): the CI parity job picks the affected harnesses | 🤖 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:03 +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#7346
No description provided.