fix: the window's inventory follows a mode change too

set_game_mode runs on the server thread; the window changes mode through
the server's game event (set_mode_id), so the switch to the creative
screen now lives in set_mode, which both reach.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Horizon agentandClaude Opus 5.5 committed 2026-11-09 16:38:19 +01:00
1 parent e2482f0e1d
commit 470f9d01e0
2 files changed
+8 -8

No files matched your search

@@ -1389,8 +1389,6 @@ impl Game<'_> {
}
}
self.set_mode(mode);
// InventoryScreen.containerTick: the open inventory follows the mode.
self.mode_changed_under_inventory();
true
}
fn cmd_gamemode(&mut self, ctx: &Context) -> R<i32> {
+8 -6
View File
@@ -82,9 +82,10 @@ fn inventory_after_mode(screen: Screen, creative: bool, spectator: bool) -> Scre
}
impl Game<'_> {
/// `InventoryScreen.containerTick` and `CreativeModeInventoryScreen.containerTick`
/// on a mode change: the inventory the player has open follows the mode.
pub(super) fn mode_changed_under_inventory(&mut self) {
/// `InventoryScreen.containerTick` on a mode change: the inventory the player has
/// open follows the mode. (`CreativeModeInventoryScreen.containerTick`, the way back
/// to survival, is not ported yet.)
fn mode_changed_under_inventory(&mut self) {
match inventory_after_mode(self.screen, self.creative, self.spectator()) {
Screen::Creative => {
if let Some(c) = self.carried.take() {
@@ -170,9 +171,10 @@ impl Game<'_> {
p.flying = false;
}
}
if mode == GameMode::Spectator && self.screen == Screen::Inventory {
self.screen = Screen::Playing;
}
// InventoryScreen.containerTick: the open inventory follows the mode. Here, not in
// the command, so the window hears it too: it changes mode through the server's
// game event (`set_mode_id`), never through `set_game_mode`.
self.mode_changed_under_inventory();
}
}
impl Game<'_> {