A shift-click during a drag on a mod menu type only ends the drag

On a mod's own menu type the drag lives in the connection's machine menu,
not in the hub menu's drag, so lan_mod_quick_move passed the click to the
mods. Leave it to lan_machine_click, which resets the quick craft as
AbstractContainerMenu.doClick does.

Fixes #6907.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
breachatoandClaude Opus 5.5 committed 2026-11-02 09:42:22 +01:00
1 parent e0bafed170
commit 77613e9250
2 files changed
+38

No files matched your search

@@ -126,6 +126,17 @@ impl Game<'_> {
}
let size = menu.size;
let window = menu.window;
// A mod menu type keeps its drag in the connection's machine menu
// (`lan_machine_click`), not in `menu.drag`: a shift-click during it
// goes there too, to only end the drag.
if host
.play
.get(&conn)
.and_then(|play| play.crafting.machine.as_ref())
.is_some_and(|(w, m)| *w == window && m.quick_crafting())
{
return false;
}
if !matches!(
self.world.block_entities.get(&pos),
Some(BlockEntity::Mod(m)) if !m.id.is_empty()
+27
View File
@@ -2545,6 +2545,12 @@ impl Menu {
}
}
/// Whether a drag (quick craft) is in progress (`quickcraftStatus != 0`):
/// the next click other than a quick craft only ends it.
pub fn quick_crafting(&self) -> bool {
self.quick_status != 0
}
fn reset_quick_craft(&mut self) {
self.quick_status = 0;
self.quick_slots.clear();
@@ -3668,6 +3674,27 @@ pub(crate) mod tests {
});
}
/// #6907: a drag in progress is seen from outside the menu, and a
/// quick move during it only ends the drag (`doClick`'s resetQuickCraft).
#[test]
fn a_quick_move_during_a_drag_only_ends_it() {
with_menu(Kind::Chest(3), |env, menu| {
menu.creative = false;
menu.set_slot(env, 27, stack("dirt", 10));
menu.carried = stack("cobblestone", 64);
assert!(!menu.quick_crafting());
// Start a left drag, then drag across chest slot 0.
menu.click(env, -999, 0, Input::QuickCraft).unwrap();
menu.click(env, 0, 1, Input::QuickCraft).unwrap();
assert!(menu.quick_crafting());
// A shift-click now moves nothing and ends the drag.
menu.click(env, 27, 0, Input::QuickMove).unwrap();
assert!(!menu.quick_crafting());
assert_eq!(menu.slot(27).map(|s| s.count), Some(10));
assert_eq!(menu.slot(0), None);
});
}
/// #1832: a potion taken from the creative inventory and put in the
/// hotbar keeps its `PotionContents` (the brew), as vanilla's
/// `PotionContents.createItemStack` builds it: the item tab's stack is