mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-10 02:21:33 -10:00
Native teleport hooks: ignore non-finite targets, keep chorus y in the level
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
2c8033a994
commit
ebb131c40c
5 files changed
+25
-9
No files matched your search
@@ -327,7 +327,15 @@ impl TeleportConsumeWorld for Teleporter<'_, '_> {
|
||||
&mut to,
|
||||
&mut cancel,
|
||||
);
|
||||
*target = Vec3::new(to[0], to[1], to[2]);
|
||||
// Keep the mod's spot inside the level as vanilla's own draw is (a
|
||||
// huge y would walk down a long way); one that is not a number keeps
|
||||
// the draw.
|
||||
if to.iter().all(|v| v.is_finite()) {
|
||||
let shape = self.0.level_shapes.get(self.0.dim.id());
|
||||
let high = shape.min_y + shape.logical_height - 1;
|
||||
let y = to[1].clamp(f64::from(shape.min_y), f64::from(high));
|
||||
*target = Vec3::new(to[0], y, to[2]);
|
||||
}
|
||||
Ok(!cancel)
|
||||
}
|
||||
fn random_teleport(&mut self, target: Vec3) -> Result<bool, Infallible> {
|
||||
|
||||
@@ -4531,7 +4531,10 @@ impl Game<'_> {
|
||||
&mut damage,
|
||||
&mut cancel,
|
||||
);
|
||||
to = Vec3::new(target[0], target[1], target[2]);
|
||||
// A target that is not a number keeps the pearl's.
|
||||
if target.iter().all(|v| v.is_finite()) {
|
||||
to = Vec3::new(target[0], target[1], target[2]);
|
||||
}
|
||||
}
|
||||
if p.owner == Some(Who::Player) && self.player.is_some() && !cancel {
|
||||
// ThrownEnderpearl: 5% endermite where the player was
|
||||
|
||||
@@ -3175,7 +3175,8 @@ impl Game<'_> {
|
||||
/// `ThrownEnderpearl.onHit` for a player owner): `pearl` is the pearl's
|
||||
/// entity id, `from` their feet now, `target` where the pearl started
|
||||
/// its last tick and `damage` the fall damage they then take (5). A mod
|
||||
/// may move `target` or change `damage` (0 or less: none). Canceling
|
||||
/// may move `target` (a value that is not a number is ignored) or change
|
||||
/// `damage` (0 or less: none). Canceling
|
||||
/// keeps the player where they are: no endermite roll, no teleport, no
|
||||
/// damage and no sound; the pearl is used up either way. The player's
|
||||
/// state is swapped in (`native_acting_player`). The hit itself is
|
||||
@@ -3207,8 +3208,9 @@ impl Game<'_> {
|
||||
/// (NeoForge's `EntityTeleportEvent.ChorusFruit`, vanilla's
|
||||
/// `TeleportRandomlyConsumeEffect.apply`): once per attempt (up to 16),
|
||||
/// after they stopped riding. `from` is their feet, `target` the spot
|
||||
/// drawn; a mod may move it, and the game still looks down from it for
|
||||
/// ground it may land on. Canceling ends the effect: no teleport and no
|
||||
/// drawn; a mod may move it (its y kept inside the level's height, a
|
||||
/// value that is not a number ignored), and the game still looks down
|
||||
/// from it for ground it may land on. Canceling ends the effect: no teleport and no
|
||||
/// more attempts. The player's state is swapped in
|
||||
/// (`native_acting_player`). Foxes are not heard. @API:chorus_fruit_teleport@.
|
||||
pub(super) fn native_chorus_fruit_teleport(
|
||||
|
||||
+5
-3
@@ -2634,8 +2634,9 @@ pub trait Hooks: Send + Sync {
|
||||
/// (NeoForge's `EntityTeleportEvent.ChorusFruit`, vanilla's
|
||||
/// `TeleportRandomlyConsumeEffect.apply`): once per attempt (up to 16),
|
||||
/// after they stopped riding. `from` is their feet, `target` the spot
|
||||
/// drawn; a mod may move it, and the game still looks down from it for
|
||||
/// ground it may land on. Canceling ends the effect: no teleport and no
|
||||
/// drawn; a mod may move it (its y kept inside the level's height, a
|
||||
/// value that is not a number ignored), and the game still looks down
|
||||
/// from it for ground it may land on. Canceling ends the effect: no teleport and no
|
||||
/// more attempts. The player's state is swapped in
|
||||
/// (`native_acting_player`). Foxes are not heard. @API:chorus_fruit_teleport@.
|
||||
///
|
||||
@@ -2699,7 +2700,8 @@ pub trait Hooks: Send + Sync {
|
||||
/// `ThrownEnderpearl.onHit` for a player owner): `pearl` is the pearl's
|
||||
/// entity id, `from` their feet now, `target` where the pearl started
|
||||
/// its last tick and `damage` the fall damage they then take (5). A mod
|
||||
/// may move `target` or change `damage` (0 or less: none). Canceling
|
||||
/// may move `target` (a value that is not a number is ignored) or change
|
||||
/// `damage` (0 or less: none). Canceling
|
||||
/// keeps the player where they are: no endermite roll, no teleport, no
|
||||
/// damage and no sound; the pearl is used up either way. The player's
|
||||
/// state is swapped in (`native_acting_player`). The hit itself is
|
||||
|
||||
+2
-1
@@ -1421,7 +1421,8 @@ For mods that run where the world is simulated: a dedicated server, a LAN host,
|
||||
- **`native_chorus_fruit_teleport(player, name, from, target, cancel)`**: a server player whose `teleport_randomly`
|
||||
consume effect (chorus fruit) is about to try a spot (NeoForge's `EntityTeleportEvent.ChorusFruit`,
|
||||
`TeleportRandomlyConsumeEffect.apply`): once per attempt, up to 16, after they stopped riding. A mod may move
|
||||
`target`; the game still looks down from it for ground to land on, inside the border. Canceling ends the effect: no
|
||||
`target` (its y is kept inside the level's height); the game still looks down from it for ground to land on, inside
|
||||
the border. Canceling ends the effect: no
|
||||
teleport and no more attempts. Foxes eating chorus fruit are not heard. Bundles need
|
||||
`"hooks": @API:chorus_fruit_teleport@`.
|
||||
- **`native_player_commands_sent(player, name, names)`**: the command tree a player is sent, when they join and when
|
||||
|
||||
Reference in new issue
Block a user