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