Skip to main content

steel_registry/
block_entity_type.rs

1use rustc_hash::FxHashMap;
2use steel_utils::Identifier;
3
4/// Represents a block entity type in Minecraft.
5/// Block entities are used for blocks that need to store additional data
6/// beyond their block state, such as chests, furnaces, signs, etc.
7#[derive(Debug)]
8pub struct BlockEntityType {
9    pub key: Identifier,
10}
11
12pub type BlockEntityTypeRef = &'static BlockEntityType;
13
14pub struct BlockEntityTypeRegistry {
15    block_entity_types_by_id: Vec<BlockEntityTypeRef>,
16    block_entity_types_by_key: FxHashMap<Identifier, usize>,
17    allows_registering: bool,
18}
19
20impl BlockEntityTypeRegistry {
21    #[must_use]
22    pub fn new() -> Self {
23        Self {
24            block_entity_types_by_id: Vec::new(),
25            block_entity_types_by_key: FxHashMap::default(),
26            allows_registering: true,
27        }
28    }
29}
30
31crate::impl_standard_methods!(
32    BlockEntityTypeRegistry,
33    BlockEntityTypeRef,
34    block_entity_types_by_id,
35    block_entity_types_by_key,
36    allows_registering
37);
38
39crate::impl_registry!(
40    BlockEntityTypeRegistry,
41    BlockEntityType,
42    block_entity_types_by_id,
43    block_entity_types_by_key,
44    block_entity_types
45);