Skip to main content

MenuKind

Trait MenuKind 

Source
pub trait MenuKind:
    ErasedType
    + Send
    + Sync {
    // Provided methods
    fn slots_changed(
        &mut self,
        _behavior: &mut MenuBehavior,
        _guard: &mut ContainerLockGuard,
        _player: &Player,
    ) { ... }
    fn removed(&mut self, _behavior: &mut MenuBehavior, _player: &Player) { ... }
    fn on_rename(
        &mut self,
        _behavior: &mut MenuBehavior,
        _name: String,
        _player: &Player,
    ) { ... }
    fn on_open(
        &mut self,
        _behavior: &mut MenuBehavior,
        _guard: &mut ContainerLockGuard,
        _player: &Player,
    ) { ... }
    fn on_tick(
        &mut self,
        _behavior: &mut MenuBehavior,
        _guard: &mut ContainerLockGuard,
        _player: &Player,
    ) { ... }
    fn on_slot_clicked(
        &mut self,
        _behavior: &mut MenuBehavior,
        _guard: &mut ContainerLockGuard,
        _click: Click,
        _player: &Player,
    ) -> ClickOutcome { ... }
    fn on_drag(
        &mut self,
        _behavior: &mut MenuBehavior,
        _guard: &mut ContainerLockGuard,
        _action: QuickCraft,
        _player: &Player,
    ) -> ClickOutcome { ... }
    fn can_drag_to(&self, _slot_index: usize) -> bool { ... }
    fn still_valid(&self, _behavior: &MenuBehavior, _player: &Player) -> bool { ... }
    fn can_take_item_for_pick_all(
        &self,
        _carried: &ItemStack,
        _slot_index: usize,
    ) -> bool { ... }
    fn quick_move(
        &mut self,
        _behavior: &mut MenuBehavior,
        _guard: &mut ContainerLockGuard,
        _slot_index: usize,
        _player: &Player,
    ) -> Option<ItemStack> { ... }
}
Expand description

Per-menu behavior that isn’t shared: recompute-on-change, validity, close cleanup, and the optional shift-click override.

Menu transitions requested while a hook owns mutable access to the current menu are applied after that hook returns.

Concrete implementations must claim a unique steel_utils::DowncastTypeKey through steel_utils::DowncastType.

Provided Methods§

Source

fn slots_changed( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _player: &Player, )

Recompute recipe-driven slots after a click touched a real slot.

Source

fn removed(&mut self, _behavior: &mut MenuBehavior, _player: &Player)

Extra cleanup on close beyond [Menu::removed].

Source

fn on_rename( &mut self, _behavior: &mut MenuBehavior, _name: String, _player: &Player, )

Applies a rename from the client (anvil-style text input) and recomputes any result. No-op for kinds without a rename input.

Source

fn on_open( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _player: &Player, )

Runs after initial contents are built but before they’re sent, so anything populated here appears in the first render.

Source

fn on_tick( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _player: &Player, )

Runs once per tick per viewer while open, before changes are synced.

Source

fn on_slot_clicked( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _click: Click, _player: &Player, ) -> ClickOutcome

Runs for every non-drag click before default handling. Return ClickOutcome::Consume to treat the slot as a button, or ClickOutcome::Fallthrough for default handling.

Source

fn on_drag( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _action: QuickCraft, _player: &Player, ) -> ClickOutcome

Runs for each drag phase before default handling. Return ClickOutcome::Consume to cancel the drag.

Source

fn can_drag_to(&self, _slot_index: usize) -> bool

Returns true if a drag may distribute items into slot_index.

Source

fn still_valid(&self, _behavior: &MenuBehavior, _player: &Player) -> bool

Returns true if this menu is still valid for the player.

Source

fn can_take_item_for_pick_all( &self, _carried: &ItemStack, _slot_index: usize, ) -> bool

Returns true if an item may be taken from slot_index during pickup-all.

Source

fn quick_move( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _slot_index: usize, _player: &Player, ) -> Option<ItemStack>

Shift-click override. Return Some to fully handle the quick-move, or None to fall back to the route table.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§