[PR #6918] [MERGED] Native mods: ender pearl and chorus fruit teleports (cancel, retarget) #7194

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

📋 Pull Request Information

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

Base: main ← Head: native/pearl-chorus-teleport


📝 Commits (2)

  • 2c8033a Native mods: ender pearl and chorus fruit teleports (cancel, retarget)
  • ebb131c Native teleport hooks: ignore non-finite targets, keep chorus y in the level

📊 Changes

8 files changed (+424 additions, -13 deletions)

View changed files

📝 crates/horizon-client/src/game/consume.rs (+27 -0)
📝 crates/horizon-client/src/game/creatures.rs (+29 -4)
📝 crates/horizon-client/src/game/native_hooks.rs (+64 -3)
📝 crates/horizon-client/src/mod_api/generated.rs (+125 -3)
📝 crates/horizon-world/src/teleport_consume.rs (+130 -1)
📝 docs/native-mods.md (+15 -2)
➕ tools/native-hook-fragments/chorus_fruit_teleport.json (+17 -0)
➕ tools/native-hook-fragments/ender_pearl_teleport.json (+17 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally.

Part of #4953: NeoForge's EntityTeleportEvent.EnderPearl and EntityTeleportEvent.ChorusFruit, for server players.

What

native_ender_pearl_teleport(player, name, pearl, from, target, damage, cancel) (server, cancel). Fires when a server player's ender pearl lands (vanilla ThrownEnderpearl.onHit), before the endermite roll and the teleport.

  • pearl is the pearl's entity id, the same id native_projectile_impact uses.
  • from is the player's feet, and target is where the pearl started its last tick (vanilla oldPosition).
  • damage is the fall damage (5); 0 or less means no damage.
  • A mod may move target (a non-finite target is ignored) or change damage.
  • Canceling keeps the player where they are: no endermite roll, teleport, damage or sound. The pearl is used up either way.

native_chorus_fruit_teleport(player, name, from, target, cancel) (server, cancel). Fires on each attempt of the teleport_randomly consume effect (vanilla TeleportRandomlyConsumeEffect.apply, up to 16 attempts), after the three draws and after the player stops riding.

  • A mod may move target. Its y is kept inside the level's height, and a non-finite target is ignored. The game still looks down from the target for ground to land on.
  • Canceling ends the effect: no teleport and no further attempts.

To support this, TeleportConsumeWorld (horizon-world) gains a default teleport_allowed method. Foxes and the teleport_consume parity probe keep vanilla's draws unchanged. Neither hook fires on a pure client, and both are gated on the acting server player (lan_acting_uuid).

Not covered (documented): mobs' pearls, and foxes eating chorus fruit. Endermen teleports are still open on the tracker. The native_player_teleported docs now point to the new hooks.

Tests

  • Real game, server thread and dedicated server, using a throwaway trait mod (not committed) driven by horizon-ctl in a private nested KWin. The player is in survival with 20 health and throws pearls straight down. The mod cancels the first pearl, and on the second sets target = from + (4, 0, 0) with damage = 0. It cancels the first chorus attempt, and on the second chorus fruit sets target = from + (20, 2, 0).
    • single player (server thread):
      • canceled pearl: no move, health 20 → 20
      • retargeted pearl: moved exactly +4 x, health 20 → 20
      • canceled chorus: no move, fruit eaten
      • retargeted chorus: landed at exactly +20 x on the ground
      • hook counts: pearl 2, chorus 2. PASS
    • dedicated server: the same five results. PASS
  • New unit tests in horizon-world teleport_consume::tests:
    • a refused attempt ends the effect with no further tries
    • the mod's target is where the user tries to land
    • with no mod, all 16 attempts run
  • python3 tools/pr_ready.py --quick --base hr/main: everything passes (610 Python tests, rustfmt, clippy, 2427 tests across horizon-client/-lib/-world, mod API check).
  • An independent Opus review found no correctness blockers. Its hardening note (a non-finite or huge mod target could hang the chorus walk-down) is fixed in the second commit. The e2e ran before that commit; it only changes out-of-range and non-finite targets, and clippy and the mod API check were re-run after it.
  • Not run: parity harnesses (--quick; CI picks them, teleport_consume among them).

Older gaps the review noticed, not changed here: Horizon's pearl does not check that the owner is alive and not sleeping (vanilla isAllowedToTeleportOwner); and a pearl whose guest has left falls back to the host's player. In the second case the hook stays silent.

🤖 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/6918 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `native/pearl-chorus-teleport` --- ### 📝 Commits (2) - [`2c8033a`](https://github.com/horizon-rust/horizon/commit/2c8033a9949a3ebb50273c884106f2ec4269c6fe) Native mods: ender pearl and chorus fruit teleports (cancel, retarget) - [`ebb131c`](https://github.com/horizon-rust/horizon/commit/ebb131c40c49f337b0d7ba09b1031e5361519148) Native teleport hooks: ignore non-finite targets, keep chorus y in the level ### 📊 Changes **8 files changed** (+424 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/consume.rs` (+27 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+29 -4) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+64 -3) 📝 `crates/horizon-client/src/mod_api/generated.rs` (+125 -3) 📝 `crates/horizon-world/src/teleport_consume.rs` (+130 -1) 📝 `docs/native-mods.md` (+15 -2) ➕ `tools/native-hook-fragments/chorus_fruit_teleport.json` (+17 -0) ➕ `tools/native-hook-fragments/ender_pearl_teleport.json` (+17 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally. Part of #4953: NeoForge's `EntityTeleportEvent.EnderPearl` and `EntityTeleportEvent.ChorusFruit`, for server players. ## What **`native_ender_pearl_teleport(player, name, pearl, from, target, damage, cancel)`** (server, `cancel`). Fires when a server player's ender pearl lands (vanilla `ThrownEnderpearl.onHit`), before the endermite roll and the teleport. - `pearl` is the pearl's entity id, the same id `native_projectile_impact` uses. - `from` is the player's feet, and `target` is where the pearl started its last tick (vanilla `oldPosition`). - `damage` is the fall damage (5); 0 or less means no damage. - A mod may move `target` (a non-finite target is ignored) or change `damage`. - Canceling keeps the player where they are: no endermite roll, teleport, damage or sound. The pearl is used up either way. **`native_chorus_fruit_teleport(player, name, from, target, cancel)`** (server, `cancel`). Fires on each attempt of the `teleport_randomly` consume effect (vanilla `TeleportRandomlyConsumeEffect.apply`, up to 16 attempts), after the three draws and after the player stops riding. - A mod may move `target`. Its y is kept inside the level's height, and a non-finite target is ignored. The game still looks down from the target for ground to land on. - Canceling ends the effect: no teleport and no further attempts. To support this, `TeleportConsumeWorld` (horizon-world) gains a default `teleport_allowed` method. Foxes and the `teleport_consume` parity probe keep vanilla's draws unchanged. Neither hook fires on a pure client, and both are gated on the acting server player (`lan_acting_uuid`). Not covered (documented): mobs' pearls, and foxes eating chorus fruit. Endermen teleports are still open on the tracker. The `native_player_teleported` docs now point to the new hooks. ## Tests - **Real game, server thread and dedicated server**, using a throwaway trait mod (not committed) driven by horizon-ctl in a private nested KWin. The player is in survival with 20 health and throws pearls straight down. The mod cancels the first pearl, and on the second sets target = from + (4, 0, 0) with `damage = 0`. It cancels the first chorus attempt, and on the second chorus fruit sets target = from + (20, 2, 0). - single player (server thread): - canceled pearl: no move, health 20 → 20 - retargeted pearl: moved exactly +4 x, health 20 → 20 - canceled chorus: no move, fruit eaten - retargeted chorus: landed at exactly +20 x on the ground - hook counts: pearl 2, chorus 2. **PASS** - dedicated server: the same five results. **PASS** - New unit tests in `horizon-world` `teleport_consume::tests`: - a refused attempt ends the effect with no further tries - the mod's target is where the user tries to land - with no mod, all 16 attempts run - `python3 tools/pr_ready.py --quick --base hr/main`: everything passes (610 Python tests, rustfmt, clippy, 2427 tests across horizon-client/-lib/-world, mod API check). - An independent Opus review found no correctness blockers. Its hardening note (a non-finite or huge mod target could hang the chorus walk-down) is fixed in the second commit. The e2e ran before that commit; it only changes out-of-range and non-finite targets, and clippy and the mod API check were re-run after it. - Not run: parity harnesses (`--quick`; CI picks them, `teleport_consume` among them). Older gaps the review noticed, not changed here: Horizon's pearl does not check that the owner is alive and not sleeping (vanilla `isAllowedToTeleportOwner`); and a pearl whose guest has left falls back to the host's player. In the second case the hook stays silent. 🤖 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:35: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#7194
No description provided.