Skip to content

Minecraft: Java Edition 26.3 rewritten from scratch in Rust, checked against vanilla with 281 differential harnesses. Get it with the Horizon launcher.

Merge main into #6307

Ludovic Marie1e1d41e588ca
diff --cc crates/horizon-client/src/game/native_hooks.rs
index ccc1760e9,fd5a9f446..b355770b8
--- a/crates/horizon-client/src/game/native_hooks.rs
+++ b/crates/horizon-client/src/game/native_hooks.rs
@@@ -2582,27 -2582,33 +2582,54 @@@ impl Game<'_>
) {
let _ = (player, command, ran);
}
+ /// A server player's game mode is about to change (NeoForge's
+ /// `PlayerChangeGameModeEvent`): from `from` to `to` (0 survival, 1
+ /// creative, 2 adventure, 3 spectator, as `NativeServerPlayer`'s
+ /// `game_mode`), `player` being the UUID and `name` the name. Heard for
+ /// the `/gamemode` command, the F3+F4 switcher's packet and a hardcore
+ /// world's respawn into spectator, once for each change to a different
+ /// mode; not for the world's default mode a player joins with. Set
+ /// `cancel` and the player keeps their mode (nothing is sent, the
+ /// command counts it as no change). For a change the game makes inside
+ /// a player's turn their state is swapped in; for the hardcore respawn
+ /// it is not. @API:native_player_game_mode_changed@.
+ pub(super) fn native_player_game_mode_changed(
+ &mut self,
+ player: u128,
+ name: &str,
+ from: i32,
+ to: i32,
+ cancel: &mut bool,
+ ) {
+ let _ = (player, name, from, to, cancel);
+ }
+ /// `player` (`name`) changed dimension (NeoForge's
+ /// `PlayerChangedDimensionEvent`): `from` and `to` are dimension ids
+ /// (`minecraft:overworld`, `minecraft:the_nether`, `minecraft:the_end`).
+ /// Heard once per move, when it has ended: the portal's exit is found
+ /// and the player stands there (after the destination has loaded), a
+ /// command's teleport has landed, or a respawn in another level than the
+ /// death's is placed for good (a bed or anchor, or the world spawn's
+ /// free column, after the fallback when a respawn block was gone). The
+ /// level of `to` is the one in place, and the player's state is swapped
+ /// in, as for `native_perform_command`: `native_acting_player`,
+ /// `native_tell`, the item helpers and the rest reach them. Heard for:
+ /// Nether and End portals (also riding a vehicle, and leaving the End as
+ /// its winner), `/execute in ... run tp` and any other command that
+ /// teleports a player into another level, and the death respawn. Not
+ /// heard: a move within a level (`/tp`, an End gateway), a player who
+ /// leaves before the move ends, a move that ends where it started (a
+ /// respawn in the dimension of the death), and anything outside a
+ /// dedicated server. @API:native_player_changed_dimension@.
+ pub(super) fn native_player_changed_dimension(
+ &mut self,
+ player: u128,
+ name: &str,
+ from: &str,
+ to: &str,
+ ) {
+ let _ = (player, name, from, to);
+ }
/// A player's client started (`flying`) or stopped flying (vanilla's
/// `handlePlayerAbilities`, which honours it only for a player who may
/// fly: creative or spectator), heard once for each change, on a server,
diff --cc docs/native-mods.md
index 0d0d76446,80d9b26ed..82b583289
--- a/docs/native-mods.md
+++ b/docs/native-mods.md
@@@ -1161,12 -1161,14 +1161,20 @@@ For mods that run where the world is si
`number`, `boolean`, `player`, `item`, `block_pos`. The usages of one command merge into one tree, which every
player receives after vanilla's (filtered by their level, as vanilla's is), so their chat box completes and colours
it. A name vanilla has, or a usage that doesn't parse, is left out with a warning in the log.
+- **`native_player_game_mode_changed(player, name, from, to, cancel)`**: a server player's game mode is about to change
+ (0 survival, 1 creative, 2 adventure, 3 spectator, as `NativeServerPlayer.game_mode`): the `/gamemode` command, the
+ F3+F4 switcher's packet and a hardcore world's respawn into spectator, once per change to a different mode. The mode a
+ player joins with (`defaultgamemode`) is not heard. Set `cancel` and the player keeps their mode. Inside the command and
+ the switcher the player's state is swapped in; for the hardcore respawn it is not (use the UUID with the helpers that
+ take one).
+ - **`native_player_changed_dimension(player, name, from, to)`**: a player changed dimension, once per move
+ (`from` and `to` are ids such as `minecraft:overworld` and `minecraft:the_nether`), heard when the move has ended:
+ the portal's exit is found and the player stands there, a command's teleport has landed, or a respawn in another
+ level than the death's is placed for good. `to` is the level in place and the player's state is swapped in (as in
+ `native_perform_command`), so `native_acting_player` and `native_tell` reach them. Heard for Nether and End portals
+ (also riding, and leaving the End as its winner), `/execute in ... run tp` and any command teleporting into another
+ level, and the death respawn. Not heard: a move within a level (`/tp`, an End gateway), a player who leaves before
+ the move ends, a respawn in the dimension of the death, and anything outside a dedicated server.
- **`native_player_toggle_flight(player, name, flying, cancel)`**: a player's client started (`flying`) or stopped
flying, once per change, for a player who may fly (creative or spectator), on a server. The player's state is swapped
in, so `native_tell` and the other helpers reach them. Set `cancel` to refuse it: the player keeps the state they