Mod API entries and dispatch calls for #6547's hooks

Main requires a mod_api entry for every pending fragment since #6253;
cargo run -p xtask -- mod-api filled the dispatch calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Ludovic MarieandClaude Opus 5.5 committed 2026-11-02 07:41:36 +01:00
1 parent e3274bed46
commit 59823928da
3 files changed
+57 -2

No files matched your search

@@ -2824,7 +2824,15 @@ impl Game<'_> {
to: [f64; 3],
dimension: &str,
) {
let _ = (player, name, from, to, dimension);
mod_api::dispatch_player_teleported(
self,
mod_api::mods(),
player,
name,
from,
to,
dimension,
);
}
/// A server player's fishing rod, with `state`: 0 the cast
/// (`FishingRodItem.use` throwing the bobber), 1 a fish biting
+44
View File
@@ -2695,6 +2695,21 @@ pub trait Hooks: Send + Sync {
let _ = event;
Flow::Continue
}
/// A server player a command teleported (NeoForge's
/// `EntityTeleportEvent`, for a player): `/tp` and `/teleport`, inside
/// their level or into another one. `from` and `to` are their feet before
/// and after, `dimension` the level they are in now. Heard after the move
/// has reached the player's state and their client (an inter-level
/// teleport: when the new level is entered, before it has loaded around
/// them), so it cannot stop it. The player's state is swapped in, so the
/// helpers that read the acting player and `native_tell` work. Once for
/// each teleported player, on a server. Other teleports are not heard
/// yet: ender pearls, chorus fruit, a spectator's teleport menu; portals
/// and respawns are not teleports here. @API:native_player_teleported@.
fn player_teleported(&self, host: &mut dyn Host, event: &mut PlayerTeleportedEvent<'_>) {
let _ = host;
let _ = event;
}
}
/// What [`Hooks::frame`] is told. Fields may be added: the struct is `#[non_exhaustive]`.
#[non_exhaustive]
@@ -7425,3 +7440,32 @@ pub fn dispatch_player_swap_hands(
}
}
}
/// What [`Hooks::player_teleported`] is told. Fields may be added: the struct is `#[non_exhaustive]`.
#[non_exhaustive]
pub struct PlayerTeleportedEvent<'a> {
pub player: u128,
pub name: &'a str,
pub from: [f64; 3],
pub to: [f64; 3],
pub dimension: &'a str,
}
pub fn dispatch_player_teleported(
host: &mut dyn Host,
mods: &[Box<dyn Hooks>],
player: u128,
name: &str,
from: [f64; 3],
to: [f64; 3],
dimension: &str,
) {
let mut event = PlayerTeleportedEvent {
player,
name,
from,
to,
dimension,
};
for mod_hook in mods {
mod_hook.player_teleported(host, &mut event);
}
}
@@ -4,7 +4,10 @@
"name": "player_teleported",
"target": "horizon_client::game::native_hooks::Game<'_>::native_player_teleported",
"neoforge": "none (EntityTeleportEvent.TeleportCommand fires before the move and can cancel it; this hook is told after the move)",
"side": "server"
"side": "server",
"mod_api": {
"contract": "listen"
}
}
],
"rust_summary": "a server player teleported by a command (`native_player_teleported`).",