Merge pull request #2887 from masa-masa-0314/fix/creative-search-reset-on-open

Creative inventory: fix the search box keeping the last search after closing
This commit is contained in:
rdbt
2026-10-28 00:32:36 +00:00
committed by GitHub
3 changed files with 23 additions and 8 deletions
+13
View File
@@ -355,6 +355,19 @@ impl Creative {
pub fn search_items(&self) -> &[ItemStack] {
&self.search_items
}
/// Opening the screen: vanilla rebuilds CreativeModeInventoryScreen, whose
/// init() makes a fresh search box and a zeroed scrollbar; only the tab
/// persists (its static selectedTab). selectTab on the reopened screen
/// takes the oldTab != tab branch, so it empties and refocuses the box.
pub fn reopen(&mut self) {
self.search.set_value("");
self.release();
self.scroll = 0.0;
self.search.focused = self.tab().search;
if self.search.focused {
self.search.reset_blink();
}
}
/// Indices into `search_items` that CreativeModeInventoryScreen.refreshSearchResults
/// shows for `term`: the whole tab when empty, the tag tree after `#`, else
/// the name tree, both over vanilla's suffix arrays (substring matches,
+5 -4
View File
@@ -12070,11 +12070,12 @@ impl Game<'_> {
Screen::Playing => {
// key.inventory while riding a tamed mount opens its inventory.
if !self.open_ridden_mount_menu() {
self.screen = if self.creative {
Screen::Creative
if self.creative {
self.screen = Screen::Creative;
self.creative_screen.reopen();
} else {
Screen::Inventory
};
self.screen = Screen::Inventory;
}
self.capture(false);
}
}
+5 -4
View File
@@ -5346,11 +5346,12 @@ impl Game<'_> {
KeyCode::KeyE => {
// The inventory opens without telling the server.
self.recipe_ui.reset_screen();
self.screen = if self.creative {
Screen::Creative
if self.creative {
self.screen = Screen::Creative;
self.creative_screen.reopen();
} else {
Screen::Inventory
};
self.screen = Screen::Inventory;
}
self.craft_size = 2;
self.capture(false);
Ok(true)