steel_core/inventory/menu/kinds/
ender_chest_menu.rs1use steel_utils::{DowncastType, DowncastTypeKey};
4
5use crate::inventory::ender_chest::{ENDER_CHEST_SLOTS, SyncPlayerEnderChest};
6use crate::inventory::menu::kinds::chest_menu::chest_with_kind;
7use crate::inventory::prelude::*;
8use crate::player::player_inventory::PlayerInventory;
9
10#[must_use]
12pub fn ender_chest(
13 inventory: Shared<PlayerInventory>,
14 container_id: u8,
15 container: SyncPlayerEnderChest,
16) -> Menu {
17 chest_with_kind(
18 inventory,
19 container_id,
20 container.clone(),
21 ENDER_CHEST_SLOTS / 9,
22 EnderChestKind { container },
23 )
24}
25
26pub struct EnderChestKind {
29 container: SyncPlayerEnderChest,
30}
31
32unsafe impl DowncastType for EnderChestKind {
35 const TYPE_KEY: DowncastTypeKey = DowncastTypeKey::new("steel:menu/ender_chest");
36}
37
38impl MenuKind for EnderChestKind {
39 fn still_valid(&self, _behavior: &MenuBehavior, player: &Player) -> bool {
40 self.container.lock().still_valid(player)
41 }
42
43 fn removed(&mut self, _behavior: &mut MenuBehavior, _player: &Player) {
46 self.container.lock().clear_active_chest();
47 }
48}