pub enum Click {
Pickup {
slot: usize,
button: MouseButton,
},
DropCarried {
button: MouseButton,
},
QuickMove {
slot: usize,
},
Swap {
slot: usize,
with: SwapTarget,
},
Clone {
slot: usize,
},
Throw {
slot: usize,
whole_stack: bool,
},
PickupAll {
slot: usize,
direction: FillDirection,
},
QuickCraft(QuickCraft),
}Expand description
A container click, validated from the raw protocol fields.
Produced by Click::parse; every slot is guaranteed in range for the
menu the click was parsed against.
Variants§
Pickup
Left/right click on a slot.
DropCarried
Left/right click outside the window, dropping the carried stack
(slot_num == -999 on the wire).
Fields
Left drops the whole stack, right drops a single item.
QuickMove
Shift-click.
Swap
Number key 1-9 or the offhand key, swapping a menu slot with a player inventory slot.
Clone
Middle-click copy (creative only).
Throw
Drop key: Q (single item) or Ctrl+Q (whole stack).
Fields
PickupAll
Double-click, collecting matching stacks into the cursor.
Fields
direction: FillDirectionWhich end of the menu to start collecting from.
QuickCraft(QuickCraft)
One phase of a drag (paint) operation.
Implementations§
Source§impl Click
impl Click
Sourcepub const fn slot(&self) -> Option<usize>
pub const fn slot(&self) -> Option<usize>
The slot this click targets, or None for clicks outside the window
and drag phases.
Sourcepub const fn is_valid_for(&self, slot_count: usize) -> bool
pub const fn is_valid_for(&self, slot_count: usize) -> bool
Returns whether every index encoded in this click satisfies the
invariants normally established by Click::parse.
Source§impl Click
impl Click
Sourcepub fn parse(
slot_num: i16,
button: i8,
click_type: ClickType,
slot_count: usize,
) -> Option<Self>
pub fn parse( slot_num: i16, button: i8, click_type: ClickType, slot_count: usize, ) -> Option<Self>
Parses the raw fields of a container-click packet against a menu with
slot_count slots.
Returns None for malformed input — an out-of-range slot, an invalid
swap button, an unknown mouse button, or an invalid drag encoding.
Callers should ignore the click (vanilla’s behavior for packets its
clients never send) but may still want to resync the client.
Trait Implementations§
impl Copy for Click
impl Eq for Click
impl StructuralPartialEq for Click
Auto Trait Implementations§
impl Freeze for Click
impl RefUnwindSafe for Click
impl Send for Click
impl Sync for Click
impl Unpin for Click
impl UnsafeUnpin for Click
impl UnwindSafe for Click
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
self with key and returns true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreArc<SyncMutex<>>