Skip to main content

steel_core/block_entity/entities/
ender_chest.rs

1//! Ender chest block entity implementation.
2
3use std::sync::{Arc, Weak};
4
5use simdnbt::borrow::BaseNbtCompound;
6use simdnbt::owned::NbtCompound;
7use steel_registry::vanilla_block_entity_types;
8use steel_utils::{BlockPos, BlockStateId, DowncastType, DowncastTypeKey};
9
10use crate::block_entity::{BlockEntity, BlockEntityBase};
11use crate::world::World;
12
13/// Ender chest block entity.
14pub struct EnderChestBlockEntity {
15    base: Arc<BlockEntityBase>,
16}
17
18// SAFETY: This key is owned by Steel and uniquely identifies `EnderChestBlockEntity`.
19unsafe impl DowncastType for EnderChestBlockEntity {
20    const TYPE_KEY: DowncastTypeKey = DowncastTypeKey::new("steel:block_entity/ender_chest");
21}
22
23impl EnderChestBlockEntity {
24    /// Creates a new ender chest block entity.
25    #[must_use]
26    pub fn new(level: Weak<World>, pos: BlockPos, state: BlockStateId) -> Self {
27        Self {
28            base: Arc::new(BlockEntityBase::new(
29                &vanilla_block_entity_types::ENDER_CHEST,
30                level,
31                pos,
32                state,
33            )),
34        }
35    }
36}
37
38impl BlockEntity for EnderChestBlockEntity {
39    fn base(&self) -> &BlockEntityBase {
40        &self.base
41    }
42
43    fn load_additional(&self, _nbt: &BaseNbtCompound<'_>) {}
44
45    fn save_additional(&self, _nbt: &mut NbtCompound) {}
46}